diff options
author | Gary E. Miller <gem@rellim.com> | 2013-11-29 14:50:29 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2013-11-29 14:50:29 -0800 |
commit | 312d3d941af0d8fb9e898be5548539bb2ced1faa (patch) | |
tree | d86f7304d18c84f26a728f1507270861f04c83d4 /ppsthread.c | |
parent | 6dacd04350a3bb7fb30a3bae5668fca0b4ab224b (diff) | |
download | gpsd-312d3d941af0d8fb9e898be5548539bb2ced1faa.tar.gz |
Improve separation of KPPS and PPS in ppsthread.c
Diffstat (limited to 'ppsthread.c')
-rw-r--r-- | ppsthread.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/ppsthread.c b/ppsthread.c index cb75b5cf..6073459d 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -281,6 +281,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) char *log = NULL; #if defined(TIOCMIWAIT) + /* we are lucky to have TIOMCIWAIT, so wait for next edge */ #define PPS_LINE_TIOC (TIOCM_CD|TIOCM_CAR|TIOCM_RI|TIOCM_CTS) if (ioctl(session->gpsdata.gps_fd, TIOCMIWAIT, PPS_LINE_TIOC) != 0) { gpsd_report(session->context->debug, LOG_ERROR, @@ -288,9 +289,9 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) errno, strerror(errno)); break; } -#endif /* TIOCMIWAIT */ /*@-noeffect@*/ + /* get the time after we just woke up */ #ifdef HAVE_CLOCK_GETTIME /* using clock_gettime() here, that is nSec, * not uSec like gettimeofday */ @@ -311,6 +312,20 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* HAVE_CLOCK_GETTIME */ /*@+noeffect@*/ + /* got the edge, got the time just after the edge, now quickly + * get the edge state */ + /*@ +ignoresigns */ + if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &state) != 0) { + gpsd_report(session->context->debug, LOG_ERROR, + "PPS ioctl(TIOCMGET) failed\n"); + break; + } + /*@ -ignoresigns */ + + /* mask for monitored lines */ + state = (int)(state & PPS_LINE_TIOC); +#endif /* TIOCMIWAIT */ + /* ok and log used by KPPS and TIOMCWAIT */ ok = false; log = NULL; @@ -397,16 +412,6 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* defined(HAVE_SYS_TIMEPPS_H) && !defined(S_SPLINT_S) */ #if defined(TIOCMIWAIT) - - /*@ +ignoresigns */ - if (ioctl(session->gpsdata.gps_fd, TIOCMGET, &state) != 0) { - gpsd_report(session->context->debug, LOG_ERROR, - "PPS ioctl(TIOCMGET) failed\n"); - break; - } - /*@ -ignoresigns */ - - state = (int)((state & PPS_LINE_TIOC) != 0); /*@ +boolint @*/ cycle = timespec_diff_ns(clock_ts, pulse[state]) / 1000; duration = timespec_diff_ns(clock_ts, pulse[(int)(state == 0)])/1000; |