Hi,
I am a bit stuck with the small details of the Serial.available() function. From the online documentation it's pretty clear to me that the function will return the number of bytes available in the serial input buffer. To test this I made a very simple sketch:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(Serial.available());
delay(200);
}
Then in the serial monitor the value 0 is returned which is correct. Then I type 5 characters and send them which changes the value to 5 which is still correct.
Then I type another 5 characters and send them, now expecting the returned value to be 10 but it's not, it stays at 5 and if I try to send additional characters the serial monitor seems to stop working until I reset the MCU. I have tried sending various combinations for the number of characters, it never seems to register the second set of characters sent.
Since I never read any bytes from the input buffer the bytes available should just keep increasing (as I send more characters) up to the buffer limit right...
Could anybody shed some light on this behaviour?
I am running a feather board which uses the SAMD21 MCU (same as the Arduino Zero).