I have a project where I'm trying to use a Raspberry Pi to run a remote control webserver and relay commands to an Arduino over the USB port.
I've done projects in the past where I've easily been able to connect to and control an Arduino using .NET programs from a windows PC, but now I'm having a lot of trouble getting even basic serial communication to work. I'm running Raspbian Jessie Lite so I don't have a GUI to run the Arduino serial port monitor. The Arduino is a Mega 2560 running the Serial Event example program and is verified to be working correctly with the Arduino serial port monitor on my windows PC.
I've done a fair amount of searching and have tried several methods (screen, minicom, python scripts) without success, but finally found something that kind of works: http://forum.arduino.cc/index.php/topic,38838.0.html#1
Following that thread, I use the commands:
stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -hupcl tail -f /dev/ACM0 echo "test" > /dev/ACM0
At first this doesn't appear to do anything (same as all the other methods I've tried), but when I unplug the Arduino from the Raspberry Pi I suddenly get all the correct output in tail -f, but only when it actually disconnects. As long as I leave the Arduino connected the output seems to be stuck in some kind of buffer that is only flushed when the device is disconnected.
Does anyone have any idea of what might be causing this behavior and how to fix it?
Thanks in advance for any help.