I just bought an Arduino Due and I'm having trouble reading from a simple serial IO program.
I have a SparkFun RedBoard which is like an Uno. With that, I just ran a "
stty" command to configure the baud rate and other terminal settings, and then I could do "
cat /dev/ttyUSB0". Actually I have a C++ program which opens "
/dev/ttyUSB01" and reads from it like a normal file.
Now, with the Due, the device is "
/dev/ttyACM0" and there have been a few snags. One of them is that after programming the Due, and running
stty, I have to open
/dev/ttyACM0 using the
screen /dev/ttyACM0 115200
and then kill screen, before
cat /dev/ttyACM0 will work. Otherwise,
cat prints out one byte and exits; rarely it prints out 10 bytes or a line, or sometimes it prints nothing.
This is a bit annoying and I can't figure out what
screen is doing to the device which I can't seem to accomplish using
stty command is:
sudo stty -F /dev/ttyACM* 115200 -parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts \ -ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc \ -ixany -imaxbel -iutf8 \ -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 \ -isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl \ echoke -flusho -extproc
I got this by running
stty -a < /dev/ttyACM0 after using
screen to initialize as above.
I thought it might have something to do with serial auto-reset, so I tried using a resistor between
RESET, but this did not fix the problem.
I should note that
cu from the
uucp package is able to read continuously from
/dev/ttyACM0, but unlike
screen it does not leave the terminal set up in such a way that a subsequent
cat command will work.
$ cu -l /dev/ttyACM0 -s 115200 <continuous stream of data> $ killall cu # (from another shell) $ cat /dev/ttyACM0 | hexdump -c <e.g. 7 bytes> $
cat would have printed an infinite stream. Any ideas how to accomplish this setup without using