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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29bcd65f3341df165af15448b0004e503ce0abe0bc467921cbc63ffdc622e14e
|
|
| MD5 |
af7c9e65bdc632351ec9445292fb62f1
|
|
| BLAKE2b-256 |
27c24aee54da94373e5a5ac1afabdeb59352e3cca06636285be25b300858782e
|
Provenance
The following attestation bundles were made for minsp-0.0.3.tar.gz:
Publisher:
python-release.yml on nunorc/minsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minsp-0.0.3.tar.gz -
Subject digest:
29bcd65f3341df165af15448b0004e503ce0abe0bc467921cbc63ffdc622e14e - Sigstore transparency entry: 206664903
- Sigstore integration time:
-
Permalink:
nunorc/minsp@0fb04eb8ecf0e298236d1095d3e3f98078d8392a -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/nunorc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@0fb04eb8ecf0e298236d1095d3e3f98078d8392a -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c545327577a2c17eb719b31180cf212dfe2f9f737b37a2d291e65f89e2f9abb8
|
|
| MD5 |
cb58d74885eeac95d3a09bc6217b15fa
|
|
| BLAKE2b-256 |
7e1e50ad65a47ada5a1956c5447f00c3406fd8570f0f62b90e697de3d2c9bec2
|
Provenance
The following attestation bundles were made for minsp-0.0.3-py3-none-any.whl:
Publisher:
python-release.yml on nunorc/minsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minsp-0.0.3-py3-none-any.whl -
Subject digest:
c545327577a2c17eb719b31180cf212dfe2f9f737b37a2d291e65f89e2f9abb8 - Sigstore transparency entry: 206664905
- Sigstore integration time:
-
Permalink:
nunorc/minsp@0fb04eb8ecf0e298236d1095d3e3f98078d8392a -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/nunorc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@0fb04eb8ecf0e298236d1095d3e3f98078d8392a -
Trigger Event:
push
-
Statement type: