summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-05-18 20:06:25 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-05-18 20:06:25 +0000
commit7e592c0891d1f852134800fbea4ade3c9ca749e0 (patch)
treecf22e9acd1486afc7999f26438620a63aa31edc1
parenta908c8fa3ff9935308bcff4d8ff16f3538c766d0 (diff)
downloadgpsd-7e592c0891d1f852134800fbea4ade3c9ca749e0.tar.gz
PPS code is now part of the main line.
-rw-r--r--INSTALL3
-rw-r--r--configure.ac6
-rw-r--r--gpsd.c9
-rw-r--r--gpsd.h1
-rw-r--r--gpsd.spec.in5
-rw-r--r--gpsd.xml13
-rw-r--r--libgpsd_core.c66
7 files changed, 62 insertions, 41 deletions
diff --git a/INSTALL b/INSTALL
index 4297c58c..0bf4871a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -79,3 +79,6 @@ line to the table. Directions are included on that page.
We can also use updates of the latest version number known to work with
hardware already supported.
+9. Note for small embedded systems and those without threading. It is
+possible to build gpsd without thread support if you configure with
+--disable-pps. You'll lose support for updating the clock from PPS pulses.
diff --git a/configure.ac b/configure.ac
index 6fdd70e9..5e7bc3a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,9 +213,9 @@ fi
dnl check for PPS time syncing support
AC_ARG_ENABLE(pps,
- AC_HELP_STRING([--enable-pps],
- [enable PPS time syncing support]),
- [ac_pps=$enableval], [ac_pps=no])
+ AC_HELP_STRING([--disable-pps],
+ [disable PPS time syncing support]),
+ [ac_pps=$enableval], [ac_pps=yes])
AC_MSG_CHECKING([for PPS time syncing support])
if test x"$ac_pps" = "xyes"; then
AC_MSG_RESULT([yes])
diff --git a/gpsd.c b/gpsd.c
index abbe576c..e6e76461 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -61,7 +61,14 @@
static fd_set all_fds;
static int debuglevel, in_background = 0;
static jmp_buf restartbuf;
-static struct gps_context_t context = {0, LEAP_SECONDS, NULL};
+static struct gps_context_t context = {0, LEAP_SECONDS,
+#ifdef NTPSHM_ENABLE
+ NULL,
+#ifdef PPS_ENABLE
+ NULL,
+#endif /* NTPSHM_ENABLE */
+#endif /* NTPSHM_ENABLE */
+};
static void onsig(int sig)
{
diff --git a/gpsd.h b/gpsd.h
index 34840c0b..4bbedff6 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -175,7 +175,6 @@ extern int gpsd_activate(struct gps_device_t *);
extern void gpsd_deactivate(struct gps_device_t *);
extern int gpsd_poll(struct gps_device_t *);
extern void gpsd_wrap(struct gps_device_t *);
-extern int gpsd_ppsmonitor(struct gps_device_t *);
/* caller should supply this */
void gpsd_report(int, const char *, ...);
diff --git a/gpsd.spec.in b/gpsd.spec.in
index e3c64b59..2da2d03c 100644
--- a/gpsd.spec.in
+++ b/gpsd.spec.in
@@ -121,12 +121,13 @@ cp gps.py "$RPM_BUILD_ROOT"%{_libdir}/python${PYVERSION}/site-packages
%{_libdir}/X11/app-defaults/xgpsspeed
%changelog
-* Tue May 17 2005 Eric S. Raymond <esr@snark.thyrsus.com> - @VERSION@-1
+* Web May 18 2005 Eric S. Raymond <esr@snark.thyrsus.com> - @VERSION@-1
- Various signedness and scaling fixes and an OpenBSD port patch for the
Zodiac driver. Command-line arguments to gpsd are now treated as a default
device list; -f is still supported but deprecated. sirfmon now tries not
changing the line speed first, so it syncs up much faster. Prevent a
- potential buffer overrun in the client library.
+ potential buffer overrun in the client library. PPS support is now
+ on by default. Lots of documentation improvements.
* Tue May 17 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 2.24-1
- Crazy-speed bug is finally fixed. Autobauding now starts with the
diff --git a/gpsd.xml b/gpsd.xml
index 088969ee..d39709e9 100644
--- a/gpsd.xml
+++ b/gpsd.xml
@@ -588,12 +588,21 @@ updates.</para>
<para>gpsd can provide reference clock information to
<application>ntpd</application>, to keep the system clock synchronized
-to the time provided by the GPS receiver.</para>
+to the time provided by the GPS receiver. Note that if you're going
+to use <application>gpsd</application> you probably want to run it
+<option>-n</option> mode so the clock will be updated ebven when no
+clients are active.</para>
<para>Note that deriving time from messages received from the GPS
receiver is not as accurate as you might expect. Messages are often
delayed in the receiver and on the link by several hundred
-milliseconds, and this delay is not constant.</para>
+milliseconds, and this delay is not constant. On Linux,
+<application>gpsd</application> includes support for interpreting the
+PPS pulses emitted at the start of every clock second on the
+carrier-detect lines of some serial GPSes; this pulse is used to
+update NTP at much higher precision. You can determine whethher
+your GPS emits this pulse by running at -D 5 and watching for
+carrier-detect state change messages in the logfile.</para>
<para>When <application>gpsd</application> receives a sentence with a
timestamp, it packages the received timestamp with current local time
diff --git a/libgpsd_core.c b/libgpsd_core.c
index e4b1b694..5c8521ed 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -86,12 +86,43 @@ void gpsd_deactivate(struct gps_device_t *session)
session->device_type->wrapup(session);
}
+#if defined(PPS_ENABLE) && defined(TIOCMIWAIT)
+static void *gpsd_ppsmonitor(void *arg)
+{
+ struct gps_device_t *session = (struct gps_device_t *)arg;
+ int high,plen,pa;
+ struct timeval tv;
+ struct timeval pulse[2] = {{0,0},{0,0}};
+
+ /* wait for status change on the device's carrier-detect line */
+ while (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, TIOCM_CAR) == 0) {
+ gettimeofday(&tv,NULL);
+ if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &high) != 0)
+ break;
+
+ high = (high & TIOCM_CAR) != 0;
+ gpsd_report(5, "carrier-detect on %s changed to %d\n",
+ session->gpsdata.gps_device, high);
+#define timediff(x, y) ((x.tv_sec-y.tv_sec)*1000000+x.tv_usec-y.tv_usec)
+ plen = timediff(tv, pulse[high]);
+ pa = timediff(tv, pulse[!high]);
+#undef timediff
+ if (plen > 999000 && plen < 1001000 && pa > 800000 && session->gpsdata.fix.mode > MODE_NO_FIX)
+ ntpshm_pps(session->context, &tv);
+
+ pulse[high] = tv;
+ }
+
+ return NULL;
+}
+#endif /* PPS_ENABLE */
+
int gpsd_activate(struct gps_device_t *session)
/* acquire a connection to the GPS device */
{
#if defined(PPS_ENABLE) && defined(TIOCMIWAIT)
pthread_t pt;
-#endif
+#endif /* PPS_ENABLE */
if (gpsd_open(session) < 0)
return -1;
@@ -121,8 +152,8 @@ int gpsd_activate(struct gps_device_t *session)
#endif /* BINARY_ENABLE */
#if defined(PPS_ENABLE) && defined(TIOCMIWAIT)
- pthread_create(&pt,NULL,gpsd_ppsmonitor,(void*)session);
-#endif
+ pthread_create(&pt,NULL,gpsd_ppsmonitor, (void *)session);
+#endif /* PPS_ENABLE */
return session->gpsdata.gps_fd;
}
@@ -464,32 +495,3 @@ void gpsd_binary_quality_dump(struct gps_device_t *session, char *bufp)
}
#endif /* BINARY_ENABLE */
-
-#if defined(PPS_ENABLE) && defined(TIOCMIWAIT)
-int gpsd_ppsmonitor(struct gps_device_t *session)
-{
- int high,plen,pa;
- struct timeval tv;
- struct timeval pulse[2] = {{0,0},{0,0}};
-
- /* wait for status change on the device's carrier-detect line */
- while (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, TIOCM_CAR) == 0) {
- gettimeofday(&tv,NULL);
- if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &high) != 0)
- break;
-
- high = (high & TIOCM_CAR) != 0;
- gpsd_report(5, "CD on %s changed to %d\n", session->device_name);
-#define timediff(x, y) ((x.tv_sec-y.tv_sec)*1000000+x.tv_usec-y.tv_usec)
- plen = timediff(tv, pulse[high]);
- pa = timediff(tv, pulse[!high])
-#undef timediff
- if (plen > 999000 && plen < 1001000 && pa > 800000 && session->gpsdata.fix.mode > MODE_NO_FIX)
- ntpshm_pps(session->context, &tv);
-
- pulse[high] = tv;
- }
-
- return 0;
-}
-#endif