Adafruit GPS library

In the example sketch, GPS_HardwareSerial_parsing,

A delay of 100ms inside the main loop stops the GPS data being received.

(I use this example of a delay to demonstrate the issue)

I assumed that the library would read in all GPS data and buffer just the most recent to be read?

It appears to need to read the GPS continously in order to receive anything?

If there is any other code that takes, say, 100ms to run, you can no longer read the GPS...

Is that right?

richardtheboffin:
It appears to need to read the GPS continously in order to receive anything?

Yes, pretty much.

richardtheboffin:
A delay of 100ms inside the main loop stops the GPS data being received.

100ms is a relatively long time in the microcontroller world - what other processing do you need to do (processing-wise) in your code?

A delay of 100ms inside the main loop stops the GPS data being received.

Nope, the GPS is still sending the data, and its being received. But on small microcontrollers with limited memory the serial buffer is small, so if you stop emptying it for 100mS you get NMEA senteces chopped in half.

I assumed that the library would read in all GPS data and buffer just the most recent to be read?

That would need a fairly large serial buffer since there can be a great number of sentences sent by the GPS that you would need to buffer, in order to be able to read the two that contain the actual location data.

It appears to need to read the GPS continously in order to receive anything?

Yep, and it not cause a problem really.

If I only want time, speed and heading, I can make a custom sententance, correct?

Then read it under interrupt and update these values so that I only read the most recent, as often as I need, which may only be once a second.

When testing, I found even a delay (simulating additional code) of 10ms is disrupting the gps readings.

richardtheboffin:
If I only want time, speed and heading, I can make a custom sententance, correct?

You can often turn off all standard messages and then poll the GPS for it to respond with the postition data when you want it.

srnet:
You can often turn off all standard messages and then poll the GPS for it to respond with the postition data when you want it.

That sounds a lot more sensible! Will read the Ublox datasheet and see how to do that. The Adafruit library seems a bit pointless...

So just to update this, I decided to go polled using the UBX commands as it's a Ublox GPS.

First set all the NMEA messages off.
Set baud rate up to max.

Poll PUBX 00 to get everything I need.

I used a non blocking routine to look for serial available and then read the UBX 00 response into a string.

At 115200 baud, it takes 9-10ms to get the GPS data in. With 1hz rate set, the GPS will only respond to the poll after the measurement cycle has completed, so if you poll, it may take up to 1 second to reply, hence the non blocking check for data.

Works great.

Well worked great until I added more code... Then found that the RX buffers are set to 64 bytes, so the GPS message at 108 chars blew it...

I changed the .h to 128 bytes. Not ideal. Shame there is no function to increase the buffer on a specific serial port, like the ESP32 version allows.

Have a look at NEOGPS. I think it will solve your problem.
It is very adaptable and lean.
It is very well documented on GitHub
I'm just a very happy user
Regards