Most GPS modules have a serial port, which makes them excellent to connect to a microcontroller or computer. It is common for the microcontroller to parse the NMEA data. Parsing is just removing the pieces of data from the NMEA sentence so the microcontroller can do something useful with the data.
NMEA is an acronym for the National Marine Electronics Association. Why do you need to parse NMEA data? Because, when you get NMEA output, you get something like this:
$GPGGA,181908.00,3404.7041778,N,07044.3966270,
W,4,13,1.00,495.144,M,29.200,M,0.10,0000*40
But you only need to get north latitude or west longitude. For this, you need a parse for the NMEA format.
The NemaTode parse is yet another lightweight generic NMEA parser. It also comes with a GPS data interface to handle the most popular GPS NMEA sentences.
This is all you need to use the GPS NMEA sentence data.
NMEAParser parser;
GPSService gps(parser);
// (optional) Called when a sentence is valid syntax
parser.onSentence += [](const NMEASentence& nmea){
cout << "Received $" << nmea.name << endl;
};
// (optional) Called when data is read/changed
gps.onUpdate += [](GPSService& gps){
// There are *tons* of GPSFix properties
if( gps.fix.locked() ){
cout << " # Position: " << gps.fix.latitude << ", " << gps.fix.longitude << endl;
} else {
cout << " # Searching..." << endl;
}
};
// Send in a log file or a byte stream
try {
parser.readLine("FILL WITH A NMEA MESSAGE");
} catch (NMEAParseError&) {
// Syntax error, skip
}
Features:
- NMEA Parsing of standard and custom sentences
- NMEA Generation of “standard” and custom sentences.
- GPS Fix class to manage and organize all the GPS-related data.
- Stream data directly from a hardware byte stream
- C++ 11 features