You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • The serial port doesn't really have any concept of when it is finished - so you won't get any 'end' or 'complete' event produced by it.

    Also, the chunk size used by pipe is more of a maximum chunk size in Espruino - it may not do the same as on node.js, but if it is idle and there is data available, it'll just push what it has.

    To be honest in this case, using the Serial.on('data' will probably work best for you. pipe was really added for files and network sockets, but was extended to other things to make it more complete rather than because it's always the best way of doing things.

    I don't know anything about SBUS, but you might get a framing error if the serial line is brought low after each transmission. Maybe try:

    Serial1.on('framing', function() {
        console.log("Frame?");
      });
    

    If that's the case, you can use the serial data handler to store the data, and can then parse it all when you get the framing error from the serial port - it'd be a nice way of working without worrying about possibly being out of sync.

About

Avatar for Gordon @Gordon started