]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Merge psp-deb1:/home/perlinger/ntp-dev-2143
authorDave Hart <hart@ntp.org>
Tue, 21 Feb 2012 02:33:47 +0000 (02:33 +0000)
committerDave Hart <hart@ntp.org>
Tue, 21 Feb 2012 02:33:47 +0000 (02:33 +0000)
into  dlh-7551.ad.hartbrothers.com:C:/ntp/ntp-dev-2143

bk: 4f43028bRUvZbLrb2WExc8rXTeLmdQ

1  2 
ChangeLog
ntpd/refclock_nmea.c

diff --cc ChangeLog
index 3e8f87f2b3ebc8bf5c96ca1d1d4d0131e6313a9d,acf09fa43c6858fdaae454ae02065271dbcf67c5..ad76bdff58da636605ebbc9cccbb995e1964e38a
+++ b/ChangeLog
@@@ -1,7 -1,5 +1,7 @@@
- * [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>
index 21b8a8f9e7f55109ed23b5c05e47ab8fb3abd132,adb7e923470a037a5f6d8b659317899cf4c124ad..0338d3fa98c5eb887e022e84b704cf6fb2de1559
@@@ -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)
        }
        
        /* 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)
@@@ -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
  /*
   * -------------------------------------------------------------------