summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2020-05-26 13:29:07 +0000
committerDaniel Golle2020-05-26 13:29:07 +0000
commit0c54380e3d8920100fcfd41f0a1fe9872eb37d0e (patch)
tree08c03d531034b912ada88afa6a618c2c3ac9d7e3
parentdb40e3a22599641be68c88ece287d3fbbacd8a45 (diff)
downloadugps-0c54380e3d8920100fcfd41f0a1fe9872eb37d0e.tar.gz
nmea: make sure date is valid
GPS time without date was previously used to set system date: Tue Oct 10 11:48:21 2000 user.info kernel: [ 108.786639] ugps: system time differs from GPS time by more than 5 seconds. Using 2000-10-10T10:48:21 UTC as the new time Tue Oct 10 11:49:27 2000 user.info kernel: [ 174.794699] ugps: system time differs from GPS time by more than 5 seconds. Using 2020-05-26T10:49:27 UTC as the new time Fix this by ignoring incomplete dates and wait for complete time information before adjusting system date/time. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--nmea.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/nmea.c b/nmea.c
index 61c57ab..8df7792 100644
--- a/nmea.c
+++ b/nmea.c
@@ -90,6 +90,10 @@ nmea_rmc_cb(void)
&tm.tm_mday, &tm.tm_mon, &tm.tm_year) != 3) {
ERROR("failed to parse date '%s'\n", nmea_params[9].str);
}
+ else if (tm.tm_year == 0) {
+ DEBUG(4, "waiting for valid date\n");
+ return;
+ }
else {
tm.tm_year += 100; /* year starts with 1900 */
tm.tm_mon -= 1; /* month starts with 0 */