• I know I used to know how to do this, but I've been in Arduino land a lot lately, and now this is puzzling me... I am sure there's a right way.

    I have serial data coming in. Each message will consist of a number of characters terminated with a newline.
    What I do on Arduino is load the characters one at a time into the incoming message buffer, and if the character is a newline, instead of doing that, I send the buffer off for processing.

    But on Espruino, I might get multiple characters at once - which means I could get the end of one message and the start of the next. What's the smart way to handle this? I'm sure it's a common thing that people have done, and settled on the obvious solution.

    Is there really no better way than using one of the substring functions to cut one character at a time off of the incoming data, and then apply the arduino-style logic? This seems uglier than I'd expect for Espruino.

    My initial reaction is that handling serial data on Espruino is much harder than in Arduino land, where you can just pick off a character at a time and easily process it - but I suspect I'm thinking about it wrong.

    Thanks

About

Avatar for DrAzzy @DrAzzy started