Netduino home hardware projects downloads community

Jump to content


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.
Photo

GPS Sentence Parser with GPS Stream Helper Class(Updated 8-26-2010)


  • Please log in to reply
15 replies to this topic

#1 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 15 August 2010 - 06:58 AM

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.

Attached Files

  • Attached File  GPS.zip   31.66KB   1062 downloads

Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!

#2 i182willsw

i182willsw

    Member

  • Members
  • PipPip
  • 12 posts

Posted 15 August 2010 - 08:11 AM

Thank this is great, I've been wanting to wire up my GPS and was hoping someone would parse out the information.

#3 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 15 August 2010 - 03:49 PM

Wow, this certainly picks up right where my post left off and very well written. Going to update my project with this and your scheduler. Thanks!

#4 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 16 August 2010 - 06:19 AM

Added GPGSA. Download is above.
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 August 2010 - 06:46 AM

Nice! Thanks, kingpin2k!

#6 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 17 August 2010 - 05:16 AM

I've uploaded a RC of the GPS Sentence parser.
Homer: [Meeting Aliens] Please don't eat me! I have a wife and kids. Eat them!

#7 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 18 August 2010 - 02:19 AM

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

#8 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 18 August 2010 - 05:51 AM

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!

#9 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 18 August 2010 - 02:31 PM

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.

#10 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 18 August 2010 - 03:32 PM

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!

#11 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 18 August 2010 - 05:21 PM

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.

#12 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 18 August 2010 - 09:06 PM

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.

#13 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 18 August 2010 - 10:07 PM

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.



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.

parser.ParseGPSString("$GPGSV,3,1,10,17,85,87,44,28,50,74,38,8,26,144,26,27,41,309,36*4F");
parser.ParseGPSString("$GPGSV,3,2,10,26,23,226,34,15,26,259,29,11,22,51,0,9,28,313,34*49");
parser.ParseGPSString("$GPGSV,3,3,10,4,17,167,33,135,39,188,30*75");

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!

#14 Patrick

Patrick

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationTampa

Posted 19 August 2010 - 03:17 AM

Ahhhh... I see. Thanks for the explanation!

#15 kingpin2k

kingpin2k

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationUSA

Posted 27 August 2010 - 02:27 AM

K yall, I finally got a GPS unit, so I actually got to connect it and see if the code actually works :P 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!

#16 i182willsw

i182willsw

    Member

  • Members
  • PipPip
  • 12 posts

Posted 27 August 2010 - 03:12 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.