This module contains the parser for the UKHAS telemetry protocol format.
$$<payload>,<data>,<data>,...,<last data>*<checksum>
The typical minimum telemetry string is: $$<payload>,<message number>,<time>,<latitude>,<longitude>,<altitude>,<data>,...,<last data>*<checksum>
The number of custom data fields and their types are configurable.
Data fields are typically human readable (or at the least ASCII) readings of sensors or other system information. See the sensors module for more information on supported formats.
Checksums work on the message content between the $$ and the *, non-inclusive, and are given as hexadecimal (upper or lower case) after the * in the message.
Supported checksums are CRC16-CCITT with polynomial 0x1021 and start 0xFFFF, Fletcher-16 and an 8bit XOR over the characters. The corresponding values for configuration are ‘crc16-ccitt’, ‘fletcher-16’ and ‘xor’. For compatibility, a varient of Fletcher16 using modulus 256 is also provided, as ‘fletcher-16-256’. Don’t use it for new payloads. ‘none’ may also be specified as a checksum type if no checksum is used; in this case the message should not include a terminating *.
Typical configuration (part of a payload dictionary in a flight document):
"habitat": {
"radio": {
"frequency": 434.075,
"mode": "usb",
},
"telemetry": {
"modulation": "rtty",
"shift": 425,
"encoding": "ascii-8",
"baud": 50,
"parity": "none",
"stop": 1
},
"sentence": {
"protocol": "UKHAS",
"checksum": "crc16-ccitt",
"fields": [
{
"name": "message_count",
"type": "base.ascii_int"
}, {
"name": "time",
"type": "stdtelem.time"
}, {
"name": "latitude",
"type": "stdtelem.coordinate",
"format": "dd.dddd"
}, {
"name": "longitude",
"type": "stdtelem.coordinate",
"format": "dd.dddd"
}, {
"name": "altitude",
"type": "base.ascii_int"
}, {
"name": "speed",
"type": "base.ascii_float"
}, {
"name": "internal_temperature",
"type": "base.ascii_float"
}
]
}
}
The UKHAS Parser Module
Store the parser reference for later use.
Check if this message is parsable by this module.
If the message is pasable, pre_parse extracts the payload name and return it. Otherwise, a ValueError is raised.
Parse the message, extracting processed field data.
config is a dictionary containing the sentence dictionary from the payload’s configuration document.
Returns a dictionary of the parsed data, with field names as keys and the result as the value. Also inserts a “payload” field containing the payload name, a “_extra_data” field if more data was in the sentence but not in the configuration, so could not be parsed, and an _sentence field containing the ASCII sentence that data was parsed from.
ValueError is raised on invalid messages. Return a dict of name:data.