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

SWE packet decom example #1

Merged
merged 8 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions imap_processing/swe/decommutation_swe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from space_packet_parser import parser, xtcedef


def decom_packet(packet_file: str, xtce_packet_definition: str):
tech3371 marked this conversation as resolved.
Show resolved Hide resolved
tech3371 marked this conversation as resolved.
Show resolved Hide resolved
"""Unpack CCSDS data packet. In this function, we unpack and return data
as it is. Data modification will not be done at this step.

Parameters
----------
packet_file : str
Path to data packet path with filename
xtce_packet_definition : str
Path to XTCE file with filename

Returns
-------
List
List of all the unpacked data
"""
packet_definition = xtcedef.XtcePacketDefinition(xtce_packet_definition)
my_parser = parser.PacketParser(packet_definition)
packet_list = []

with packet_file.open(mode="rb") as binary_data:
packet_generator = my_parser.generator(binary_data)
for packet in packet_generator:
# Add packet to list
packet_list.append(packet)
return packet_list
tech3371 marked this conversation as resolved.
Show resolved Hide resolved
Loading