ludocode / mpack

MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]
MIT License
521 stars 82 forks source link

How to know the end of message pack in serial communication? #108

Closed rqi14 closed 3 months ago

rqi14 commented 5 months ago

Hi. I'm writing code for serial communication between an esp32-s3 and a pc.

I encounter a situation where two consecutive message packs may be sent in a row. If the client checks the serial port, finds available data, and starts to read it, with the node api, how should I determine the end of a message pack?

Let's say, I have message pack A and B. If in the serial buffer I have A and half B, when I reads the data from the buffer in the PC, is there any way to determine which part belongs to A, and which part belongs to B (needs to wait more bytes from the serial buffer)?

rqi14 commented 3 months ago

It can be done by parsing and checking error message