dronecan / pydronecan

python DroneCAN code generation, interface and utilities
MIT License
40 stars 42 forks source link

ID allocation in FD mode issues #38

Closed David-OConnor closed 1 year ago

David-OConnor commented 1 year ago

I am unable to determine the rule for creating a Dynamic ID allocation message in FD mode. In non-FD, it is straightforward as expected from the DSDL when applying Tail Call Optomization.

The first byte makes sense. The rest, which encode the hardware unique ID, do not.

Example unique ID as bytes:

[49, 4, 33, 5, 69, 21, 85, 96, 3, 36, 11, 13, 0, 0, 0, 0]

Example message as created by PyDroneCAN, and expected in parsing via Dronecan GUI:

[139, 129, 136, 33, 8, 42, 40, 170, 171, 0, 25, 32, 88, 104, 0, 0, 0, 0, 0, 192]

The first bit is correct. Of note, this is almost encoded by bit-shifting the original message to the right by 11 bits, but a few of the values are still incorrect. This is what that produces. (Note that this has 41 instead of 40, 168 instead of 171 etc, but most of the values are correct)

[139, 129, 136, 33, 8, 41, 40, 170, 168, 2, 27, 32, 89, 104]

What we expect from the spec and DSDL is a 5-bit shift, due to the length-field.

David-OConnor commented 1 year ago

Fixed; I think was using LSB instead of MSB.