- * [Bug 2143] NMEA 4.2.7p204 uses timecodes indicating lost reception.
- * Increase detail in clockstats for NMEA driver (from Hal Murray).
+* [Bug 2140] Rework of Windows I/O completion port handling to avoid
+ garbling serial input in UNIX line discipline emulation.
- add statistic counters (mode bit enabled) to clockstats file
+ * [Bug 2143] NMEA driver: discard data if quality indication not good,
++ add statistic counters (mode bit enabled) to clockstats file.
(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>
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;
/*
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)
}
/* 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;
}
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)
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
/*
* -------------------------------------------------------------------