Skip to content

Extending parser with proprietary sentences #36

@jtojnar

Description

@jtojnar

I need to interact with a proprietary GPS logger that sends sentences like:

$PMTK182,8,0001F800,FFFFFFFFFFFFFF…FFFFF*52

Now I could wrap the parse_sentence function and handle those proprietary functions in the wrapper but I would have to duplicate code like checksum verification.

Possible solutions:

  • Include the whole sentence as a struct field in ParseError::UnsupportedSentenceType so that wrapper can attempt to handle it after running parse_sentence.
  • Return Ok(ParsedMessage::Proprietary(String)) from parse_sentence instead of ParseError::UnsupportedSentenceType.
  • Factor out the verify_and_strip_checksum function and make it public.
  • Add NmeaParserFull<ProprietaryMessagesType> (NmeaParser would become NmeaParserFull<()>) and a method like NmeaParserFull::register_parser_for_prefix<H>(prefix: &str, handler: H) where H: Fn(&str) -> Option<ProprietaryMessagesType>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions