The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
GPS Sentence Parser with GPS Stream Helper Class(Updated 8-26-2010)
Currently it will parse GPRMC, GPGSA, GPGSV, GPGLL and GPGGA sentences. There are 6 events you can attach to. One for each sentence type, and one for all types. Currently you need to feed the sentence into the parser. All of my information came from http://www.gpsinform.../dale/nmea.htm. If something doesn't work please let me know. If you have the offending sentence that would be great also.
I finally bought a gps (ebay gps). I got a pre modded gps unit off ebay which was super easy. It was quite a bit cheaper than sparkfun, just a fyi
With the help of my brother we built a GPS Stream object that can be used to connect to the gps object and sit there and monitor the incoming data.
Hi kingpin2k,
I got around to adding your GPS to my project and it is quite a tidy set of code. I especially like that you already thought of exposing the CurrentSatelliteCount variable.
Haven't run across any issues yet although it does need some additional error handling when the GPS doesn't have satellites in view.
Patrick
Hah, I'm sure it needs a lot more error handling, and polishing for that matter. A few of the errors it throws are thrown on purpose. Post RC they will be disabled, but for testing purposes I like the errors tossed around.
By additional error handling when the GPS doesn't have satellites in view, are you saying when you aren't receiving any GPS sentences?
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!
Immediately when the GPS is turned on and satellites haven't been acquired, the GPS streams sentences that have a valid GPS id ($GPSGGA) and a valid checksum but contain something like so (note, that checksum is invalid):
$GPGGA,123519,,N,,E,,,,,M,,M,,*47
Then when you try to do the casting, such as the the string lat/lon into a number, etc we're getting lots of exceptions.
This is the reason I like the idea of exposing the CurrentSatelliteCount variable. It allows the user to check for satellites before parsing the sentence and show a "Acquiring satellites..." message.
I see what you're saying. Although you aren't actually "getting" those exceptions, you are just seeing them in the debugger. All of those exceptions were anticipated and actually are caught by the parser. I can add more checks, but it'd just be for aesthetic purposes in the debugger. The functionality won't change.
The gps sentence "$GPGGA,123519,,N,,E,,,,,M,,M,,*50" (50 would be the valid sentence checksum) will still parse and give you the results.
I will modify it for debug aesthetics along with the finalizing exception types that will be thrown for other errors.
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!
I see what you're saying. Although you aren't actually "getting" those exceptions, you are just seeing them in the debugger. All of those exceptions were anticipated and actually are caught by the parser.
Those exceptions are being handled but from I've seen they are not allowing the parser to complete and the output is never generated which makes it difficult to simply plug in your solution and, for example, print to an LCD directly from the event handlers.
I don't want to convolute this discussion, so I will give a clear example of what I'm referring to when I have access to my project this evening.
This seems like a valid string I get from my GPS:
$GPGSV,2,1,05,31,,,37,32,,,35,22,,,36,10,,,30*79
However, the parser never makes it to display the result.
However, the parser never makes it to display the result.
It is a valid string, but it's incomplete GSV standard can span across multiple sentences. The 2nd parameter (2) is the amount of sentences it spans across. The 3rd parameter (1) is which sentence it is. The parser won't fire the event until it's received all of the relevant data for a GPS sentence. These messages don't always show up one after another. AKA You could get GSV (sentence 1), RMC, RMC, GSV (sentence 2). The parser handles that.
That's why in the example I parsed 3 of those sentences and it only fired 1 event.
On top of that, GSV doesn't actually send the Latitude/Longitude in the message. It's meant to show data about the satellites that the unit might be able to find based on it's viewing mask and almanac data.
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!
K yall, I finally got a GPS unit, so I actually got to connect it and see if the code actually works I'm going to call this complete, if there are issues just lemme know. I set up a stream object which works quite well for the gps device, it can be simply modified to work with any analog stream type object. In fact I might modify it and set it up as a generic stream object.
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!
Hey it's working great. GPS is awesome, the possibilities are endless. Speaking of which, with everyones help we're catching up to the Arduino's code content, and it hardly took any time.