Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add continuation packet support #115

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Release notes for the `space_packet_parser` library
### v5.1.0 (unreleased)
- BUGFIX: Fix kbps calculation in packet generator for showing progress.
- Add support for string and float encoded enumerated lookup parameters.
- Add properties to extract the CCSDS Header items from the ``RawPacketData`` object directly.
e.g. ``RawPacketData.apid``
- Add a ``create_ccsds_packet`` function that can create a CCSDS Packet
with the given header items and data. This is useful for creating
mock packets in testing and experimentation for creating debugging
streams as needed.
- Add a ``ccsds_packet_generator()`` function that iterates through raw
bytes and yields individual CCSDS packets.
- Add continuation packet support to the XTCE parsing and packet generation.
This adds logic to concatenate packet data fields together across successive
packets (if there was too much data to fit in a single CCSDS packet or it
was logically better to split by other teams).
- Add warnings if packets are out of sequence within a given apid.
- Add ability to remove secondary header bytes from subsequent packets.
``definition.packet_generator(data, combine_segmented_packets=True, secondary_header_bytes=4)``

### v5.0.1 (released)
- BUGFIX: Allow raw_value representation for enums with falsy raw values. Previously these defaulted to the enum label.
Expand Down
277 changes: 64 additions & 213 deletions space_packet_parser/definitions.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions space_packet_parser/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _calculate_size(self, packet: packets.CCSDSPacket) -> int:
"""
raise NotImplementedError()

def parse_value(self, packet: packets.CCSDSPacket, **kwargs) -> packets.ParameterDataTypes:
def parse_value(self, packet: packets.CCSDSPacket) -> packets.ParameterDataTypes:
"""Parse a value from packet data, possibly using previously parsed data items to inform parsing.

Parameters
Expand Down Expand Up @@ -334,7 +334,7 @@ def _get_raw_buffer(self, packet: packets.CCSDSPacket) -> bytes:
).to_bytes(buflen_bytes, "big")
return raw_string_buffer

def parse_value(self, packet: packets.CCSDSPacket, **kwargs) -> packets.StrParameter:
def parse_value(self, packet: packets.CCSDSPacket) -> packets.StrParameter:
"""Parse a string value from packet data, possibly using previously parsed data items to inform parsing.

Parameters
Expand Down Expand Up @@ -529,7 +529,7 @@ def _twos_complement(val: int, bit_width: int) -> int:

def parse_value(self,
packet: packets.CCSDSPacket,
**kwargs) -> Union[packets.FloatParameter, packets.IntParameter]:
) -> Union[packets.FloatParameter, packets.IntParameter]:
"""Parse a value from packet data, possibly using previously parsed data items to inform parsing.

Parameters
Expand Down Expand Up @@ -793,7 +793,7 @@ def _calculate_size(self, packet: packets.CCSDSPacket) -> int:
len_bits = self.linear_adjuster(len_bits)
return len_bits

def parse_value(self, packet: packets.CCSDSPacket, **kwargs) -> packets.BinaryParameter:
def parse_value(self, packet: packets.CCSDSPacket) -> packets.BinaryParameter:
"""Parse a value from packet data, possibly using previously parsed data items to inform parsing.

Parameters
Expand Down
14 changes: 14 additions & 0 deletions space_packet_parser/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ class CalibrationError(Exception):
class InvalidParameterTypeError(Exception):
"""Error raised when someone is using an invalid ParameterType element"""
pass


class UnrecognizedPacketTypeError(Exception):
"""Error raised when we can't figure out which kind of packet we are dealing with based on the header"""

def __init__(self, *args, partial_data: dict = None):
"""
Parameters
----------
partial_data : dict, Optional
Data parsed so far (for debugging at higher levels)
"""
super().__init__(*args)
self.partial_data = partial_data
Loading
Loading