node-serialport
node-serialport copied to clipboard
Best practices for sequences of events
We should have more documentation and examples around handling sequences of events that parsers
doesn't quite cover.
For example.
- Waiting for a
ready
byte or bytes before switching to a parser. - Using serialport to implement simple protocols (eg, data encapsulation and command passing)
- Using serialport to implement more complex protocols like
firmata
- Modem commands that respond with an
OK
- Manage a queue of requests (writes) and expected response lengths. and send each request sequentially
Yes, I can't figure out how to handle a sequence of commands. I'm able to send the first one and read it's response data, but how can I send a second command and read it's response?
Hi @edmont! Had any success sending a second command? I'm managing to create a simple protocol, to send a big message from one device to another. The idea is to divide the message. In this case the slave must sent some info to signal that the first message was received allowing the master to send the second part.
@arthurmoises, I managed to make it work with await
, but I finally moved to Python :)
I use seq-queue for this