You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because not all of the NMEA sentences include the time:
if gps.update():
rtc.RTC().datetime = gps.datetime
can set the RTC to a timestamp read from a previous update() call.
This gets worse when you consider the date. Only RMC sentences have the date, so processing (for example) an GAA sentence and then doing rtc.RTC().datetime = gps.datetime just after midnight will wind the RTC back almost 24 hours. Arguably this would be a short term effect, as the next RMC sentence will fix the date, but I have run into situations where my GPS Featherwings get into a state where they are setup to return both RMC and GAA sentences, but GPS.update seem to only get/process GAA sentences for 1000s of calls.
Signaling the age of the datetime, could significantly complicate the interface, and I can imagine that being a bad trade-off. The best solution might be just to document the issue.
FWIW, the workaround I settled on for my code is to a) configure the GPS to only return RMC sentences, and (because the GPS does not seem to always obey the PMTK314 sentences) b) use this subclass:
class TimeSettingGPS(adafruit_gps.GPS):
def _update_timestamp_utc(self, time_utc, date=None):
adafruit_gps.GPS._update_timestamp_utc(self, time_utc, date)
if date is not None:
rtc.RTC().datetime = self.datetime
The text was updated successfully, but these errors were encountered:
Because not all of the NMEA sentences include the time:
can set the RTC to a timestamp read from a previous
update()
call.This gets worse when you consider the date. Only RMC sentences have the date, so processing (for example) an GAA sentence and then doing
rtc.RTC().datetime = gps.datetime
just after midnight will wind the RTC back almost 24 hours. Arguably this would be a short term effect, as the next RMC sentence will fix the date, but I have run into situations where my GPS Featherwings get into a state where they are setup to return both RMC and GAA sentences, butGPS.update
seem to only get/process GAA sentences for 1000s of calls.Signaling the age of the datetime, could significantly complicate the interface, and I can imagine that being a bad trade-off. The best solution might be just to document the issue.
FWIW, the workaround I settled on for my code is to a) configure the GPS to only return RMC sentences, and (because the GPS does not seem to always obey the PMTK314 sentences) b) use this subclass:
The text was updated successfully, but these errors were encountered: