Sooner or later, any buffer can be filled with data. It is not always possible to do the parsing often enough. Maybe just the CPU performance is not enough.
No. Serial is really slow. Even the slowest Arduino can perform thousands of operations between each Serial character arriving.
If you are burning up those thousands of instructions doing floating-point calculations then that doesn’t mean Serial is broken. It means you or your library are doing something wrong.
If I understand correctly, then the buffer is filled with data by an interrupt from the UART RX. Therefore, it is necessary to make room for new data before starting the parsing in LOOP ().
Nope. Parsing by using Serial.read() is the only thing that should be taking characters out of that buffer. If parsing is working fast enough then it will empty the buffer before the next packet finishes transmission.
There should be a clear buffer command. After all, this is just zeroing the variable of the buffer filling counter. Can Serial.End () and Serial.began () apply and then enable parsing? Then the parsing will checknew data like in first packet, as after resetting the CPU.
Double nope! If you erase the buffer then you would have to wait at least 100 milliseconds for the next packet to start. Then wait for that packet to finish. That is a long time for the Arduino to waste when it already had the data buffered and waiting for the parser.
Of course, I will try also your buffer cleaning solution. Thanks!
No. Don’t use that code. Just verify that the parser always completes its job before the next packet is complete in the Serial buffer.
Print out Serial.available() after getting that first packet. It should be a small number like 0 or maybe 100.