summaryrefslogtreecommitdiff
path: root/libgpsd_core.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2006-09-28 23:11:26 +0000
committerGary E. Miller <gem@rellim.com>2006-09-28 23:11:26 +0000
commit3af802770d0be2efec6bf9b98ca1c8dd46191753 (patch)
tree4e1495ec8955eeb2f6d2cd531c69d1c714738029 /libgpsd_core.c
parenta2e36ce992ba788c03f5e07eecf9194eec1e6fb4 (diff)
downloadgpsd-3af802770d0be2efec6bf9b98ca1c8dd46191753.tar.gz
Patch to allow PPS on CTS instead of DCD.
Thanks to Dave C <gpsd@creativesilicon.com.au>.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r--libgpsd_core.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index a3cdf1d2..4de28083 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -106,16 +106,22 @@ static void *gpsd_ppsmonitor(void *arg)
int cycle,duration, state = 0, laststate = -1, unchanged = 0;
struct timeval tv;
struct timeval pulse[2] = {{0,0},{0,0}};
+ int pps_device = TIOCM_CAR;
+
+#if defined(PPS_ON_CTS)
+ pps_device = TIOCM_CTS;
+#endif
+
/* wait for status change on the device's carrier-detect line */
- while (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, TIOCM_CAR) == 0) {
+ while (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, pps_device) == 0) {
(void)gettimeofday(&tv,NULL);
/*@ +ignoresigns */
if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &state) != 0)
break;
/*@ -ignoresigns */
- state = (int)((state & TIOCM_CAR) != 0);
+ state = (int)((state & pps_device) != 0);
if (state == laststate) {
if (++unchanged == 10) {
@@ -123,8 +129,8 @@ static void *gpsd_ppsmonitor(void *arg)
break;
}
} else {
- gpsd_report(5, "carrier-detect on %s changed to %d\n",
- session->gpsdata.gps_device, state);
+ gpsd_report(5, "pps-detect (%s) on %s changed to %d\n",
+ ((pps_device==TIOCM_CAR) ? "DCD" : "CTS"),
laststate = state;
unchanged = 0;
}