|
|
|
This page is dedicated to presenting some of the things that I am playing around with or have found useful. NOTE: Downloads of the source code for items discussed on this page are not yet available. I should find time to post them after the Christmas holidays. NMEA Parser: I needed a good parser for the NMEA sentences from my GPS receiver. I wanted one that was both quick and expandable so I created NMEAParser which comes in both flavors, .PAS and .BAS. NMEAParser currently contains routines for parsing the sentences that come from my old Garmin 45 but as you will see, you can easily modify or add functions to handle any NMEA sentence, even those from other than GPSRs or any instrument that speaks NMEA. NMEAParser, as distributed, contains routines for tokenizing the following NMEA sentences: GPBOD, GPGGA, GPGLL, GPGSA, GPGSV, GPRMB, GPRMC, GPRTE, GPVTG, and GPWPL which are the one supported by my Garmin 45. As is common in my software, there is a data structure defined for each sentence, for example:
The parser will take the NMEA string and strip out all of the values and place them in a structure like these and return the structure to the caller. You have the data from the sentence ready for use in your program. The structures have two fields in common. The first is the Sentence type ($GPGGA) and the check sum. Using the structures and the example sentence above you should be able to work out how the sentence is constructed. The sentence is always a text string. The fields are always comma delimited save for the check sum field at the end (*42) which is delimited by the *. The actual check sum is a hexadecimal number (in this case 42). There is a null (empty) field in the example which is shown by the two commas with no interposed value. In order to parse out the values tokens from this string these conditions have to be addressed. The heart of NMEAParser is my StrTokenizer (Tokenizer in my VB software). This function allows you to specify both the comma and the asterisk as field delimiters. After the tokenizer is done its thing on a sentence, each token is examined and the proper conversion is made and the resultant value is placed in the data structure. If you examine the code that parses the $GPGGA sentence you can see how this is done. There is a prototype data structure that you can use to describe any NMEA sentence. This structure has the name YYYStruct. There is a prototype parse function as well called ParseYYYSentence. Use this to get started coding up a new parsing function. Just follow the methods in the standard functions using cut and paste (for the most part) to roll your own function(s). There are a couple of helper functions in the file. GetNMEAType:
ParseNMEAToSList:
LatLongToDouble:
TimeToDouble:
ConvToDouble:
ConvToInt:
This page was last updated on 12/11/2003 |