CCSDSPy / ccsdspy

I/O interface and utilities for CCSDS binary spacecraft data in Python. Library used in flight missions at NASA, NOAA, and SWRI
https://ccsdspy.org
BSD 3-Clause "New" or "Revised" License
75 stars 18 forks source link

Improves handling of intermittently specified bit_offset #9

Closed 5tefan closed 5 years ago

5tefan commented 5 years ago

Previously, beginning of the packet was "floating" in the sense that the bit start position depended on how many bits total were specified. This reasonably allows the omission of fields (so that the definition does not fill the whole packet), but that the definition would span to the end of the packet. Implicitly, what was omitted would be assumed to be the header (or more).

We've run into the situation where the length of a packet might change at some point, but the change adds more fields to the end of the packet... while the existing structure of the packet remains the same.

Given the described, floating behavior of ccsdspy, the same packet definition would not work. One initial idea was to fix the start of the packet by specifying exactly the start of the packet... eg. first bit_offset = 0.

This caused problems when leaving the rest of the bit_offsets unspecified because, even though the first packet would be at the start, the remaining would misalign due to the counter variable not taking the fixed start into account.

This commit improves handling of intermingled packet definitions where some fields may have bit_offset specified and other may not (ie bit_offset = None).

ddasilva commented 5 years ago

Looks good to me. Let's fix that minor style issue and then I will merge.

ddasilva commented 5 years ago

Thanks!

5tefan commented 5 years ago

Would you update PyPI as well? :)

ddasilva commented 5 years ago

Done!