1

I receive data from serial port, and data packet structure looks something like this:

[src] [size] [dest] [data] [xor checksum]

Sometime data packet is split in half, meaning I receive it partially. How do I find when data packet starts since there is no data packet delimiter?

jM2.me
  • 3,839
  • 12
  • 44
  • 58
  • 2
    You have to write a procedure to hunt for frame alignment. Here's a [Q & A](http://stackoverflow.com/questions/16177947/identification-of-packets-in-a-byte-stream/16180135#16180135) for a fixed-length frame. For your variable-length frame your task is made a bit more complicated because the first byte(s) of the frame is not a constant. You should optimize the hunt by doing sanity checks on the values of [size], [src] and [dest] of the frame under test. – sawdust Sep 25 '13 at 08:12

0 Answers0