MODGPS read last string

21 Apr 2011

Hi,

I'm using the modgps library in my project, but I wanted to know if it is possible to read back the last nmea string the mbed received from the gps. If this is not implemented yet, what would be the best way to do this?

Thanks!

21 Apr 2011

The only real problem here is that internally strtok() is used to process the string sentence. strtok() converts it's tokens (commas in the case) to nulls. So once processed the string is effectively managled/destroyed. I'd have to alter the code (say to add copying the string). I could something that would allow you to make a copy of the string before it's processed.

MODGPS works basically on the assumption "you're not bothered about the underlying bits" (ie strings or serial ports). It just exports the data.

21 Apr 2011

I just made an alteration. You can now request that MODGPS make a copy of the raw sentence before it's processed. See example1.cpp.

You can use setRmc(), setGga(), setVtg() and setUkn() functions to pass a char pointer to MODGPS. This should point to a buffer, your application defines, that MODGPS will copy the data to. You buffer should be large enough to hold a NMEA sentence + null terminator.

[edit, note, you can tell when these buffers have been copied to by using the associated callbacks. When a call back is triggered you know it's corresponding buffer has already been filled with the most recent data.]

23 Apr 2011

Thank you very much! I will test this code as soon as possible.

05 Feb 2014

Anyone tried this with a Ublox GPS Module and got it to work?

Followed the examples, with my module connected to Pin 27. Got '0' in my while loop then the program crashes the mbed... :-(