diff options
author | Gary E. Miller <gem@rellim.com> | 2011-01-27 17:26:55 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2011-01-27 17:26:55 -0800 |
commit | a28af18bea6567e86691da01582a95abaff5079e (patch) | |
tree | 2d4522952734c54345f8ab7c656fe767e4e98db7 /libgpsd_core.c | |
parent | 4164f46b8f8217567c7f5a82ea94eafc73c5b97e (diff) | |
download | gpsd-a28af18bea6567e86691da01582a95abaff5079e.tar.gz |
Fix a loss of precision in KPPS, By: Miroslav Lichvar
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r-- | libgpsd_core.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c index 75c0988b..3264883d 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -92,8 +92,6 @@ TS_NORM( ts ); \ } while (0) -/* convert timespec to double */ -#define TSTOD(ts) ((double)((ts)->tv_sec+((double)((ts)->tv_nsec)/1000000000))) #endif #if defined(ONCORE_ENABLE) && defined(BINARY_ENABLE) @@ -616,9 +614,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) } if (0 != ok) { /* chrony expects tv-sec since Jan 1970 */ - /* FIXME!! sample.tv is time of sample */ /* FIXME!! offset is double of the error from local time */ - sample.offset = 1 + session->last_fixtime; sample.pulse = 0; sample.leap = 0; sample.magic = SOCK_MAGIC; @@ -636,7 +632,10 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) { sample.tv = tv; /* structure copy */ } - sample.offset -= TSTOD( &ts ); + /* FIXME!! this is wrong if signal is 5Hz or 10Hz instead of PPS */ + /* carefull, unix time to nSec is more precision that a double */ + sample.offset = 1 + session->last_fixtime - ts.tv_sec; + sample.offset -= ts.tv_nsec / 1e9; #if defined(ONCORE_ENABLE) && defined(BINARY_ENABLE) /*@-noeffect@*/ if (session->device_type == &oncore_binary) { |