Drew
Drew

Reputation: 13408

Write data to Arduino from terminal (OSX)

I'm attempting to send data to my Arduino over my USB cable from the OSX terminal. My understanding was that I should be able just do something like echo b > /dev/tty.usbmodem1411 or echo b > /dev/cu.usbmodem1411 but neither of those are working. I also tried an explicit newline by doing echo "b\r\n" > /dev/tty.usbmodem1411 and echo "b\r\n" > /dev/cu.usbmodem1411 but neither worked. I don't really have any idea what's going on, what the difference between the cu and tty is (when I write data with the Serial Monitor in the Arduino IDE I use the cu version, and that works)

Upvotes: 1

Views: 5296

Answers (2)

Drew
Drew

Reputation: 13408

I found this blog post: http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/

And this code: https://github.com/todbot/arduino-serial

Which solve the problem.

Upvotes: 0

ladislas
ladislas

Reputation: 3070

It is not as easy as echoing :)

Here is great tutorial with everything you need to know about Serial Communication -- Serial Terminal Basics

I'd be happy to answer more of your questions if needed.

EDIT:

for the shell script something like that:

#!/bin/bsh

screen /dev/tty.usbmodem* 9600

# and everything you need to do

Upvotes: 3

Related Questions