ecom.parser

Module Contents

Classes

Parser

A parser for messages.

TelemetryParser

A parser for telemetry messages.

TelecommandParser

A parser for telecommand messages.

Attributes

M

exception ecom.parser.ParserError(message: str, buffer: bytes)[source]

Bases: RuntimeError

An error occurred during parsing.

property buffer: bytes[source]
Returns:

The parser buffer at the time the error was generated.

ecom.parser.M[source]
class ecom.parser.Parser(database: ecom.database.CommunicationDatabase, headerType: str, messageTypes: List[ecom.message.MessageType], verifier: Optional[ecom.verification.MessageVerifier] = None, maxDynamicMemberSize: int = DEFAULT_MAX_DYNAMIC_MEMBER_SIZE)[source]

Bases: ecom.datatypes.CommunicationDatabaseAccessor, abc.ABC, Generic[M]

A parser for messages.

property numParsedBytes: int[source]
Returns:

The number of bytes of all successfully parsed messages.

property numInvalidBytes: int[source]
Returns:

The number of bytes that could not be parsed into a message.

DEFAULT_MAX_DYNAMIC_MEMBER_SIZE = 512[source]

The default maximum size of a dynamically sized member that the parser will allow during parsing.

parse(message: bytes, errorHandler: Optional[Callable[[ParserError], None]] = None, ignoredBytesHandler: Optional[Callable[[bytes, int], None]] = None) Iterator[M][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.parser.TelemetryParser(database: ecom.database.CommunicationDatabase, **kwargs)[source]

Bases: Parser[ecom.message.Telemetry]

A parser for telemetry messages.

class ecom.parser.TelecommandParser(database: ecom.database.CommunicationDatabase, **kwargs)[source]

Bases: Parser[ecom.message.Telecommand]

A parser for telecommand messages.