1. Home
  2. Docs
  3. NMEA Parser
  4. Quickstart
  5. Parsing NMEA messages using the NMEA parser (the simple way)

Parsing NMEA messages using the NMEA parser (the simple way)

Parsing NMEA sentences using the NMEA Parser is really easy. We just have to follow these steps:

  • Contruct an NMEA sentence parser
  • Call the Parse function with the raw text sentence as a parameter
  • Get the return value: it is an INmeaSentence
  • Cast it to GgaSentence
  • Read the value of any property

This works but it requires us to know what kind of sentence we are expecting. We could use a switch on the sentence ID but it wouldn’t be really convenient. So to overcome this we can use the listeners.

We may also note that if the sentence is not correctly formatted (for instance, a bad number of fields, a wrong ID, etc.), the result will be an empty sentence object, i.e. a sentence object with only default values.

Was this article helpful to you? Yes No

How can we help?