I've gone through the Serial Input Basics thread and a couple of others, still have not find the optimal solution for my problem. Hope some guru out there can give some guidance
here is the problem:
I have an Arduino board (ESP32) talking to a LTE modem via serial,
I would like to send command to the modem and wait for a response or a timeout.
right now, if I use the simple serial.read(), it does not handle a timeout and since it is single thread system, I can't stop it using another thread when timeout reached.
if I use serial.readstring() or readbytes(), it insist that read until the timeout is reached, which I would like to exit as soon as response is obtained.
if I use serial.readstringutil, or readbytesuntil, it require a specific end char to stop, in my case, the response is not quite unified with the same end char, the ending condition differs depends on the command I send to the modem. so whenever the response comes in, I need to trigger another matching function (varies depends on the initial command) to determine if a proper response is received.
I am sure some of you have met this issue before, kindly share your thoughts on this, or refer me to some other post/page which I may not have read .