Depending on the datarate and what else you do when you get the decoded data it could be that the data can't be processed fast enough and the buffer overflows?
Maybe check E.getErrorFlags() to see if that's the case? If so it's finding a way to decode the data a bit faster - maybe something like:
Serial1.on('data', function(data) {
buf += data;
var i = buf.indexOf("\x00\xFF");
while (i>=15) {
decode(buf.substr(i-15,16));
buf = buf.substr(i+1);
i = buf.indexOf("\x00\xFF");
}
});
Not tested, but might work - of course the way I've done it above you're always one frame behind.
Also... which board are you using? different boards have different serial buffer sizes
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.
Depending on the datarate and what else you do when you get the decoded data it could be that the data can't be processed fast enough and the buffer overflows?
Maybe check
E.getErrorFlags()
to see if that's the case? If so it's finding a way to decode the data a bit faster - maybe something like:Not tested, but might work - of course the way I've done it above you're always one frame behind.
Also... which board are you using? different boards have different serial buffer sizes