ecom.response

Module Contents

Classes

ResponseTelemetryParser

A parser and serializer for telemetry and telecommand messages.

ResponseTelemetrySerializer

A serializer that can serialize a response to a received telecommand.

FixedSizeResponseTelemetrySerializer

A serializer that supports sending responses in a datapoint that is a list of bytes with a constant size.

VariableSizedResponseTelemetrySerializer

A serializer that supports sending responses in a variable sized response package.

class ecom.response.ResponseTelemetryParser(*args, **kwargs)[source]

Bases: ecom.parser.TelemetryParser, ecom.serializer.TelecommandSerializer

A parser and serializer for telemetry and telecommand messages. It adds extra functionality for response and acknowledge messages:

  • Both gain a ‘command’ data point with the telecommand instance that initiated the response.

  • The ‘value’ data point of the response message is parsed into it’s Python representation.

serialize(telecommand: ecom.message.TelecommandType, **kwargs) bytes[source]

Serialize the telecommand and its data into bytes.

Parameters:
  • telecommand – The telecommand.

  • kwargs – Data for the telecommand.

Returns:

The serialized telecommand.

parse(message: bytes, errorHandler: Optional[Callable[[ecom.parser.ParserError], None]] = None, ignoredBytesHandler: Optional[Callable[[bytes, int], None]] = None) Iterator[ecom.message.Message][source]

Parse messages from the data. Multiple messages might be parsed from the data. If the data contains an incomplete message, it will be added to an internal buffer and parsed once the rest of the data is available.

Parameters:
  • message – The raw data to parse.

  • errorHandler – An optional error handler for handling parser errors.

  • ignoredBytesHandler – An optional handler for bytes that will get ignored during parsing. Takes the parser buffer and the number of bytes that will be ignored.

Returns:

An iterator over all parsed messages.

Raises:

ParserError – If the data contains a message with invalid data and no error handler is specified.

class ecom.response.ResponseTelemetrySerializer(*args, responseTelemetryName: str = 'RESPONSE', acknowledgeTelemetryName: str = 'ACKNOWLEDGE', responseValueDatapointName: str = 'value', **kwargs)[source]

Bases: ecom.serializer.TelemetrySerializer, abc.ABC

A serializer that can serialize a response to a received telecommand. This handles logic for responses whose content depend on a received telecommand message.

serializeTelecommandResponse(telecommand: ecom.message.Telecommand, value: Any, additionalData: Optional[Dict[str, Any]] = None) bytes[source]

Serialize a response for the given telecommand with the given value.

Parameters:
  • telecommand – The telecommand message that this response is responding to.

  • value – The response value to the telecommand.

  • additionalData – Optional additional data that is required by the response telemetry package.

Returns:

The serialized response.

serializeTelecommandAcknowledge(telecommand: ecom.message.Telecommand, additionalData: Optional[Dict[str, Any]] = None) bytes[source]

Serialize an acknowledgement for the given telecommand.

Parameters:
  • telecommand – The telecommand message that this response is acknowledging.

  • additionalData – Optional additional data that is required by the acknowledgement telemetry package.

Returns:

The serialized acknowledgement.

class ecom.response.FixedSizeResponseTelemetrySerializer(*args, maxResponseSize: Optional[int] = None, maxResponseSizeConstant: str = 'MAX_TELECOMMAND_RESPONSE_SIZE', **kwargs)[source]

Bases: ResponseTelemetrySerializer

A serializer that supports sending responses in a datapoint that is a list of bytes with a constant size.

class ecom.response.VariableSizedResponseTelemetrySerializer(*args, sizeDatapointName: str = 'size', **kwargs)[source]

Bases: ResponseTelemetrySerializer

A serializer that supports sending responses in a variable sized response package.