This project demonstrate how to parser NMEA protocol.
- Include "nmeaparser.h" in your source file.
- Create a nmeaparser:
struct nmea_parser parser[1];
. - Init the
parser
withnmea_parser_init(parser);
. - Create your navigation report function:
void my_reporter(struct nav_data *navdata){...}
. - Setup
parser
's report funtion:parser->report_nav_status = my_reporter;
. - When read data from serialport or file, add thee data character by character to the parser with
nmea_parser_putchar(parser, c)
. - When navigation data is ready,
parser
will triggermy_reporter
function to report navigation status.
Module | Files | Description |
---|---|---|
nmea_reader |
nmeardr.h nmeardr.c |
Read NMEA data, contains one NMEA sentence. |
nmea_tokenizer |
nmeatknzr.h nmeatknzr.c |
Split NMEA sentence into token s. |
parser |
nmeaparser.h nmeaparser.c |
Parse nmea from token s. |
nav_data |
navdata.h navdata.c |
Navigation data. |
- Add NMEA data to
nmea_reader
by character. - If encounter '\n', using
nmea_tokenizer
splitnmea_reader
. - Parse
nmea_tokenizer
, and store results intnav_data
. - If encounter
GGA
sentence, printnav_data
.
Date and time are in UTC.
In degrees.
Positive for North, and negative for South.
In degrees.
Positive for East, and negative for West.
PRN
is the satellite's NO. in NMEA.
SVID
is the index in satellite's array.
SVID range | Constellation type |
---|---|
1-64 | GPS |
65-96 | GLONASS |
201-264 | Beidou |