Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adafruit_gps.GPS gives no indication how current the value of the datetime property is #77

Open
jwfmcclain opened this issue Jan 4, 2022 · 0 comments

Comments

@jwfmcclain
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant