diff options
author | Gary E. Miller <gem@rellim.com> | 2015-03-31 00:34:16 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-03-31 00:39:59 -0700 |
commit | 58b97df6fec87d361599c19dc2a315a1e2433d43 (patch) | |
tree | 725917c976dfc555ff0d50af4b95ef2566fd5f37 /ppsthread.c | |
parent | a04c74524bd8fbd606ec9eb9c7792e053496ff4e (diff) | |
download | gpsd-58b97df6fec87d361599c19dc2a315a1e2433d43.tar.gz |
Separate invisible pulse detection from unchanged detection.
The old code broke invisible pulse on 5Hz and 0.5 Hz PPS.
Also did not catch many of the chattering modes.
Diffstat (limited to 'ppsthread.c')
-rw-r--r-- | ppsthread.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ppsthread.c b/ppsthread.c index 3e850795..ff2fe642 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -774,6 +774,15 @@ static void *gpsd_ppsmonitor(void *arg) char *log = NULL; char *edge_str = ""; + if (++unchanged == 10) { + /* last ten edges no good, stop spinning, just wait 10 seconds */ + unchanged = 0; + thread_context->log_hook(thread_context, THREAD_WARN, + "PPS:%s unchanged state, ppsmonitor sleeps 10\n", + thread_context->devicename); + (void)sleep(10); + } + /* Stage One; wait for the next edge */ #if defined(TIOCMIWAIT) if ( !not_a_tty && !pps_canwait ) { @@ -926,17 +935,9 @@ static void *gpsd_ppsmonitor(void *arg) /* some pulses may be so short that state never changes */ if (999000 < cycle && 1001000 > cycle) { duration = 0; - unchanged = 0; thread_context->log_hook(thread_context, THREAD_RAW, "PPS:%s %.10s pps-detect invisible pulse\n", thread_context->devicename, edge_str); - } else if (++unchanged == 10) { - /* not really unchanged, just out of bounds */ - unchanged = 1; - thread_context->log_hook(thread_context, THREAD_WARN, - "PPS:%s %.10s unchanged state, ppsmonitor sleeps 10\n", - thread_context->devicename, edge_str); - (void)sleep(10); } } else { thread_context->log_hook(thread_context, THREAD_RAW, @@ -1078,6 +1079,8 @@ static void *gpsd_ppsmonitor(void *arg) continue; } + /* we have valiidated a goood cycle, mark it */ + unchanged = 0; /* offset is the skew from expected to observed pulse time */ struct timespec offset; /* offset as a printable string */ |