minsp.pus module

The minsp.pus module provides PUS header related classes.

class minsp.pus.PUSHeader(version: int = 1, ack: int = 0, service_type: int = 1, service_subtype: int = 1, source_id: int = 0, has_time: bool = False, cuc_time: bytes = b'')

Bases: object

Represents a Packet Utilization Standard (PUS) secondary header as used in CCSDS space packets.

The PUS secondary header adds standardized metadata to a CCSDS space packet, including service type, service subtype, source ID, and an optional timestamp in CUC format.

Parameters:
  • version (int) – PUS version number (4 bits).

  • ack (int) – Acknowledgment flags, only for telecommands (4 bits).

  • service_type (int) – PUS service type (1 byte).

  • service_subtype (int) – PUS service subtype (1 byte).

  • source_id (int) – Identifier of the source application or subsystem (1 byte).

  • has_time (bool) – Sequence count, default is 0 (14 bits).

  • cuc_time – Optional CUC-formatted timestamp (7 bytes).

  • cuc_time – bytes.

ack: int = 0
as_bytes() bytes

Packs the PUS header as a byte stream.

Returns:

PUS header bytes.

Return type:

bytes

cuc_time: bytes = b''
classmethod from_bytes(data: bytes, has_time: bool = False) PUSHeader

Unpacks a byte stream into a PUSHeader instance.

Parameters:
  • data (bytes) – The byte stream.

  • has_time (bool) – Includes a CUC time in header.

Raises:
  • ValueError – Insufficient data for PUS header.

  • ValueError – Insufficient data for PUS header with CUC time.

Returns:

A new PUSHeader.

Return type:

PUSHeader

has_time: bool = False
service_subtype: int = 1
service_type: int = 1
source_id: int = 0
version: int = 1