]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception.
authorDave Hart <hart@ntp.org>
Mon, 20 Feb 2012 22:16:37 +0000 (22:16 +0000)
committerDave Hart <hart@ntp.org>
Mon, 20 Feb 2012 22:16:37 +0000 (22:16 +0000)
Increase detail in clockstats for NMEA driver (from Hal Murray).

bk: 4f42c645HH5ILCICSAVGHaa871Lbzg

ChangeLog
ntpd/refclock_nmea.c

index e3056d2267671850bf44f82e8d43c05db6e9cb68..f072053186b824e5f2bb980ebb2efdf497ad0f4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+* [Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception.
+* Increase detail in clockstats for NMEA driver (from Hal Murray).
 (4.2.7p257) 2012/02/17 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2135] defer calls to 'io_input' to main thread under Windows.
 (4.2.7p256) 2012/02/08 Released by Harlan Stenn <stenn@ntp.org>
index af8c68c4f578399e7e3e874de31b7135ef5ba2b8..21b8a8f9e7f55109ed23b5c05e47ab8fb3abd132 100644 (file)
@@ -229,6 +229,11 @@ typedef struct {
        l_fp    last_reftime;   /* last processed reference stamp */
        /* per sentence checksum seen flag */
        u_char  cksum_type[NMEA_ARRAY_SIZE];
+       int     total_nmea;     /* clockstats sentence counts */
+       int     good_nmea;
+       int     bad_nmea;
+       int     filter_nmea;
+       int     pps_used;
 } nmea_unit;
 
 /*
@@ -402,6 +407,8 @@ nmea_start(
 #ifdef HAVE_PPSAPI
        up->ppsapi_fd = -1;
 #endif
+       up->total_nmea = up->good_nmea = up->bad_nmea =
+           up->filter_nmea = up->pps_used = 0;
 
        /* Initialize miscellaneous variables */
        peer->precision = PRECISION;
@@ -637,7 +644,7 @@ refclock_ppsrelate(
 
        if (pp->leap == LEAP_NOTINSYNC)
                return PPS_RELATE_NONE; /* clock is insane, no chance */
-       
+
        ZERO(timeout);
        ZERO(pps_info);
        if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC,
@@ -768,6 +775,7 @@ nmea_receive(
                        rd_lastcode));
                break;
        }
+       up->total_nmea++;
        /* 
         * --> below this point we have a valid NMEA sentence <--
         * Check sentence name. Skip first 2 chars (talker ID), to allow
@@ -799,9 +807,11 @@ nmea_receive(
        }
        
        /* See if I want to process this message type */
-       if ( (peer->ttl & NMEA_MESSAGE_MASK      ) &&
-           !(peer->ttl & sentence_mode[sentence])  )
+       if ((peer->ttl & NMEA_MESSAGE_MASK) &&
+           !(peer->ttl & sentence_mode[sentence])) {
+               up->filter_nmea++;
                return;
+       }
 
        /* 
         * make sure it came in clean
@@ -943,8 +953,10 @@ nmea_receive(
         */
        rd_reftime = tspec_intv_to_lfp(tofs);
        rd_reftime.l_ui += caltontp(&date);
-       if (L_ISEQU(&up->last_reftime, &rd_reftime))
+       if (L_ISEQU(&up->last_reftime, &rd_reftime)) {
+               up->filter_nmea++;
                return;
+       }
        up->last_reftime = rd_reftime;
        rd_fudge = pp->fudgetime2;
 
@@ -959,6 +971,14 @@ nmea_receive(
        pp->a_lastcode[rd_lencode] = '\0';
        pp->lastrec = rd_timestamp;
 
+       if (pp->leap == LEAP_NOTINSYNC) {
+               up->bad_nmea++;
+               return;
+       }
+
+       /* Text looks OK. */
+       up->good_nmea++;
+
 #ifdef HAVE_PPSAPI
        /* If we have PPS running, we try to associate the sentence
         * with the last active edge of the PPS signal.
@@ -974,6 +994,7 @@ nmea_receive(
                        peer->flags |= FLAG_PPS;
                        DPRINTF(2, ("%s PPS_RELATE_PHASE\n",
                                    refnumtoa(&peer->srcadr)));
+                       up->pps_used++;
                        break;
                        
                case PPS_RELATE_EDGE:
@@ -1049,7 +1070,19 @@ nmea_poll(
                pp->polls++;
                pp->lastref = pp->lastrec;
                refclock_receive(peer);
-               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       }
+       if (up->total_nmea > 0) {
+               /*
+                * Log counters if any NMEA lines.
+                * May include sample of bad line.
+                */
+               mprintf_clock_stats(&peer->srcadr,
+                                   "%s %d %d %d %d %d", pp->a_lastcode,
+                                   up->total_nmea, up->good_nmea,
+                                   up->bad_nmea, up->filter_nmea,
+                                   up->pps_used);
+               up->total_nmea = up->good_nmea = up->bad_nmea =
+                   up->filter_nmea = up->pps_used = 0;
        }
 }
 
@@ -1717,4 +1750,4 @@ nmead_open(
 }
 #else
 NONEMPTY_TRANSLATION_UNIT
-#endif /* REFCLOCK && CLOCK_NMEA */
+#endif /* REFCLOCK && CLOCK_NMEA */
\ No newline at end of file