Go Down

Topic: Board stops listening after reading 73 bytes on /dev/ttyACM* (Read 1 time) previous topic - next topic


Nov 12, 2013, 11:47 am Last Edit: Nov 12, 2013, 12:15 pm by giuscri Reason: 1
Hi there,

using the following piece of code written changing just few lines from what's been written by the user AlphaBeta (here)

Code: [Select]

int input;
int numberOfCharactersRead = 0;

void setup() {

void loop() {
 if (Serial.available()) {
   // Read next character ...
   input = Serial.read();
   Serial.print("DEBUG: numberOfCharactersRead ==");

   // Print just-read character ...
   Serial.print("DEBUG: Serial.println((char)input) ==");

and typing from the command-line (using Bash)

Code: [Select]

$ cat theLog > /dev/ttyACM0    # theLog: ASCII text ; /dev/ttyACM0: serial port Arduino is listening to.

via the Serial Monitor (in the Arduino IDE) I see that only ~70 bytes are read -- doesn't matter how many bytes the file is filled with.

As for my understanding, the serial port gives up listening if it takes too long to read the file ... (?) Indeed, if one uses redirection to pass an infinite flow of bytes like

Code: [Select]
$ od /dev/urandom > /dev/ttyACM0

then problems disappear.

Any suggestion on how to fix that?

Thank you folks :-)


Remove the printout and see what happens. My guess is that you fill the output buffer and the Arduino then waits for space which then misses the receive.

To test this idea simply remove the printout in the sketch for each recieved character and do for instance one every 100 or a time limit.

My guess is also that od and cat give very different bursts of data to the driver. This also gives an idea on how to fix this. You can write your own version of cat that does not write so fast ;-) You can also use expect and look for "sync" messages. A bit like xon/xoff.


Go Up