• But Serial.read() appears to be a blocking call

    It's not blocking, but it'll only return what data is available.

    It's much easier to use Serial1.on('data', callback) to get called back when the data arrives. You'll also need to convert it to a Uint16Array (use new Uint16Array(E.toArrayBuffer(data))) - and also be aware that you need to make sure you've received all the relevant data - since Serial1.on may be called before the full 'frame' is received. Most protocols use a number that isn't normally sent to denote an 'end of frame'.

    You should also use Serial.write(myUint16Array.buffer) to write the underlying buffer since trying to write a normal Uint16Array directly will result in each element being truncated to just 8 bits.

About

Avatar for Gordon @Gordon started