From: Juergen Perlinger Date: Fri, 24 Apr 2015 19:20:38 +0000 (+0200) Subject: [Bug 2808] GPSD_JSON driver enhancements, step 1. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ed7a8076bccf8e0b4e7f2f93ac94beedd18f2d3;p=thirdparty%2Fntp.git [Bug 2808] GPSD_JSON driver enhancements, step 1. Add a few more tallies as per Hal Murray's suggestions bk: 553a9786ZAGc9SwpxAQw5XSFbjZaHQ --- diff --git a/ChangeLog b/ChangeLog index 39d5c23af..63a13b38f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --- +* [Bug 2808] GPSD_JSON driver enhancements, step 1. + Add a few more tallies as per Hal Murray's suggestions * [Bug 2794] Clean up kernel clock status reports. * [Bug 2800] refclock_true.c true_debug() can't open debug log because of incompatible open/fdopen parameters. diff --git a/html/drivers/driver46.html b/html/drivers/driver46.html index f52412f5d..957306063 100644 --- a/html/drivers/driver46.html +++ b/html/drivers/driver46.html @@ -238,24 +238,62 @@

Clockstats

If flag4 is set when the driver is polled, a clockstats record is written for the primary clock unit. (The secondary PPS unit - does not provide clock stats yet.) The first 3 fields are the - normal date, time, and IP address common to all clockstats + does not provide clock stats on its own.) The first 3 fields are + the normal date, time, and IP address common to all clockstats records.

- The 4th field is the number of good time samples processed - since the last poll. -

- The 5th field is the number of bad replies since the last - poll. A bad reply is considered malformed when it is missing - vital fields or the fields contain malformed data. If the data - indicates that the GPS receiver has no valid fix the sample is - also accounted as bad. -

- The 6th field is the number of received and known JSON records - since the last poll. (Note: Since the sample data is - collected from several JSON records and some JSON data is not - related to samples, this is not the sum of the other - fields. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
The Clockstats Line
fieldDescription
1Date as day number since NTP epoch.
2Time as seconds since midnight.
3(Pseudo-) IP address of clock unit.
4Number of received known JSON records since last + poll. The driver knows about TPV, PPS, TOFF, VERSION and + WATCH records; others are silently ignored. +
5Bad replies since last poll. A record is considered + malformed or a bad reply when it is missing vital fields + or the fields contain malformed data that cannot be + parsed. +
6Number of sample cycles since last poll that were + discarded because there was no GPS fix. This is + effectively the number of TPV records with a fix value + < 2 or without a time stamp. +
7Number of serial time information records (TPV or TOFF, + depending on the GPSD version) received since last poll. +
8Number of serial time information records used for + clock samples since the last poll. +
9Number of PPS records received since the last poll.
10Number of PPS records used for clock samples on the + secondary channel since the last poll. +

diff --git a/ntpd/refclock_gpsdjson.c b/ntpd/refclock_gpsdjson.c index 8cf43996e..89445223a 100644 --- a/ntpd/refclock_gpsdjson.c +++ b/ntpd/refclock_gpsdjson.c @@ -311,9 +311,13 @@ struct gpsd_unit { u_int tickpres; /* timeout preset */ /* tallies for the various events */ - u_int tc_good; /* good samples received */ - u_int tc_breply; /* bad replies */ u_int tc_recv; /* received known records */ + u_int tc_breply; /* bad replies / parsing errors */ + u_int tc_nosync; /* TPV / sample cycles w/o fix */ + u_int tc_sti_recv;/* received serial time info records */ + u_int tc_sti_used;/* used --^-- */ + u_int tc_pps_recv;/* received PPS timing info records */ + u_int tc_pps_used;/* used --^-- */ /* log bloat throttle */ u_int logthrottle;/* seconds to next log slot */ @@ -651,13 +655,20 @@ poll_primary( if (pp->sloppyclockflag & CLK_FLAG4) mprintf_clock_stats( - &peer->srcadr,"%u %u %u", - up->tc_good, up->tc_breply, up->tc_recv); + &peer->srcadr,"%u %u %u %u %u %u %u", + up->tc_recv, + up->tc_breply, up->tc_nosync, + up->tc_sti_recv, up->tc_sti_used, + up->tc_pps_recv, up->tc_pps_used); /* clear tallies for next round */ - up->tc_good = 0; - up->tc_breply = 0; - up->tc_recv = 0; + up->tc_breply = 0; + up->tc_recv = 0; + up->tc_nosync = 0; + up->tc_sti_recv = 0; + up->tc_sti_used = 0; + up->tc_pps_recv = 0; + up->tc_pps_used = 0; } static void @@ -883,10 +894,11 @@ eval_strict( /* use TPV reference time + PPS receive time */ add_clock_sample(peer, pp, up->sti_stamp, up->pps_recvt); peer->precision = up->pps_prec; - up->tc_good += 1; + //DEAD? up->tc_good += 1; /* both packets consumed now... */ up->fl_pps = 0; up->fl_sti = 0; + ++up->tc_sti_used; } } @@ -913,6 +925,7 @@ eval_pps_secondary( peer->flags |= FLAG_PPS; /* mark time stamp as burned... */ up->fl_pps2 = 0; + ++up->tc_pps_used; } } @@ -927,9 +940,10 @@ eval_serial( if (up->fl_sti) { add_clock_sample(peer, pp, up->sti_stamp, up->sti_recvt); peer->precision = up->sti_prec; - up->tc_good += 1; + //DEAD? up->tc_good += 1; /* mark time stamp as burned... */ up->fl_sti = 0; + ++up->tc_sti_used; } } @@ -1457,10 +1471,12 @@ process_tpv( /* accept time stamps only in 2d or 3d fix */ if (gps_mode < 2 || NULL == gps_time) { /* receiver has no fix; tell about and avoid stale data */ - up->tc_breply += 1; - up->fl_sti = 0; - up->fl_pps = 0; - up->fl_nosync = -1; + if ( ! up->pf_toff) + ++up->tc_sti_recv; + ++up->tc_nosync; + up->fl_sti = 0; + up->fl_pps = 0; + up->fl_nosync = -1; return; } up->fl_nosync = 0; @@ -1469,6 +1485,7 @@ process_tpv( * TOFF sentence is *not* available */ if ( ! up->pf_toff) { + ++up->tc_sti_recv; /* save last time code to clock data */ save_ltc(pp, gps_time); /* now parse the time string */ @@ -1489,8 +1506,8 @@ process_tpv( L_SUB(&up->sti_recvt, &up->sti_fudge); up->fl_sti = -1; } else { - up->tc_breply += 1; - up->fl_sti = 0; + ++up->tc_breply; + up->fl_sti = 0; } } @@ -1523,6 +1540,8 @@ process_pps( int xlog2; + ++up->tc_pps_recv; + /* Bail out if there's indication that time sync is bad or * if we're explicitely requested to ignore PPS data. */ @@ -1586,7 +1605,7 @@ process_pps( fail: DPRINTF(1, ("%s: PPS record processing FAILED\n", up->logname)); - up->tc_breply += 1; + ++up->tc_breply; } /* ------------------------------------------------------------------ */ @@ -1600,6 +1619,8 @@ process_toff( clockprocT * const pp = peer->procptr; gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr; + ++up->tc_sti_recv; + /* remember this! */ up->pf_toff = -1; @@ -1628,7 +1649,7 @@ process_toff( fail: DPRINTF(1, ("%s: TOFF record processing FAILED\n", up->logname)); - up->tc_breply += 1; + ++up->tc_breply; } /* ------------------------------------------------------------------ */ @@ -1670,7 +1691,7 @@ gpsd_parse( process_watch(peer, &up->json_parse, rtime); else return; /* nothing we know about... */ - up->tc_recv += 1; + ++up->tc_recv; /* if possible, feed the PPS side channel */ if (up->pps_peer)