summaryrefslogtreecommitdiff
path: root/libgpsd_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-06-19 16:47:35 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-06-19 16:47:35 +0000
commite39f39a63a649f8de6f06717302c37c493c8e4f0 (patch)
tree234f5deeb5131c4c6a9feb8e0292bb302e686ea5 /libgpsd_core.c
parent42ccfb24f6f0fedcdc4927ed320538404dfcab17 (diff)
downloadgpsd-e39f39a63a649f8de6f06717302c37c493c8e4f0.tar.gz
Avoid CPU cost for nonworking DCD change detection.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r--libgpsd_core.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 2a10c312..4b9dc5b8 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -111,7 +111,7 @@ void gpsd_deactivate(struct gps_device_t *session)
static void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
- int cycle,duration, state = 0;
+ int cycle,duration, state = 0, laststate = -1, unchanged = 0;
struct timeval tv;
struct timeval pulse[2] = {{0,0},{0,0}};
@@ -124,8 +124,18 @@ static void *gpsd_ppsmonitor(void *arg)
/*@ -ignoresigns */
state = (int)((state & TIOCM_CAR) != 0);
- gpsd_report(5, "carrier-detect on %s changed to %d\n",
- session->gpsdata.gps_device, state);
+
+ if (state == laststate) {
+ if (++unchanged == 10) {
+ gpsd_report(1, "TIOCMIWAIT returns unchanged state, ppsmonitor terminates\n");
+ break;
+ }
+ } else {
+ gpsd_report(5, "carrier-detect on %s changed to %d\n",
+ session->gpsdata.gps_device, state);
+ laststate = state;
+ unchanged = 0;
+ }
/*@ +boolint @*/
if (session->gpsdata.fix.mode > MODE_NO_FIX) {