I have an Arduino connected to my USB port (on my Linux based OS) at /dev/ttyACM0
which is listening for serial data to be read and processes them when received. All I need to do is send data to this port. I have used the program minicom
with the following command:
minicom --device=/dev/ttyACM0 --baudrate=9600
and it works perfectly. The problem is that minicom
runs in an interactive environment and I wish to write a shell script which sends information non interactively, something like
minicom --device=/dev/ttyACM0 --baudrate=9600 "message"
From what I understand, everything in Unix is a file - even USB ports - so I was wondering if it would be possible to simply echo
the bytes directly to the device file:
echo "message" >/dev/ttyACM0
But this did not work. I realized this might have something to do with mismatch in Baud rates. I ran the following command
$ stty -F /dev/ttyACM0
speed 9600 baud; line = 0;
min = 0; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
But the baud rate is at 9600. Is there any way I can get this to work with the above command?