]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2808] GPSD_JSON driver enhancements, step 1.
authorJuergen Perlinger <perlinger@ntp.org>
Fri, 24 Apr 2015 19:20:38 +0000 (21:20 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Fri, 24 Apr 2015 19:20:38 +0000 (21:20 +0200)
 Add a few more tallies as per Hal Murray's suggestions

bk: 553a9786ZAGc9SwpxAQw5XSFbjZaHQ

ChangeLog
html/drivers/driver46.html
ntpd/refclock_gpsdjson.c

index 39d5c23af9c1282177a7ba5f66acf6fc3d2a8154..63a13b38fa53912c9d8a86eecbf4ecedcf734b48 100644 (file)
--- 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.
index f52412f5d02adff2b2f0da484a1bcc9cf5bbcf9c..9573060634b3f4c450dd9551f9c25673229ceff4 100644 (file)
     <br><h4>Clockstats</h4>
     <p>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.
     </p><p>
-      The 4th field is the number of good time samples processed
-      since the last poll.
-    </p><p>
-      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.
-    </p><p>
-      The 6th field is the number of received and known JSON records
-      since the last poll. (<b>Note:</b> Since the sample data is
-      collected from several JSON records and some JSON data is not
-      related to samples, this is <i>not</i> the sum of the other
-      fields.
+      <table border="1" frame="box" rules="all">
+       <th colspan="2">The Clockstats Line</th>
+       <tr> <td>field</td><td>Description</td> </tr>
+       <tr>
+         <td align="center">1</td>
+         <td>Date as day number since NTP epoch.</td>
+       </tr><tr>
+         <td align="center">2</td>
+         <td>Time as seconds since midnight.</td>
+       </tr><tr>
+         <td align="center">3</td>
+         <td>(Pseudo-) IP address of clock unit.</td>
+       </tr><tr>
+         <td align="center">4</td>
+         <td>Number of received known JSON records since last
+           poll. The driver knows about TPV, PPS, TOFF, VERSION and
+           WATCH records; others are silently ignored.
+         </td>
+       </tr><tr>
+         <td align="center">5</td>
+         <td>Bad 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.
+         </td>
+       </tr><tr>
+         <td align="center">6</td>
+         <td>Number 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
+           &lt; 2 or without a time stamp.
+         </td>
+       </tr><tr>
+         <td align="center">7</td>
+         <td>Number of serial time information records (TPV or TOFF,
+           depending on the GPSD version) received since last poll.
+         </td>
+       </tr><tr>
+         <td align="center">8</td>
+         <td>Number of serial time information records used for
+           clock samples since the last poll.
+         </td>
+       </tr><tr>
+         <td align="center">9</td>
+         <td>Number of PPS records received since the last poll.</td>
+       </tr><tr>
+         <td align="center">10</td>
+         <td>Number of PPS records used for clock samples on the
+           secondary channel since the last poll.
+         </td>
+       </tr>
+      </table>
     </p>
 
     <!-- --------------------------------------------------------- -->
index 8cf43996e6ff17d7819f7c99a7aecbf37c7d6689..89445223a0c2ad77beb33ddba82a60417197b364 100644 (file)
@@ -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)