Here we go again. I am stucked with the same problem again and again.
I am having the same problem again, that is:
- Sending data from arduino to a pc
- Decode the binary structures with construct
CCSDS defines that:
- Bit 0 is the FIRST bit transmitted = MSB.
My conclusions are:
- Sending structs without control it is not useful because is difficult to maintain. It is better to create the buffers like 20230518 - C Binary Data structures
- With little endian systems is difficult to describe bit structs that are sent over systems
- Microcontrollers are sending the data in little endian. So in systems with big endian, and bitstructs is necessary to do a swap. This is the change that is necessary in Python:
d = ByteSwapped(BitStruct(
"TYPE" / BitsInteger(1),
"APID" / BitsInteger(6),
"SECH" / BitsInteger(1),
"LENGTH" / BitsInteger(8)
))
d.parse(b"\x03\x05")