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 | |
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>
-rw-r--r-- | gpsd.c | 9 | ||||
-rw-r--r-- | gpsd.xml | 9 |
2 files changed, 16 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; @@ -33,6 +33,7 @@ BSD terms apply: see the file COPYING in the distribution root for details. <arg choice='opt'>-n </arg> <arg choice='opt'>-N </arg> <arg choice='opt'>-h </arg> + <arg choice='opt'>-r </arg> <arg choice='opt'>-P <replaceable>pidfile</replaceable></arg> <arg choice='opt'>-D <replaceable>debuglevel</replaceable></arg> <arg choice='opt'>-V </arg> @@ -203,6 +204,14 @@ This switch is mainly useful for debugging.</para> <listitem><para>Display help message and terminate.</para></listitem> </varlistentry> <varlistentry> +<term>-r</term> +<listitem><para>Use GPS time even with no current fix. Some GPS's have +battery powered Real Time Clocks (RTC's) built in, makeing them a valid time +source even before a fix is acquired. This can be useful on a Raspberry Pi, +or other device that has no battery powered RTC, and thus has no valid +time at startup.</para></listitem> +</varlistentry> +<varlistentry> <term>-P</term> <listitem> <para>Specify the name and path to record the daemon's process ID.</para> |