Reputation: 5630
I have a rather strange issue. I DCcduino Uno (Arduino Uno copy) plugged into my Xubuntu box via the USB serial interface. Using the Arduino GUI Serial Monitor, I can communicate with the board as expected. Also, when the serial monitor is open, I can ssh into the box and run commands like
echo 1700 > /dev/ttyUSB0
completely fine. However, as soon as I close the serial monitor (even if the Arduino GUI is still running) that command no longer does anything.
I have tried open the serial port with several combinations of stty
arguments including everything from
stty -F /dev/ttyUSB0 9600 cs8 cread clocal
to
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
but it just won't write to the arduino. What am I doing wrong?
EDIT:
I just managed to get it working using
stty -F /dev/ttyUSB0 raw ispeed 9600 ospeed 9600 cs8 -ignpar -cstopb -echo
cat < /dev/ttyUSB0 > /dev/null &
echo "1700" > /dev/ttyUSB0
However, this only works with the backgrounded cat
running. Is there any way to get it working without that line?
Upvotes: 2
Views: 1654
Reputation: 5630
The best solution I was able to come up with was to use the pyserial
library and communicate with the arduino via python, using it like a bridge between bash and the arduino. I'm sure it's just an issue with not setting the right configuration with stty
but python works just fine.
Upvotes: 0
Reputation: 143
As far as I know the Arduino communicates over the serial comm port in an way that requires the connection to be present before any serial commands can be sent. I think this probably evolved as a method of preventing the AtMega chip from getting stuck waiting for commands. It also has to be compatible with the USB protocol that prevents devices from operating without a connection made.
Upvotes: 1