From: Dave Hart Date: Mon, 20 Feb 2012 22:16:37 +0000 (+0000) Subject: [Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception. X-Git-Tag: NTP_4_2_7P258~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=310128eae6dd2ba4d73da071e5b82f6bbeba0c25;p=thirdparty%2Fntp.git [Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception. Increase detail in clockstats for NMEA driver (from Hal Murray). bk: 4f42c645HH5ILCICSAVGHaa871Lbzg --- diff --git a/ChangeLog b/ChangeLog index e3056d226..f07205318 100644 --- 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 * [Bug 2135] defer calls to 'io_input' to main thread under Windows. (4.2.7p256) 2012/02/08 Released by Harlan Stenn diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c index af8c68c4f..21b8a8f9e 100644 --- a/ntpd/refclock_nmea.c +++ b/ntpd/refclock_nmea.c @@ -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