3

In Android development (latest SDK) I am using the GpsStatus.NmeaListener to parse NMEA messages for time synchronization.

In the onNmeaReceived(long timestamp, String nmea) callback I parse the nmea string for GPRMC messages. I then calculate the offset between the system clock and the time parsed from the GPRMC message.

Now there is a delay between the moment in time the NMEA message was received in the Android Frame work and the handling of the callback. This would cause a variation in the actual offset that I am calculating.

My guess is that the timestamp that is send along the NMEA message is the system clock time of the moment that the NMEA message was received. If this is true, I can use this timestamp to compensate for the latency in the callback handling.

From my measurements, the timestamp time has a difference from the System clock time captured in the onNmeaReceived callback of approx 10 ~ 30 ms.
The difference/offset between the time between the timestamp and the time derived from the parsed GPRMC message is in the order of 7200092ms (2hours difference between GPS and system time).

Therefore I would say the timestamp is not the GPS-based time but the system clock time when the message was received.

I have searched the web for quite a bit but I can not seem to locate any information regarding this timestamp. Does anyone have a resource that tells us more about this timestamp? What exactly does this timestamp represent? At what moment in time is it recorded?

Kamminga
  • 51
  • 7
  • a) The timestamp should be the GPS-based time of reception as determined by the receiver, b) the delay/jitter between acquiring a single GPS fix and the time your App sees the NMEA data is unspecified and may well be in the range of hundreds of ms; so not really a good way for exact timestamping. – JimmyB Jul 17 '15 at 11:09
  • From my measurements, the `timestamp` time has a difference from the System clock time captured in the `onNmeaReceived` callback of approx 10 ~ 30 ms. Therefore I would say it is not the GPS-based time. The difference/offset between the time between the `timestamp` and the time derived from the parsed GPRMC message is in the order of 7200092ms (2hours difference between GPS and system time). – Kamminga Jul 17 '15 at 15:18
  • Oops, sorry. I had mistaken the `timestamp` you mentioned for the time(stamp) from the GPRMC message. However, the issue would still be the same: The point in time the message is received outside of the GPS receiver is subject to "random" delays and jitter even at the lowest layer of the software stack. GPS receivers for timing applications have a dedicated signal/interrupt line to enable synchronization to GPS time, which an Android device is unlikely to employ. So, my estimation remains that you cannot rely on the accuracy of the arrival time of GPS time messages to below maybe 100ms. – JimmyB Jul 20 '15 at 09:35
  • I see your point. This is why I am curious about the `timestamp` information. It looks like it should be taken at the moment of an interrupt from the GPS receiver, in order to make the NMEA information usefull. However I cannot find any information regarding the `timestamp`. Measuring the standard deviation of 200 offsets between the `timestamp` and the GPRMC-time over 10 devices, results in an average standard deviation of 6.95ms. Thus, the jitter is not that high... Would you have an idea of where to find more legit documentation regarding the `timestamp` ? – Kamminga Jul 20 '15 at 12:57
  • Only thing I could find for now is http://osxr.org/android/source/hardware/qcom/gps/loc_api/libloc_api/loc_eng.cpp#0991, where the timestamp really is what is returned by `gettimeofday()`. (`nmea_cb` is the callback of type [`gps_nmea_callback`](http://osxr.org/android/source/hardware/libhardware/include/hardware/gps.h#0344)). – JimmyB Jul 20 '15 at 13:29
  • Tanks! this helps, it states here that the timestamp is taken when the android framework processes events received from the location engine (GL engine). – Kamminga Jul 20 '15 at 16:43

1 Answers1

2

Thanks to Hanno Binder's comments I came to the following answer.

The NMEA callback is described in: Android Location Engine source code. Here it states that the timestamp in the onNmeaReceived(long timestamp, String nmea) callback is recorded when the android framework processes events received from the location engine (GL engine). For an overview of the Android GPS architecture see: greatanjum's overview of the GPS architecture on XDA.

The timestamp is recorded as as struct timeval (as specified in sys/time.h>) using the gettimeofday() method.

Measuring the standard deviation of 200 offsets between the timestamp and the GPRMC-time over ten Nexus 7 (2012) devices, results in an average standard deviation in the recorded offsets of 6.95ms.

Kamminga
  • 51
  • 7