Arduino UNO (R2), fw 001, linux driver performance/serial bugs

Hi all, I'm wondering if Arduino UNO (R2) has still issues on serial port for Linux. I did see the info on http://arduino.cc/blog/2011/02/15/fix-to-uno-and-mega-2560-linux-serial-problems/ and I'm using an R2 board with the updated(fixed) fw.

BUT ... I wrote a simple loop that dumps the analog values as fast as possible. If I connect on windows using HyperTerminal everything works every time, not a single glitch, awesome performance.

If I use Linux (on /dev/ttyACM0) I see a problem. 1) I plug the board and connect with picocom: result is perfect. Then hang-up and quit. 2) reconnect with picocom ... I see few values .... and then nothing, nothing comes on my serial.

So ... If I unplug and plug the board ... I can repeat step 1 and 2 every time... I was thinking my fw was old, but I did check the version number for ATU2 and it;s already updated.

The weird part is that if I put a little delay in the loop on the arduino board, it seems more reliable, it works longer .. but from time to time I do see the same issue.

So to debug further I did protect the dump loop with a "start"/"stop" serial command. I connect the board, send a start, I get the dump of analog input values, I send a stop ... and it does stop. On hyper terminal ... again no problems! I can run max speed 115200 and even 230400, not a single glitch.

On linux, /dev/ttyACM0 ... I connect (ok) then issue the start command (ok), see the log (ok), send the stop command ... the stop command seems to be written to the serial port, but I never see the arduino board to REALLY stop sending data, it keeps going... with or without delay in the loop.

any idea/hint? :(

It sounds like the problem is with the linux USB serial driver, not with the Arduino. The "serial" part really only exists between the 8u2 chip and the 328p chip on the Arduino. That is the connection that runs at the configured "serial bitrate." If you can assume the Arduino board is well designed, there is no reason why you shouldn't always run at the fastest possible bitrate, as that's only an inch or so of traces between the two chips. The connection between the PC and the Arduino is USB, and runs at USB rate (12 Mbps IIRC) using the USB protocol. The Linux (or Windows) device driver then turns this USB data around and presents it as a "tty" device, emulating the interface that an application would expect to see from a serial port. If the emlation of tty devices works poorly, especially when a device is un-plugged and re-plugged, then it's the Linux USB serial driver that has a bug, not the Arduino board.

thanks jwatte for your reply, it makes a lot of sense.

since the difference between win/linux it's so wide, it must be the sw driver for usb/tty. If I'm not asking too much, do you know which driver it's set for linux when we connect arduino for ttyACM0?

I'm not a usb expert .. but I might take a look ... :-)

I actually had a problem with a R1, that I don't have with a R3. Manually re-configuring the port after opening "fixed" this problem. Here's my code:

https://github.com/jwatte/robotcode/blob/master/benchmark/snarf.cpp

You can also do this from the command line with the "stty" command. Read the man page for "stty" and for "tty_ioctl" and for "tcsetattr" to understand what the different controls are (it's pretty technical.)