• @DrAzzy, take a look at the GPS module... it does that the Espruino way: constantly receiving and adding to the buffer, and as long as a line is found it removes that line from the buffer and processes it. Latter could also be made asynchronous, so if there is something coming in while one line is processed, that this incoming (urgent) thing is handled first, such as adding new chars to the buffer that is then checked against line ends. The (async) processing loop ends when no complete line is found anymore. A watchdog could be implemented that if when no line end comes in within a certain time, flushing is triggered, because most likely the (eventually) remaining data in the buffer is garbage...

    I vaguely recall that we did some of this 'over buffer looping'.... nowI recall: it was sending out stuff without using the drain w/ callback option... conceptually, it is very similar.

About

Avatar for allObjects @allObjects started