Is there an associated timeout function when using Serial Buffer

I have been testing the Serial library buffer() function and it works very well with Serial Event.

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.

Hello,

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.

Some references:

I have had success with open > stop > open of the serial port to reset it and flush all the buffers between the Arduino and Processing.

If you are using an Arduino or other serial device experiment a little and disrupt the connection.

:)

Ok thanks for the comments.

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.