diff options
author | Larry Boyd <lbdroidman@gmail.com> | 2017-06-30 16:21:51 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2017-06-30 16:21:51 -0700 |
commit | 3e3e09cfc9e07160b58a62f13137fe579f3f8623 (patch) | |
tree | 9e7e69bfef9c404bec31919032107ca4c58621d9 /gpsd.c | |
parent | 241b2f0cb08ac00ce6c2751d8aab75ad20681f38 (diff) | |
download | gpsd-3e3e09cfc9e07160b58a62f13137fe579f3f8623.tar.gz |
Add the -r option to gpsd.
-r allows gpsd to use the time from a GPS even if the GPS has no valid
fix. This is useful on devices like the Raspberry Pi that have not
battery backed RTC, but have a GPS with a battery backed RTC.
Signed-off-by: Gary E. Miller <gem@rellim.com>
Diffstat (limited to 'gpsd.c')
-rw-r--r-- | gpsd.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -158,6 +158,7 @@ static bool nowait = false; #else /* FORCE_NOWAIT */ #define NOWAIT true #endif /* FORCE_NOWAIT */ +static bool batteryRTC = false; static jmp_buf restartbuf; static struct gps_context_t context; #if defined(SYSTEMD_ENABLE) @@ -1548,8 +1549,9 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) */ if ((changed & TIME_SET) == 0) { //gpsd_log(&context.errout, LOG_PROG, "NTP: No time this packet\n"); - } else if ( NTP_MIN_FIXES > device->fixcnt ) { + } else if ( 0 >= device->fixcnt && !batteryRTC ) { /* many GPS spew random times until a valid GPS fix */ + /* allow override with -r optin */ //gpsd_log(&context.errout, LOG_PROG, "NTP: no fix\n"); } else if (isnan(device->newdata.time)) { //gpsd_log(&context.errout, LOG_PROG, "NTP: bad new time\n"); @@ -1872,7 +1874,7 @@ int main(int argc, char *argv[]) #endif /* PPS_ENABLE && SOCKET_EXPORT_ENABLE */ #endif /* CONTROL_SOCKET_ENABLE */ - while ((option = getopt(argc, argv, "F:D:S:bGhlNnP:V")) != -1) { + while ((option = getopt(argc, argv, "F:D:S:bGhlNnrP:V")) != -1) { switch (option) { case 'D': context.errout.debug = (int)strtol(optarg, 0, 0); @@ -1909,6 +1911,9 @@ int main(int argc, char *argv[]) nowait = true; #endif /* FORCE_NOWAIT */ break; + case 'r': + batteryRTC = true; + break; case 'P': pid_file = optarg; break; |