Skip to main content

minimalistic implementation of the Space Packet specification from the CCSDS Space Packet Protocol standard

Project description

minsp

Minimalistic implementation of the Space Packet specification from the CCSDS Space Packet Protocol standard.

Repository | Documentation

Installation

Install using pip:

$ pip install minsp

Install package from the git repository:

$ pip install git+https://github.com/nunorc/minsp@master

Getting Started

Import the SpacePacket class from the package:

>>> from minsp import SpacePacket

For example, to create a new space packet for APID 11 and an arbitrary data field:

>>> space_packet = SpacePacket(apid=11, data_field=b'hello')
>>> space_packet
SpacePacket(version=0, type=<PacketType.TM: 0>, secondary_header_flag=0, apid=11, sequence_flags=3, sequence_count=0, data_length=4, secondary_header=b'', data_field=b'hello')

To get the bytes representation of the packet:

>>> byte_stream = space_packet.as_bytes()
>>> byte_stream
b'\x00\x0b\xc0\x00\x00\x04hello'

Packets can also be created from a byte stream:

>>> new_packet = SpacePacket.from_bytes(byte_stream)
>>> new_packet
SpacePacket(version=0, type=0, secondary_header_flag=0, apid=11, sequence_flags=3, sequence_count=0, data_length=4, secondary_header=b'', data_field=b'hello')
>>> new_packet.data_field
b'hello'

Secondary header can have a custom data definition, or to use PUS:

>>> from minsp.pus import PUSHeader
>>> pus_header = PUSHeader()
>>> pus_header
PUSHeader(version=1, ack=0, service_type=1, service_subtype=1, source_id=0, has_time=False, cuc_time=b'')

And create a new packet with the PUS header:

>>> space_packet = SpacePacket(secondary_header=pus_header)
>>> space_packet
SpacePacket(version=0, type=<PacketType.TM: 0>, secondary_header_flag=1, apid=0, sequence_flags=3, sequence_count=0, data_length=3, secondary_header=PUSHeader(version=1, ack=0, service_type=1, service_subtype=1, source_id=0, has_time=False, cuc_time=b''), data_field=b'')

Similar approach for a MAL secondary header:

>>> from minsp.mo import MALHeader
>>> mal_header = MALHeader()
>>> mal_header
MALHeader(version=0, sdu_type=0, service_area=0, service=0, operation=0, area_version=0, is_error=0, qos_level=0, session=0, secondary_apid=0, secondary_apid_qualifier=0, transaction_id=0, source_id_flag=0, destination_id_flag=0, priority_flag=0, timestamp_flag=0, network_zone_flag=0, session_name_flag=0, domain_flag=0, authentication_id_flag=0, source_id=0, destination_id=0, segment_counter=0, priority=0, timestamp=None, network_zone='', session_name='', domain='', authentication_id='')

And to create a new packet with the MAL header:

>>> space_packet = SpacePacket(secondary_header=mal_header)
>>> space_packet
SpacePacket(version=0, type=<PacketType.TM: 0>, secondary_header_flag=1, apid=0, sequence_flags=3, sequence_count=0, data_length=20, secondary_header=MALHeader(version=0, sdu_type=0, service_area=0, service=0, operation=0, area_version=0, is_error=0, qos_level=0, session=0, secondary_apid=0, secondary_apid_qualifier=0, transaction_id=0, source_id_flag=0, destination_id_flag=0, priority_flag=0, timestamp_flag=0, network_zone_flag=0, session_name_flag=0, domain_flag=0, authentication_id_flag=0, source_id=0, destination_id=0, segment_counter=0, priority=0, timestamp=None, network_zone='', session_name='', domain='', authentication_id=''), data_field=b'')

To create a space packet from a byte stream including a PUS header:

>>> data = SpacePacket(secondary_header=pus_header).as_bytes()
>>> SpacePacket.from_bytes(data, pus=True)
SpacePacket(version=0, type=0, secondary_header_flag=1, apid=0, sequence_flags=3, sequence_count=0, data_length=3, secondary_header=PUSHeader(version=1, ack=0, service_type=1, service_subtype=1, source_id=0, has_time=False, cuc_time=b''), data_field=b'')

Or from a byte stream including a MAL header:

>>> data = SpacePacket(secondary_header=mal_header).as_bytes()
>>> SpacePacket.from_bytes(data, mal=True)
SpacePacket(version=0, type=0, secondary_header_flag=1, apid=0, sequence_flags=3, sequence_count=0, data_length=20, secondary_header=MALHeader(version=0, sdu_type=0, service_area=0, service=0, operation=0, area_version=0, is_error=0, qos_level=0, session=0, secondary_apid=0, secondary_apid_qualifier=0, transaction_id=0, source_id_flag=0, destination_id_flag=0, priority_flag=0, timestamp_flag=0, network_zone_flag=0, session_name_flag=0, domain_flag=0, authentication_id_flag=0, source_id=0, destination_id=0, segment_counter=0, priority=0, timestamp=None, network_zone='', session_name='', domain='', authentication_id=''), data_field=b'')

Acknowledgements

  • Dominik Marszk for general support and MAL header baseline implementation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minsp-0.0.3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minsp-0.0.3-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file minsp-0.0.3.tar.gz.

File metadata

  • Download URL: minsp-0.0.3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for minsp-0.0.3.tar.gz
Algorithm Hash digest
SHA256 29bcd65f3341df165af15448b0004e503ce0abe0bc467921cbc63ffdc622e14e
MD5 af7c9e65bdc632351ec9445292fb62f1
BLAKE2b-256 27c24aee54da94373e5a5ac1afabdeb59352e3cca06636285be25b300858782e

See more details on using hashes here.

Provenance

The following attestation bundles were made for minsp-0.0.3.tar.gz:

Publisher: python-release.yml on nunorc/minsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minsp-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: minsp-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for minsp-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c545327577a2c17eb719b31180cf212dfe2f9f737b37a2d291e65f89e2f9abb8
MD5 cb58d74885eeac95d3a09bc6217b15fa
BLAKE2b-256 7e1e50ad65a47ada5a1956c5447f00c3406fd8570f0f62b90e697de3d2c9bec2

See more details on using hashes here.

Provenance

The following attestation bundles were made for minsp-0.0.3-py3-none-any.whl:

Publisher: python-release.yml on nunorc/minsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page