+1 vote
by
Hello!
Two devices are communicating via the com port. Let it be an Arduino, because I test with them.
We need to somehow separate the packet from the packet, provided that the stream can be distorted. Of course, checksums, parity, etc.
But here is the question, how best to divide the "packets" (sequence of bytes)?
So far I put 3 zeros in a row. Ideally, I'm looking for some simple and fast byte encoding/decoding algorithm that avoids multiple (say, from 3 to 6) consecutive identical fixed values (i.e., I need to know in advance what to put as separator)
I thought of simply adding one to every third byte, but then the problem: if the distortion will be in it during transmission and it becomes 0.

3 Answers

0 votes
by
 
Best answer
Checksum (hash).

If there is distortion, the chance of not detecting it is one in a million (actually even less, although it depends on the bit depth).
0 votes
by
You're doing the right thing. In telegraphy and data transmission - this is the only way to synchronize the transmitter and receiver. Agree with yourself that 3 zeros in a row + 3 ones will be the sync pulse and then the data will go. If there is a failure, it means that there was a false sync pulse and you have to wait for the next one.
+1 vote
by
1) Manchester coding
2) CAN bus (service bits automatically track errors)
by
Alas, I don't have a transport level.
...