From: Dave Hart Date: Tue, 21 Feb 2012 02:33:47 +0000 (+0000) Subject: Merge psp-deb1:/home/perlinger/ntp-dev-2143 X-Git-Tag: NTP_4_2_7P258~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=becbbfb317d34003ef1642a2661de38fb0057fda;p=thirdparty%2Fntp.git Merge psp-deb1:/home/perlinger/ntp-dev-2143 into dlh-7551.ad.hartbrothers.com:C:/ntp/ntp-dev-2143 bk: 4f43028bRUvZbLrb2WExc8rXTeLmdQ --- becbbfb317d34003ef1642a2661de38fb0057fda diff --cc ChangeLog index 3e8f87f2b,acf09fa43..ad76bdff5 --- a/ChangeLog +++ b/ChangeLog @@@ -1,7 -1,5 +1,7 @@@ +* [Bug 2140] Rework of Windows I/O completion port handling to avoid + garbling serial input in UNIX line discipline emulation. - * [Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception. - * Increase detail in clockstats for NMEA driver (from Hal Murray). + * [Bug 2143] NMEA driver: discard data if quality indication not good, - add statistic counters (mode bit enabled) to clockstats file ++ add statistic counters (mode bit enabled) to clockstats file. (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 --cc ntpd/refclock_nmea.c index 21b8a8f9e,adb7e9234..0338d3fa9 --- a/ntpd/refclock_nmea.c +++ b/ntpd/refclock_nmea.c @@@ -227,13 -229,18 +229,23 @@@ typedef struct u_char gps_time; /* use GPS time, not UTC */ u_short century_cache; /* cached current century */ l_fp last_reftime; /* last processed reference stamp */ + /* tally stats, reset each poll cycle */ + struct + { + u_int total; + u_int good; + u_int bad; + u_int filtered; + u_int pps_used; + } + tally; /* 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; /* @@@ -775,12 -781,14 +786,15 @@@ nmea_receive rd_lastcode)); break; } - up->total_nmea++; + up->tally.total++; ++ /* * --> below this point we have a valid NMEA sentence <-- - * Check sentence name. Skip first 2 chars (talker ID), to allow - * for $GLGGA and $GPGGA etc. Since the name field has at least 5 - * chars we can simply shift the field start. + * + * Check sentence name. Skip first 2 chars (talker ID) in most + * cases, to allow for $GLGGA and $GPGGA etc. Since the name + * field has at least 5 chars we can simply shift the field + * start. */ cp = field_parse(&rdata, 0); if (strncmp(cp + 2, "RMC,", 4) == 0) @@@ -807,9 -815,9 +821,9 @@@ } /* 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++; + up->tally.filtered++; return; } @@@ -971,16 -989,9 +995,17 @@@ 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 + /* + * If we have PPS running, we try to associate the sentence * with the last active edge of the PPS signal. */ if (up->ppsapi_lit) @@@ -1071,21 -1080,25 +1094,26 @@@ nmea_poll pp->lastref = pp->lastrec; refclock_receive(peer); } - 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; + + /* + * If extended logging is required, write the tally stats to the + * clockstats file; otherwise just do a normal clock stats + * record. Clear the tally stats anyway. + */ + if (peer->ttl & NMEA_EXTLOG_MASK) { + /* Log & reset counters with extended logging */ + mprintf_clock_stats( + &peer->srcadr, "%s %u %u %u %u %u", + pp->a_lastcode, + up->tally.total, up->tally.good, up->tally.bad, + up->tally.filtered, up->tally.pps_used); + } else { + record_clock_stats(&peer->srcadr, pp->a_lastcode); } + ZERO(up->tally); } ++ #if NMEA_WRITE_SUPPORT /* * -------------------------------------------------------------------