As @allObjects suggests, the GPS module is a good example - just use indexOfand substr to search for newlines and split the string. (or you could use str.split("\n") and deal with the array that comes out the end of it).
If you were dealing with particularly long lines you could use indexOf on the data coming in rather than the whole line, but for <50 byte packets the way that's used there is going to work great and is reasonably simple.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
As @allObjects suggests, the GPS module is a good example - just use
indexOf
andsubstr
to search for newlines and split the string. (or you could usestr.split("\n")
and deal with the array that comes out the end of it).If you were dealing with particularly long lines you could use indexOf on the data coming in rather than the whole line, but for <50 byte packets the way that's used there is going to work great and is reasonably simple.