Ahh, right... Well, I can do a flush function - although busy-waiting in JavaScript is generally not a great idea as it relies on the idle handler firing reasonably often to work properly.
a way to tell espruino to not fire the next on(data) event until so many bytes have been received, with the option of a timeout.
I think this is probably overkill to implement in Espruino, and extremely niche. I'd have thought it would be reasonably easy to just create a JS function that would handle that though.
Personally, I think really to do this reliably you probably need to handle framing yourself rather than relying on forcing it to send in packets - you might always get some chunk of data split up when it shouldn't be - or maybe some data gets sent over bluetooth but then the send fails and has to be retried or something like that.
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.
Ahh, right... Well, I can do a flush function - although busy-waiting in JavaScript is generally not a great idea as it relies on the idle handler firing reasonably often to work properly.
I think this is probably overkill to implement in Espruino, and extremely niche. I'd have thought it would be reasonably easy to just create a JS function that would handle that though.
Personally, I think really to do this reliably you probably need to handle framing yourself rather than relying on forcing it to send in packets - you might always get some chunk of data split up when it shouldn't be - or maybe some data gets sent over bluetooth but then the send fails and has to be retried or something like that.