Determining if Serial.readBytesUntil() has passed or failed??


i was wondering if there was a way to quickly determine if the function Serial.readBytesUntil() has passed or failed to read in the termination character?

i notice that if i send the arduino a character then let this function timeout it still returns the number of bytes (or 1 in this case) that it read in. but i can not tell if it actually saw the termination character so my code continues to process it as if it did see the terminator.

basically i have come to the conclusion that this function is not capable of alerting you of this. so i was wondering if there is an alternative without having to write an entire function to handle it myself.

for example, first readBytesUntil() is called, then when it either see the termination character, exceeds the length of the specified buffer or times out it will return some number, lastly check to see if the last character in the buffer array was the desired termination character (if true then proceed otherwise loop around again).

any help here would be much appreciated!!

I don't know what that function does, and I would not use it.

I am suspecting that a function like that is going to consume all of the processors time, until it gets what it is waiting for. Which is not what you want, if you have anything else to do.

If I wanted that functionality, I'd implement it myself in code, so you can test it to do exactly what you want. There are examples around showing how to do this. each time you loop(), collect any serial characters that are there into a buffer. Also remember the time when you got them. When you get the last character you expect, process the data. If you get no more characters a certain time after the last one you got, process the data.