But I am left wondering what happens if the Serial port is somehow disrupted. Is there a timeout parameter somewhere that I can use (a bit like in Arduino with it’s Serial.setTimeout() function), or is there some other way to still trigger the Serial Event (or trigger a flag/event to notify) to read or even clear the data.
I have written code that sends a “heartbeat” (regular intervals) from Arduino and if it is not received by Processing I can respond accordingly (this depends on what you want to do).
You can also do handshaking to request data and write a timeout() routine if there is no response.
I was hoping to find a non-polling timeout method that can be used with Serial Event when buffer size is say > 30 bytes etc. Sounds like I’ll have to stick to polling the serial bus as this way I can detect a break in the serial data stream.
In my application, I don’t have control over the MCU firmware otherwise I would probably introduce a terminating character, which would allow me to use the bufferUntil() command.