Interpret incoming telemetry strings into useful telemetry data.


Parser(config) habitat’s parser
ParserModule(parser) Base class for real ParserModules to inherit from.
class habitat.parser.Parser(config)[source]

habitat’s parser

Parser takes arbitrary unparsed payload telemetry and attempts to use each loaded ParserModule to turn this telemetry into useful data.

On construction, it will:

  • Use config[daemon_name] as self.config (defaults to ‘parser’).
  • Load modules from self.config["modules"].
  • Connects to CouchDB using self.config["couch_uri"] and config["couch_db"].
parse(doc, initial_config=None)[source]

Attempts to parse telemetry information out of a new telemetry document doc.

This function attempts to determine which of the loaded parser modules should be used to parse the message, and which payload_configuration document it should be given to do so (if initial_config is specified, no attempt will be made to find any other configuration document).

The resulting parsed document is returned, or None is returned if no data could be parsed.

Some field names in data[“data”] are reserved, as indicated by a leading underscore.

These fields may include:

  • _protocol which gives the parser module name that was used to decode this message

From the UKHAS parser module in particular:

  • _sentence gives the ASCII sentence from the UKHAS parser

Parser modules should be wary when outputting field names with leading underscores.

class habitat.parser.ParserModule(parser)[source]

Base class for real ParserModules to inherit from.

ParserModules are classes which turn radio strings into useful data. They do not have to inherit from ParserModule, but can if they want. They must implement pre_parse() and parse() as described below.


Go though string and attempt to extract a callsign, returning it as a string. If string is not parseable by this module, raise CantParse. If string might be parseable but no callsign could be extracted, raise CantExtractCallsign.

parse(string, config)[source]

Go through string which has been identified as the format this parser module should be able to parse, extracting the data as per the information in config, which is the sentence dictionary extracted from the payload’s configuration document.