CURocketEngineering / CURocketEngineering/Avionics
Switch start sequence away from using 3 zeros
- Dominant language
- C++
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the start sequence uses three 0x00 bytes followed by a single distinct byte of 0x33.
The 0x00 bytes can be generated for many reasons, not just MARTHA trying to do a start sequence, which can cause the ground station to start parsing packets incorrectly. It's not a very distinct signal for the ground station to pick out.
# Better Alternative
I propose that we should switch the start bytes from `0x00 0x00 0x00 0x33` to instead be the ASCII values for `CURE` which is:
`0x43 0x55 0x52 0x45`
It is far less likely to appear accidentally in the payload data.
# Best Alternative
You can use [COBS](https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing) to entirely eliminate the problem by reserving a specific byte as the "delimiter" and then whenever that byte shows up in the payload, you replace that byte with the offset to the next byte that also was that special byte.
Here is an example where the reserved delimiter is `0xEE`:
**Packet (not encoded)**
`-- AA BB EE 05 C3 12 EE 04 01 EE` <-- The `EE` at the end is the delimiter to separate from the next packet
The other `EE`s I put in the packet are to show examples where the payload contains the special delimiter, which would cause packet parsing issues if not handled.
**Packet encoded**
`03 AA BB 04 05 C3 12 03 04 01 EE`
The `03` at the start is the first offset to the first `EE` that appears in the payload.
Then, where the `EE` should be, is the offset to the next `EE`.
That continues until it hits the last EE.
The Wikipedia article linked above has more examples.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.