C NMEA Parser
The GPS emits coordinate information in the form of NMEA sentences. In the previous post, I showed how to we could connect to GPS to get these strings and simply print them out to the console. But in order to really work with the GPS coordinates, the data stream needs to be processed and each NMEA sentence parsed for this.
The NMEA Sentence
Each NMEA sentence begins with the data type field and ends with checksum. For example:
$GPGGA,014923.000,3724.2341,N,12200.7448,W,2,09,0.9,12.4,M,-25.6,M,0.8,0000*75
$GPGGA is the location fix data, with the coordinates including: latitude, longitude and altitude. This is the most commonly used NMEA sentence which also includes accuracy information.
$GPGSV,3,1,11,02,79,076,38,12,75,326,29,25,37,314,40,04,32,047,36*72
$GPGSV,3,2,11,10,29,088,31,09,29,209,36,05,23,145,44,27,21,199,41*7A
$GPGSV,3,3,11,29,20,275,15,17,03,078,23,51,43,156,35*48
$GPGSV is the visible satellite data. The sentences include an id and information about the location of the satellite with respect to the GPS in degrees.
Source Code
Although the parser is not threaded at this time, here is a first cut of the source code, printing individual NMEA sentences.