Yes. The receive ring buffer is 64 bytes and will discard anything past that until the program reads them out of the buffer.
But be careful: In serial monitor, any number of bytes more than 64 and ending with Enter will give you Serial.available==63
at the Arduino - and no \n
at the end. This is important especially if you are using readline() in Python.
However, when NOT in the serial monitor, you can actually get the result Serial.available==64
and use Serial.read() to get them in sequence. No \n
is required.
So be careful debugging in the serial monitor when it comes to buffer size and newlines. It is subtly different when programs are talking vs the serial monitor.
Most important difference is that a program can send a single byte and continue. Serial monitor will send a single character, but is blocked until you press newline to get it to transmit. Yet serial monitor does not send the newline character.
Simple scenario: You want the Arduino to respond to a single-byte command code send via the serial cable from a Raspbian system running a Python data logging program based on something the Arduino reads or by time of day.
You need to trigger the Arduino to take some action as a result.
So on the Arduino you want to first clear the receive buffer by simply reading it out like so:
Arduino code to read a single-character command:
byte ch;
void setup() {
Serial.begin(9600));
while (Serial.available>1) ch = ser.read();
}
void loop {
if (Serial.Available==1 && Serial.read()=='X') {
.....respond to the X command....
}
else
....etc...
delay(60000);
}
Note that when a Rpi Python program is sitting there waiting for linein=ser.readline() the Arduino transmit buffer size is not relevant. Python collects each byte as it comes in until the \n
then returns the string to linein. The line can be very long. I have tested it to 100 bytes.
Software.Serial acts exactly the same way.