Ultimate GPS Logger Shield Coding Questions

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by tdicola »

flybob wrote:Noticed one more small bug, The GPRMC data uses the $GPRMC sentence identifier but the parser leaves the "$" off the GPGGA sentence identifier. This causes the file to crash when processed by GPS Babel. Manually adding the "$" via notepad makes the output process correctly.
Oh interesting--I noticed the same thing but wasn't sure if the code originally did that. Will take a look this afternoon to see why the $ gets cut off.

edit: Also I used this to compute checksums and it makes it a little easier for one-off or fixed strings: http://www.hhhh.org/wiml/proj/nmeaxor.html

User avatar
flybob
 
Posts: 26
Joined: Fri Dec 27, 2013 12:16 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by flybob »

Thanks for check sum info.
I have the 10sec update mod working via change to Adafruit_GPS header and shield_sdlog. Happy to share, how do you want it transferred to you. Next project parse date of first good fix and use to tag log file date.

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by tdicola »

Awesome, feel free to submit a pull request to the library on github. You'll want to fork the GPS library to your own account, make the changes, and then use Github's UI to send a pull request. Check out this for a little more info: https://help.github.com/articles/fork-a-repo

I've been looking more at the shield sd log example today and I keep running into pretty bad race conditions with trying to read serial data and write to the SD card. It seems like my SD card is just too slow to keep up with the incoming GPS data, at least using the sketch right now. Just something to be careful of that the sketch is very sensitive to the speed at which you can write data to the SD card.

User avatar
flybob
 
Posts: 26
Joined: Fri Dec 27, 2013 12:16 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by flybob »

Done Should be there.

akrange
 
Posts: 5
Joined: Mon Sep 27, 2010 1:15 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by akrange »

Sorry for not replying sooner but I have been putting GPS tracking collars on cattle and have also been testing the fixed logging script. While the fix works much better (thanks for all the hard work) it is still not perfect. I have done static tests on the GPS logging shield (two different times on each of three days) I have still have occasional times where the RMC sentence is being recorded without a corresponding GGA sentence. The periods where no GGA sentences are logged last anywhere from 23 seconds to 75 seconds before the unit goes back to recording both GGA and RMC sentences. I have been running the units for two hours at a time and have three or four periods during each of these six static tests where the unit fails to log the GGA sentences. I have attached a couple of screen captures showing the problem. In the second screen capture the unit recorded only RMC sentences for 75 seconds then recorded both RMC and GGA sentences for 4 seconds before recording only RMC sentences for another 43 seconds. The only change I made in the script was to turn off GPSECHO and turned on FIXONLY logging as suggested by Adafruit2. Hopefully this helps in your programming. Thanks.
Attachments
Second screen capture
Second screen capture
Snap2.jpg (372.74 KiB) Viewed 299 times
First screen capture
First screen capture
Snap1.jpg (387.47 KiB) Viewed 299 times

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Ultimate GPS Logger Shield Coding Questions

Post by tdicola »

Yeah there's still an annoying race condition in the logic where the interrupt routine that reads serial data from the GPS module is trying to signal a new line available to parse, while at the same time the main loop is clearing that signal that a new line is ready to parse. The problem can occur when the GGA and RMC lines come in at just the right time so the main loop misses one of them. I have a feeling as the timing between the CPU and GPS module drifts around it can briefly get into that state and one of the messages is missed for a period.

One thing you might try is disabling the interrupt routine by changing this line in the setup:

Code: Select all

useInterrupt(true);
To this:

Code: Select all

useInterrupt(false);
Make sure the debug logging is turned off too because without the interrupt processing serial data the main loop needs to be as fast as possible to keep up with the data. To turn off debug logging change this define at the top:

Code: Select all

#define GPSECHO  true
Is defined as false:

Code: Select all

#define GPSECHO  false
You might even want to go into the loop function and comment out any Serial.print statement too just to save some cycles.

Ultimately the race condition is tricky to resolve because AVR chips and libraries aren't really made to handle concurrency--i.e. there aren't any lock, semaphore, or other structures you can use to easily serialize access to important bits of memory like the new line is ready to parse flag. A more drastic option might be to greatly simplify the script so it just reads as much data as it can from the GPS serial connection and immediately dumps that to the SD card. I.e. pull out any use of the GPS library to parse the GPS statements and check if there's a fix, etc. This would be the fastest way to handle getting data from the GPS module to the SD card and wouldn't have any race conditions, but wouldn't have any nice logic like only recording good location fixed GPS lines. Unfortunately it's a bit of a trade off in what your needs are for the sketch.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”