]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1237] Windows serial code treat CR and LF both as line
authorDave Hart <hart@ntp.org>
Sat, 11 Jul 2009 05:47:56 +0000 (05:47 +0000)
committerDave Hart <hart@ntp.org>
Sat, 11 Jul 2009 05:47:56 +0000 (05:47 +0000)
  terminators.
[Bug 1238] use fudge time2 for serial timecode offset in NMEA driver.
document fudge time1 as PPS offset, fudge time2 as serial timecode offset
  for driver20.html (NMEA)

bk: 4a58278cfU51ZGIMdfe9OaGRuGh_AA

ChangeLog
html/drivers/driver20.html
ntpd/refclock_nmea.c
ports/winnt/ntpd/ntp_iocompletionport.c

index 4d07fe48f5bd58ad6e7dd99333f13156f7e0a007..44a459631fd533399f81d1562a77888d2c557136 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,14 @@
+* [Bug 1237] Windows serial code treat CR and LF both as line
+  terminators.
+* [Bug 1238] use fudge time2 for serial timecode offset in NMEA driver.
 (4.2.5p185) 2009/07/01 Released by Harlan Stenn <stenn@ntp.org>
 * Documentation updates from Dave Mills.
 * [Bug 1234] convert NMEA driver to use common PPSAPI code.
 * timepps-Solaris.h pps_handle_t changed from pointer to scalar
 * Spectracom refclock added to Windows port of ntpd
 * [Bug 1236] Declaration order fixed.
-* Bracket private ONCORE debug statements with #if 0 rather than #ifdef DEBUG
+* Bracket private ONCORE debug statements with #if 0 rather than #ifdef
+  DEBUG
 * Delete ONCORE debug statement that is now handled elsewhere.
 (4.2.5p184) 2009/06/24 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1233] atom refclock fudge time1 sign flipped in 4.2.5p164.
index c6837439082579002f814d99005377b6011305f3..9b871a937f095aa6c7f87e6232992852f19e6574 100644 (file)
@@ -80,9 +80,9 @@ $GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;
                <h4>Fudge Factors</h4>
                <dl>
                        <dt><tt>time1 <i>time</i></tt>
-                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dd>Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0.
                        <dt><tt>time2 <i>time</i></tt>
-                       <dd>Not used by this driver.
+                       <dd>Specifies the serial end of line time offset calibration factor, in seconds and fraction, with default 0.0.
                        <dt><tt>stratum <i>number</i></tt>
                        <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
                        <dt><tt>refid <i>string</i></tt>
index dd94efa8286520ea357678ba88976be19f29eb37..8be9879a006037a5ba1737d12f14f1a239e67567 100644 (file)
@@ -9,6 +9,11 @@
  *
  * Updated to process 'time1' fudge factor
  *             Venu Gopal May 05, 2008
+ *
+ * Converted to common PPSAPI code, separate PPS fudge time1
+ * from serial timecode fudge time2.
+ *             Dave Hart July 1, 2009
+ *             hart@ntp.org, davehart@davehart.com
  */
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -333,6 +338,7 @@ nmea_timer(
                    0) {
                        up->pcount++,
                        peer->flags |= FLAG_PPS;
+                       peer->precision = PPS_PRECISION;
                }
        }
 }
@@ -354,6 +360,7 @@ nmea_receive(
        char *cp, *dp, *msg;
        int cmdtype;
        int cmdtypezdg = 0;
+       l_fp lfp_fudgetime2;
        /* Use these variables to hold data until we decide its worth keeping */
        char    rd_lastcode[BMAX];
        l_fp    rd_timestamp;
@@ -463,7 +470,10 @@ nmea_receive(
        memcpy(pp->a_lastcode, rd_lastcode, pp->lencode + 1);
        cp = pp->a_lastcode;
 
-       pp->lastrec = up->tstamp = rd_timestamp;
+       DTOLFP(pp->fudgetime2, &lfp_fudgetime2);
+       L_ADD(&rd_timestamp, &lfp_fudgetime2);
+       up->tstamp = rd_timestamp;
+       pp->lastrec = up->tstamp;
 
        DPRINTF(1, ("nmea: timecode %d %s\n", pp->lencode, pp->a_lastcode));
 
@@ -762,8 +772,10 @@ nmea_poll(
         * timeout and keep going.
         */
 #ifdef HAVE_PPSAPI
-       if (up->pcount == 0)
+       if (up->pcount == 0) {
                peer->flags &= ~FLAG_PPS;
+               peer->precision = PRECISION;
+       }
        if (up->tcount == 0) {
                pp->coderecv = pp->codeproc;
                refclock_report(peer, CEVNT_TIMEOUT);
index 97e341afa2e27c8a6bdb0ea161013c302440a007..ac30fcbdc544214da2ec0b6e2ac37a80ef58384b 100644 (file)
@@ -507,9 +507,11 @@ OnSerialWaitComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errsta
 static int 
 OnSerialReadComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
 {
-       recvbuf_t *buff;
-       struct refclockio * rio = (struct refclockio *) i;
+       recvbuf_t *             buff;
+       l_fp                    cr_time;
+       struct refclockio *     rio;
 
+       rio = (struct refclockio *)i;
        /*
         * Get the recvbuf pointer from the overlapped buffer.
         */
@@ -530,6 +532,24 @@ OnSerialReadComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errsta
                 * have fired since the port was opened.
                 */
                if (rio->recvcount++) {
+                       cr_time = buff->recv_time;
+                       add_full_recv_buffer(buff);
+                       /*
+                        * Mimic Unix line discipline and assume CR/LF
+                        * line termination.  On Unix the CR terminates
+                        * the line containing the timecode, and
+                        * immediately after the LF terminates an empty
+                        * line.  So synthesize the empty LF-terminated
+                        * line using the same CR timestamp.  Both CR
+                        * and LF are stripped by refclock_gtlin().
+                        */
+                       buff = get_free_recv_buffer_alloc();
+                       buff->recv_time = cr_time;
+                       buff->recv_length = 0;
+                       buff->fd = _get_osfhandle(rio->fd);
+                       buff->receiver = rio->clock_recv;
+                       buff->dstadr = NULL;
+                       buff->recv_srcclock = rio->srcclock;
                        add_full_recv_buffer(buff);
                        /*
                         * Now signal we have something to process