Telemetry Handling Package

CCSDS TM Listener Module

Contains the TmListener which can be used to listen to Telemetry in the background

class tmtccmd.tmtc.ccsds_tm_listener.CcsdsTmListener(tm_handler: CcsdsTmHandler)

Bases: object

Simple helper object which can be used for retrieving and routing CCSDS packets. It can be used to poll CCSDS packets from a provided tmtccmd.com_if.ComInterface and then route them using a provided CCSDS TM handler.

Initiate a TM listener.

Parameters:

tm_handler – If valid CCSDS packets are found, they are dispatched to the passed handler

operation(com_if: ComInterface) int

Core operation to route packet to the provided handler.

Parameters:

com_if

Raises:

PacketsTooSmallForCcsds – If any of the received packets are too small. The internal handler will still continue to process the remaining packet list retrieved from the COM interface.

Returns:

exception tmtccmd.tmtc.ccsds_tm_listener.PacketsTooSmallForCcsdsError(packets: list[bytes])

Bases: Exception

TM Common Module

class tmtccmd.tmtc.common.CcsdsTmHandler(generic_handler: GenericApidHandlerBase | None)

Bases: TmHandlerBase

Generic CCSDS handler class. The user can create an instance of this class to handle CCSDS packets by adding dedicated APID handlers or a generic handler for all APIDs with no dedicated handler

add_apid_handler(handler: SpecificApidHandlerBase)

Add a TM handler for a certain APID. The handler is a callback function which will be called if telemetry with that APID arrives.

Parameters:

handler – Handler class instance

Returns:

handle_packet(apid: int, packet: bytes) bool

Handle a packet with an APID. If a handler exists for the given APID, it is used to handle the packet. If not, a dedicated handler for unknown APIDs is called.

Parameters:
  • apid

  • packet

Returns:

True if the packet was passed to as dedicated APID handler, False otherwise

has_apid(apid: int) bool
user_hook(apid: int, packet: bytes)

Can be overriden to trace all packets received.

class tmtccmd.tmtc.common.DefaultApidHandler(user_args: Any)

Bases: GenericApidHandlerBase

handle_tm(apid: int, _packet: bytes, _user_args: Any)
class tmtccmd.tmtc.common.GenericApidHandlerBase(user_args: Any)

Bases: ABC

This class is similar to the SpecificApidHandlerBase but it is not specific for an APID and the found APID will be passed to the callback

abstract handle_tm(apid: int, _packet: bytes, _user_args: Any)
class tmtccmd.tmtc.common.SpecificApidHandlerBase(apid: int, user_args: Any)

Bases: ABC

Abstract base class for an CCSDS APID specific handler. The user can implement a TM handler by implementing this class and then adding it to the CcsdsTmHandler. If a CCSDS space packet with a specific APID is received, it will be routed to this handler using the handle_tm() callback function

abstract handle_tm(_packet: bytes, _user_args: Any)
class tmtccmd.tmtc.common.TmHandlerBase(tm_type: TmTypes)

Bases: object

get_type()
class tmtccmd.tmtc.common.TmTypes(value)

Bases: Enum

An enumeration.

CCSDS_SPACE_PACKETS = <class 'enum.auto'>
NONE = <class 'enum.auto'>

TM Base Module (deprecated)

class tmtccmd.tmtc.tm_base.PusTmBase(pus_tm: PusTm)

Bases: PusTmInterface

property apid: int
pack() bytearray
property service: int
property ssc: int
property subservice: int
property tm_data: bytes
class tmtccmd.tmtc.tm_base.PusTmInfoBase(pus_tm: PusTm)

Bases: PusTmInfoInterface

append_packet_info(info: str)
append_telemetry_column_headers(header_list: list)

Default implementation adds the PUS header content header (confusing, I know) to the list which can then be printed with a simple print() command. To add additional headers, override this method. Any child class should call this function as well if header information is required.

Parameters:

header_list – Header content will be appended to this list

Returns:

append_telemetry_content(content_list: list)

Default implementation adds the PUS header content to the list which can then be printed with a simple print() command. To add additional content, override this method. Any child class should call this function as well if header information is required.

Parameters:

content_list – Header content will be appended to this list

Returns:

get_custom_printout() str
get_print_info() str
get_source_data_string(print_format: PrintFormats = PrintFormats.HEX) str
set_custom_printout(custom_string: str)
set_packet_info(print_info: str)
class tmtccmd.tmtc.tm_base.PusTmInfoInterface

Bases: object

abstract append_packet_info(info: str)
abstract append_telemetry_column_headers(header_list: list)
abstract append_telemetry_content(content_list: list)
abstract get_custom_printout() str
abstract get_print_info() str
abstract get_source_data_string() str
abstract set_packet_info(print_info: str)
class tmtccmd.tmtc.tm_base.PusTmInterface

Bases: object

abstract property apid: int
abstract pack() bytearray
abstract property service: int
abstract property ssc: int
abstract property subservice: int
abstract property tm_data: bytes
abstract property valid: bool