]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
refclock_nmea.c refactoring by Juergen Perlinger.
authorDave Hart <hart@ntp.org>
Mon, 10 Jan 2011 00:22:04 +0000 (00:22 +0000)
committerDave Hart <hart@ntp.org>
Mon, 10 Jan 2011 00:22:04 +0000 (00:22 +0000)
bk: 4d2a512c1vv1mwduGlMekyxLS7PQ4w

ChangeLog
html/drivers/driver20.html
ntpd/refclock_nmea.c

index 1f05e7d0a940c879d4576d47b1706e76c3930f20..10985b52c31c059dccc9a349d7c627cb71cecf11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* refclock_nmea.c refactoring by Juergen Perlinger.
 (4.2.7p115) 2011/01/09 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl().
 * [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64.
index 3626fa30f3f4ea46a1daa6a04883793ef84a8fc2..9b871a937f095aa6c7f87e6232992852f19e6574 100644 (file)
 
 <html>
 
-  <head>
-    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
-    <title>Generic NMEA GPS Receiver</title>
-    <link href="scripts/style.css" type="text/css" rel="stylesheet">
-    
-    <style type="text/css">
-      table.dlstable { font-size:85%; }
-      td.ttf{ font-family:Courier; font-weight:bold; }
-    </style>
-  </head>
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>Generic NMEA GPS Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Generic NMEA GPS Receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.20.<i>u</i><br>
+                       Reference ID: <tt>GPS</tt><br>
+                       Driver ID: <tt>GPS_NMEA</tt><br>
+                       Serial Port: <tt>/dev/gps<i>u</i></tt>; 4800 - 115200 bps, 8-bits, no parity<br>
+                       Serial Port: <tt>/dev/gpspps<i>u</i></tt>; for just the PPS signal (this is tried first for PPS, before <tt>/dev/gps<i>u</i></tt>)<br>
+                       Serial Port: <tt>/dev/gps<i>u</i></tt>; symlink to server:port (for nmead) Features: <tt>tty_clk</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports GPS receivers with the <tt>$GPRMC, $GPGLL, $GPGGA, $GPZDA, and $GPZDG</tt> NMEA sentences by default.&nbsp; Note that Accord's custom NMEA sentence <tt>$GPZDG</tt> reports using the GPS timescale, while the rest of the sentences report UTC.&nbsp; The difference between the two is a whole number of seconds which increases with each leap second insertion in UTC.&nbsp; To avoid problems mixing UTC and GPS timescales, the driver disables processing of UTC sentences once <tt>$GPZDG</tt> is received.</p>
+               <p>The driver expects the receiver to be set up to transmit at least one supported sentence every second.</p>
+               <p>The accuracy depends on the receiver used. Inexpensive GPS models are available with a claimed PPS signal accuracy of 1 <font face="Symbol">m</font>s or better relative to the broadcast signal. However, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.</p>
+               <p>If the Operating System supports PPSAPI (<a href="http://www.ietf.org/rfc/rfc2783.txt">RFC 2783</a>), fudge flag1 1 enables its use.<br>&nbsp;</p>
+               <p>The various GPS sentences that this driver recognises look like this:<br>
+                       (others quietly ignored)</p>
+               <pre><tt>$GPRMC,UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CS&lt;cr&gt;&lt;lf&gt;
+$GPGLL,LAT,LAT_REF,LONG,LONG_REF,UTC,POS_STAT*CS&lt;cr&gt;&lt;lf&gt;
+$GPGGA,UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CS&lt;cr&gt;&lt;lf&gt;
+$GPZDA,UTC,DD,MM,YYYY,TH,TM,*CS&lt;cr&gt;&lt;lf&gt;
+$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;
+
+&nbsp; UTC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])
+&nbsp; POS_STAT - Position status. (A = Data valid, V = Data invalid)
+&nbsp; LAT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Latitude (llll.ll)
+&nbsp; LAT_REF&nbsp; - Latitude direction. (N = North, S = South)
+&nbsp; LON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Longitude (yyyyy.yy)
+&nbsp; LON_REF&nbsp; - Longitude direction (E = East, W = West)
+&nbsp; SPD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Speed over ground. (knots) (x.x)
+&nbsp; HDG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Heading/track made good (degrees True) (x.x)
+&nbsp; DATE&nbsp;&nbsp;&nbsp;&nbsp; - Date (ddmmyy)
+&nbsp; MAG_VAR&nbsp; - Magnetic variation (degrees) (x.x)
+&nbsp; MAG_REF&nbsp; - Magnetic variation (E = East, W = West)
+&nbsp; FIX_MODE - Position Fix Mode (0 = Invalid, &gt;0 = Valid)
+&nbsp; SAT_USED - Number Satellites used in solution
+&nbsp; HDOP&nbsp;&nbsp;&nbsp;&nbsp; - Horizontal Dilution of Precision
+&nbsp; ALT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Antenna Altitude
+&nbsp; ALT_UNIT - Altitude Units (Metres/Feet)
+&nbsp; GEO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Geoid/Elipsoid separation
+&nbsp; G_UNIT&nbsp;&nbsp; - Geoid units (M/F)
+&nbsp; D_AGE&nbsp;&nbsp;&nbsp; - Age of last DGPS Fix
+&nbsp; D_REF&nbsp;&nbsp;&nbsp; - Reference ID of DGPS station
+&nbsp; GPSTIME&nbsp; - Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])
+&nbsp; DD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Day of the month (1-31)
+&nbsp; MM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Month of the year (1-12)
+&nbsp; YYYY&nbsp;&nbsp;&nbsp;&nbsp; - Year
+&nbsp; AA.BB&nbsp;&nbsp;&nbsp; - Denotes the signal strength (should be &lt 05.00)
+&nbsp; V&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - GPS sync status
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '0' =&gt INVALID time,
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '1' =&gt accuracy of +/- 20ms,
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '2' =&gt accuracy of +/- 100ns      
+&nbsp; CS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Checksum
+&nbsp; &lt;cr&gt;&lt;lf&gt; - Sentence terminator.</tt></pre>
+
+<p>Specific GPS sentences and bitrates may be selected by setting bits of the 'mode' in the server configuration line:<br>
+  &nbsp;&nbsp;<tt>server 127.127.20.x mode X</tt><br>&nbsp;&nbsp;&nbsp; bit 0 - process <tt>$GPMRC</tt>&nbsp;&nbsp;&nbsp; (value = 1)<br>&nbsp;&nbsp;&nbsp; bit 1 - process <tt>$GPGGA</tt>&nbsp;&nbsp;&nbsp; (value = 2)<br>&nbsp;&nbsp;&nbsp; bit 2 - process <tt>$GPGLL</tt>&nbsp;&nbsp;&nbsp; (value = 4)<br>&nbsp;&nbsp;&nbsp; bit 4 - process <tt>$GPZDA</tt> or <tt>$GPZDG</tt>&nbsp;&nbsp;&nbsp; (value = 8)<br> 
+<p>The default (mode 0) is to process all supported sentences, which results in the last received each cycle being used.&nbsp; Multiple sentences may be selected by adding their mode bit values.&nbsp; The driver uses 4800 bits per second by default.&nbsp; Faster bitrates can be selected using bits 4, 5, and 6 of the mode field:<br><br>
+               &nbsp;&nbsp;&nbsp; bits 4/5/6 - select serial bitrate&nbsp;&nbsp; (0 for 4800 - the default, 16 for 9600, 32 for 19200, 48 for 38400, 64 for 57600, 80 for 115200)<br></p>
+               <p>The driver will send a <tt>$PMOTG,RMC,0000*1D&lt;cr&gt;&lt;lf&gt;</tt> command each poll interval.&nbsp; This is not needed on most GPS receivers because they automatically send <tt>$GPRMC</tt> every second, but helps a Motorola GPS receiver that is otherwise silent.&nbsp; NMEA devices ignore commands they do not understand.</p>
+               <h4>Setting up the Garmin GPS-25XL</h4>
+               Switch off all output with by sending it the following string.
+               <pre>&quot;$PGRMO,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <p>Now switch only $GPRMC on by sending it the following string.</p>
+               <pre>&quot;$PGRMO,GPRMC,1&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <p>On some systems the PPS signal isn't switched on by default. It can be switched on by sending the following string.</p>
+               <pre>&quot;$PGRMC,,,,,,,,,,,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <h4>Monitor Data</h4>
+               <p>The GPS sentence that is used is written to the clockstats file and available with ntpq -c clockvar.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <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>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Disable PPS signal processing if 0 (default); enable PPS signal processing if 1.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>If PPS signal processing is enabled, capture the pulse on the rising edge if 0 (default); capture on the falling edge if 1.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>If PPS signal processing is enabled, use the <tt>ntpd</tt> clock discipline if 0 (default); use the kernel discipline if 1.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Obscures location in timecode: 0 for disable (default), 1 for enable.
+               </dl>
+               <p>Additional Information</p>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
 
-  <body>
-    <h3>Generic NMEA GPS Receiver</h3>
-    <hr>
-    <h4>Synopsis</h4>
-
-    <p>
-      Address: 127.127.20.<i>u</i><br>
-      Reference ID: <tt>GPS</tt><br>
-      Driver ID: <tt>GPS_NMEA</tt><br>
-      Serial Port: <tt>/dev/gps<i>u</i></tt>; 4800 - 115200 bps, 8-bits, no parity<br>
-      Serial Port: <tt>/dev/gpspps<i>u</i></tt>; for just the PPS signal (this
-      is tried first for PPS, before <tt>/dev/gps<i>u</i></tt>)<br>
-      Serial Port: <tt>/dev/gps<i>u</i></tt>; symlink to server:port (for nmead)<br>
-      Features: <tt>tty_clk</tt>
-    </p>
-
-    <h4>Description</h4>
-
-    <p>
-      This driver supports GPS receivers with
-      the <tt>$GPRMC</tt>, <tt>$GPGLL</tt>, <tt>$GPGGA</tt>, <tt>$GPZDA</tt>
-      and <tt>$GPZDG</tt> NMEA sentences by default.&nbsp; Note that Accord's
-      custom NMEA sentence <tt>$GPZDG</tt> reports using the GPS timescale,
-      while the rest of the sentences report UTC.&nbsp; The difference between
-      the two is a whole number of seconds which increases with each leap
-      second insertion in UTC.&nbsp; To avoid problems mixing UTC and GPS
-      timescales, the driver disables processing of UTC sentences
-      once <tt>$GPZDG</tt> is received.
-    </p>
-    <p>
-      The driver expects the receiver to be set up to transmit at least one
-      supported sentence every second.
-    </p>
-    <p>
-      The accuracy depends on the receiver used. Inexpensive GPS models are
-      available with a claimed PPS signal accuracy of
-      1 <font face="Symbol">m</font>s or better relative to the broadcast
-      signal. However, in most cases the actual accuracy is limited by the
-      precision of the timecode and the latencies of the serial interface and
-      operating system.
-    </p>
-    <p>
-      If the Operating System supports PPSAPI
-      (<a href="http://www.ietf.org/rfc/rfc2783.txt">RFC 2783</a>), fudge flag1
-      1 enables its use.
-    </p>
-    <p>
-      The various GPS sentences that this driver recognises look like this:<br>
-      (others quietly ignored)
-    </p>
-
-    <p><table border="1" class="dlstable">
-      <caption>Accepted NMEA sentences</caption>
-      <tr>
-       <th>Sentence</th>
-       <th>Vendor</th>
-      </tr><tr>
-       <td class="ttf">$GPRMC,UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CS&lt;cr&gt;&lt;lf&gt;</td>
-      </tr><tr>
-       <td class="ttf">$GPGLL,LAT,LAT_REF,LON,LON_REF,UTC,POS_STAT*CS&lt;cr&gt;&lt;lf&gt;</td>
-      </tr><tr>
-       <td class="ttf">$GPGGA,UTC,LAT,LAT_REF,LON,LON_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CS&lt;cr&gt;&lt;lf&gt;</td>
-      </tr><tr>
-       <td class="ttf">$GPZDA,UTC,DD,MM,YYYY,TH,TM,*CS&lt;cr&gt;&lt;lf&gt;</td>
-      </tr><tr>
-       <td class="ttf">$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;</td>
-       <td>Accord</td>
-      </tr>
-    </table></p>
-
-    <p><table border="1" class="dlstable">
-      <caption>NMEA data items</caption>
-      <tr>
-       <th>Symbol</th>
-       <th>Meaning and Format</th>
-      </tr>
-      
-      <tr>
-       <td class="ttf">UTC</td>
-       <td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])</td>
-      </tr><tr>
-       <td class="ttf">POS_STAT</td>
-       <td>Position status. (A = Data valid, V = Data invalid)</td>
-      </tr><tr>
-       <td class="ttf">LAT</td>
-       <td>Latitude (llll.ll)</td>
-      </tr><tr>
-       <td class="ttf">LAT_REF</td>
-       <td>Latitude direction. (N = North, S = South)</td>
-      </tr><tr>
-       <td class="ttf">LON</td>
-       <td>Longitude (yyyyy.yy)</td>
-      </tr><tr>
-       <td class="ttf">LON_REF</td>
-       <td>Longitude direction (E = East, W = West)</td>
-      </tr><tr>
-       <td class="ttf">SPD</td>
-       <td>Speed over ground. (knots) (x.x)</td>
-      </tr><tr>
-       <td class="ttf">HDG</td>
-       <td>Heading/track made good (degrees True) (x.x)</td>
-      </tr><tr>
-       <td class="ttf">DATE</td>
-       <td>Date (ddmmyy)</td>
-      </tr><tr>
-       <td class="ttf">MAG_VAR</td>
-       <td>Magnetic variation (degrees) (x.x)</td>
-      </tr><tr>
-       <td class="ttf">MAG_REF</td>
-       <td>Magnetic variation (E = East, W = West)</td>
-      </tr><tr>
-       <td class="ttf">FIX_MODE</td>
-       <td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
-      </tr><tr>
-       <td class="ttf">SAT_USED</td>
-       <td>Number of Satellites used in solution</td>
-      </tr><tr>
-       <td class="ttf">HDOP</td>
-       <td>Horizontal Dilution of Precision</td>
-      </tr><tr>
-       <td class="ttf">ALT</td>
-       <td>Antenna Altitude</td>
-      </tr><tr>
-       <td class="ttf">ALT_UNIT</td>
-       <td>Altitude Units (Metres/Feet)</td>
-      </tr><tr>
-       <td class="ttf">GEO</td>
-       <td>Geoid/Elipsoid separation</td>
-      </tr><tr>
-       <td class="ttf">G_UNIT</td>
-       <td>Geoid units (M/F)</td>
-      </tr><tr>
-       <td class="ttf">D_AGE</td>
-       <td>Age of last DGPS Fix</td>
-      </tr><tr>
-       <td class="ttf">D_REF</td>
-       <td>Reference ID of DGPS station</td>
-      </tr><tr>
-       <td class="ttf">GPSTIME</td>
-       <td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])</td>
-      </tr><tr>
-       <td class="ttf">DD</td>
-       <td>Day of the month (1-31)</td>
-      </tr><tr>
-       <td class="ttf">MM</td>
-       <td>Month of the year (1-12)</td>
-      </tr><tr>
-       <td class="ttf">YYYY</td>
-       <td>Year</td>
-      </tr><tr>
-       <td class="ttf">AA.BB</td>
-       <td>Denotes the signal strength (should be &lt 05.00)</td>
-      </tr><tr>
-       <td class="ttf">V</td>
-       <td>GPS sync status<br>
-         &nbsp;&nbsp;&nbsp;'0' =&gt INVALID time,<br>
-         &nbsp;&nbsp;&nbsp;'1' =&gt accuracy of +/- 20ms,<br>
-         &nbsp;&nbsp;&nbsp;'2' =&gt accuracy of +/- 100ns</td>
-      </tr><tr>
-       <td class="ttf">CS</td>
-       <td> Checksum</td>
-      </tr><tr>
-       <td class="ttf">&lt;cr&gt;&lt;lf&gt</td>
-       <td>Sentence terminator.</td>
-      </tr>
-    </table></p>
-
-
-    <h4>The 'mode' byte</h4>
-    
-    <p>
-      Specific GPS sentences and bitrates may be selected by setting bits of
-      the 'mode' in the server configuration line:<br> &nbsp;&nbsp;<tt>server
-      127.127.20.x mode X</tt>
-    </p>
-
-    <table border="1">
-      <caption>mode byte bits and bit groups</caption>
-      <tr>
-       <th align="center">Bit</th>
-       <th align="center">Dec.</th>
-       <th align="left">Meaning</th>
-      </tr>
-      
-      <tr>
-       <td align="center">0</td>
-       <td align="center">1</td>
-       <td>process <tt>$GPMRC</tt></td>
-      </tr><tr>
-       <td align="center">1</td>
-       <td align="center">2</td>
-       <td>process <tt>$GPGGA</tt></td>
-      </tr><tr>
-       <td align="center">2</td>
-       <td align="center">4</td>
-       <td>process <tt>$GPGLL</tt></td>
-      </tr><tr>
-       <td align="center">3</td>
-       <td align="center">8</td>
-       <td>process <tt>$GPZDA</tt> or <tt>$GPZDG</tt></td>
-      </tr><tr>
-       <td rowspan="6" align="center">4-6</td>
-       <td align="center">0</td>
-       <td>linespeed 4800bps</td>
-      </tr><tr>
-       <td align="center">16</td>
-       <td>linespeed 9600bps</td>
-      </tr><tr>
-       <td align="center">32</td>
-       <td>linespeed 19200bps</td>
-      </tr><tr>
-       <td align="center">48</td>
-       <td>linespeed 38400bps</td>
-      </tr><tr>
-       <td align="center">64</td>
-       <td>linespeed 57600bps</td>
-      </tr><tr>
-       <td align="center">80</td>
-       <td>linespeed 115200bps</td>
-      </tr><tr>
-       <td align="center">7</td>
-       <td align="center">128</td>
-       <td>Write the sub-second fraction of the receive time stamp to the
-       clockstat file for all recognised NMEA sentences. This can be used to
-       get a useful value for fudge time2.<br><strong>Caveat:</strong> This
-       will fill your clockstat file rather fast. Use it only temporarily to
-       get the numbers for the NMEA sentence of your choice.</td>
-      </tr>
-    </table> 
-
-    <p>
-      The default (mode 0) is to process all supported sentences at a linespeed
-      of 4800bps, which results in the first one received and recognised in
-      each cycle being used.&nbsp; If only specific sentences should be
-      recognised, then the mode byte must be chosen to enable only the selected
-      ones.&nbsp; Multiple sentences may be selected by adding their mode bit
-      values, but of those enabled still only the first received sentence in a
-      cycle will be used.&nbsp; Using more than one sentence per cycle is
-      impossible, because
-      <ul>
-       <li>there is only <a href="#fudgetime2">fudge time2</a> available to
-         compensate for transmission delays but every sentence would need a
-         different one and
-       <li>using more than one sentence per cycle overstuffs the internal data
-         filters.
-      </ul>
-      The driver uses 4800 bits per second by default, but faster bitrates can
-      be selected using bits 4 to 6 of the mode field.
-    </p>
-
-    <p>
-      <strong>Caveat:</strong> Using higher line speeds does not necessarily
-      increase the precision of the timing device.&nbsp; Higher line speeds are
-      not necessarily helpful for the NMEA driver, either.&nbsp; They can be
-      used to accomodate for an amount of data that does not fit into a
-      1-second cycle at 4800bps, but high-speed high-volume NMEA data is likely
-      to cause trouble with the serial line driver since NMEA supports no
-      protocol handshake.&nbsp; Any device that is exclusively used for time
-      synchronisation purposes should be configured to transmit the relevant
-      data only, e.g. one <tt>$GPRMC</tt> or <tt>$GPZDA</tt> per second, at a
-      linespeed of 4800bps or eventually 9600bps.
-    </p>
-
-    <p>
-      <a href="https://support.ntp.org/bin/view/Support/ConfiguringNMEARefclocks">Configuring
-      NMEA Refclocks</a> might give further useful hints for specific hardware
-      devices that exhibit strange or curious behaviour.
-    </p>
-
-    <p>
-      To make a specific setting, select the corresponding decimal values from
-      the mode byte table, add them all together and enter the resulting
-      decimal value into the clock configuration line.
-    </p>
-
-    <p>
-      The driver will send a <tt>$PMOTG,RMC,0000*1D&lt;cr&gt;&lt;lf&gt;</tt>
-      command each poll interval.&nbsp; This is not needed on most GPS
-      receivers because they automatically send <tt>$GPRMC</tt> every second,
-      but helps a Motorola GPS receiver that is otherwise silent.&nbsp; NMEA
-      devices ignore commands they do not understand.
-    </p>
-
-    <h4>Setting up the Garmin GPS-25XL</h4>
-
-    Switch off all output with by sending it the following string.
-    <pre>&quot;$PGRMO,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
-    <p>Now switch only $GPRMC on by sending it the following string.</p>
-    <pre>&quot;$PGRMO,GPRMC,1&lt;cr&gt;&lt;lf&gt;&quot;</pre>
-
-    <p>On some systems the PPS signal isn't switched on by default. It can be
-    switched on by sending the following string.</p>
-    <pre>&quot;$PGRMC,,,,,,,,,,,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
-
-    <h4>Monitor Data</h4>
-
-    <p>The GPS sentence that is used is written to the clockstats file and
-    available with ntpq -c clockvar.</p>
-
-    <h4>Fudge Factors</h4>
-
-    <dl>
-      <dt><tt>time1 <i>time</i></tt></dt>
-      <dd>Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0.</dd>
-      <dt><a name="fudgetime2"><tt>time2 <i>time</i></tt></a></dt>
-      <dd>Specifies the serial end of line time offset calibration factor, in seconds and fraction, with default
-       0.0.</dd>
-      <dt><tt>stratum <i>number</i></tt></dt>
-      <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.</dd>
-      <dt><tt>refid <i>string</i></tt></dt>
-      <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with
-       default <tt>GPS</tt>.</dd>
-      <dt><tt>flag1 0 | 1</tt></dt>
-      <dd>Disable PPS signal processing if 0 (default); enable PPS signal processing if 1.</dd>
-      <dt><tt>flag2 0 | 1</tt></dt>
-      <dd>If PPS signal processing is enabled, capture the pulse on the rising edge if 0 (default); capture on the
-       falling edge if 1.</dd>
-      <dt><tt>flag3 0 | 1</tt></dt>
-      <dd>If PPS signal processing is enabled, use the <tt>ntpd</tt> clock discipline if 0 (default); use the kernel
-       discipline if 1.</dd>
-      <dt><tt>flag4 0 | 1</tt></dt>
-      <dd>Obscures location in timecode: 0 for disable (default), 1 for enable.</dd>
-    </dl>
-
-    <p>Additional Information</p>
-    <p><a href="../refclock.html">Reference Clock Drivers</a></p>
-    <hr>
-    <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
-  </body>
-  
 </html>
index fb98b36c750fe87d5e0143db5914e058a10c824b..744ac1ee4431ac4c3c6394a3fd5f65c0d0b9f548 100644 (file)
@@ -32,7 +32,6 @@
 #include "ntp_refclock.h"
 #include "ntp_stdlib.h"
 #include "ntp_calendar.h"
-#include "lib_strbuf.h"
 
 #ifdef HAVE_PPSAPI
 # include "ppsapi_timepps.h"
@@ -269,7 +268,7 @@ static int  parse_time      (const char *cp, struct calendar *jd,
 static int     parse_date      (const char *cp, struct calendar *jd,
                                 enum date_fmt fmt);
 /* calendar / date helpers */
-static int     unfold_day      (struct calendar*, u_int32 rec_ui);
+static int     unfold_day      (struct calendar *jd, u_int32 rec_ui);
 
 /*
  * -------------------------------------------------------------------
@@ -403,8 +402,7 @@ nmea_start(
                refnumtoa(&peer->srcadr), device, baudtext);
 
        /* Allocate and initialize unit structure */
-       up = emalloc(sizeof(*up));
-       memset(up, 0, sizeof(*up));
+       up = emalloc_zero(sizeof(*up));
        pp->io.clock_recv = nmea_receive;
        pp->io.srcclock = (caddr_t)peer;
        pp->io.datalen = 0;
@@ -638,9 +636,8 @@ refclock_ppsrelate(
        if (pp->leap == LEAP_NOTINSYNC)
                return PPS_RELATE_NONE; /* clock is insane, no chance */
        
-       memset(&timeout, 0, sizeof(timeout));
-       memset(&pps_info, 0, sizeof(pps_info_t));
-
+       ZERO(timeout);
+       ZERO(pps_info);
        if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC,
                           &pps_info, &timeout) < 0)
                return PPS_RELATE_NONE;
@@ -748,8 +745,10 @@ nmea_receive(
                                    sizeof(rd_lastcode), &rd_timestamp);
        checkres = field_init(&rdata, rd_lastcode, rd_lencode);
        switch (checkres) {
+
        case CHECK_INVALID:
-               DPRINTF(1, ("nmea: invalid data: '%s'\n", rd_lastcode));
+               DPRINTF(1, ("%s invalid data: '%s'\n",
+                       refnumtoa(&peer->srcadr), rd_lastcode));
                refclock_report(peer, CEVNT_BADREPLY);
                /* FALLTHRU */
 
@@ -757,7 +756,8 @@ nmea_receive(
                return;
 
        default:
-               DPRINTF(1, ("nmea: gpsread: %d '%s'\n", rd_lencode,
+               DPRINTF(1, ("%s gpsread: %d '%s'\n",
+                       refnumtoa(&peer->srcadr), rd_lencode,
                        rd_lastcode));
                break;
        }
@@ -783,12 +783,10 @@ nmea_receive(
 
        /* eventually output delay measurement now. */
        if (peer->ttl & NMEA_DELAYMEAS_MASK) {
-               LIB_GETBUF(cp);
-               snprintf(cp, LIB_BUFLENGTH, "delay %0.6f %.*s",
+               mprintf_clock_stats(&peer->srcadr, "delay %0.6f %.*s",
                         ldexp(rd_timestamp.l_uf, -32),
                         (int)(strchr(rd_lastcode, ',') - rd_lastcode),
                         rd_lastcode);
-               record_clock_stats(&peer->srcadr, cp);
        }
        
        /* See if I want to process this message type */
@@ -816,7 +814,8 @@ nmea_receive(
        if (up->cksum_type[sentence] <= (u_char)checkres) {
                up->cksum_type[sentence] = (u_char)checkres;
        } else {
-               DPRINTF(1, ("nmea: checksum missing: '%s'\n", rd_lastcode));
+               DPRINTF(1, ("%s checksum missing: '%s'\n",
+                       refnumtoa(&peer->srcadr), rd_lastcode));
                refclock_report(peer, CEVNT_BADREPLY);
                return;
        }
@@ -829,15 +828,15 @@ nmea_receive(
        if (up->gps_time && NMEA_GPZDG != sentence)
                return;
 
-       DPRINTF(1, ("nmea: processing %d bytes, timecode '%s'\n",
-                   rd_lencode, rd_lastcode));
+       DPRINTF(1, ("%s processing %d bytes, timecode '%s'\n",
+               refnumtoa(&peer->srcadr), rd_lencode, rd_lastcode));
 
        /* Grab fields depending on clock string type and possibly wipe
         * sensitive data from the last timecode.
         */
-       memset(&date, 0, sizeof(date)); /* pristine state of stamp */
-       switch (sentence)
-       {
+       ZERO(date);             /* pristine state of stamp */
+       switch (sentence) {
+
        case NMEA_GPRMC:
                /*
                 * Check quality byte, fetch data & time; need recv
@@ -915,7 +914,8 @@ nmea_receive(
                return;
        up->last_daytime = daytime;
        
-       DPRINTF(1, ("nmea_receive: effective timecode: %04u-%02u-%02u %02d:%02d:%02d\n",
+       DPRINTF(1, ("%s effective timecode: %04u-%02u-%02u %02d:%02d:%02d\n",
+               refnumtoa(&peer->srcadr),
                date.year, date.month, date.monthday,
                date.hour, date.minute, date.second));
 
@@ -1036,7 +1036,8 @@ nmea_poll(
        /*
         * reset counters for next cycle.
         */
-       up->pcount = up->tcount = 0;
+       up->pcount = 0;
+       up->tcount = 0;
 #endif /* HAVE_PPSAPI */
        /*
         * If the median filter is empty, claim a timeout and leave
@@ -1097,7 +1098,8 @@ gps_send(
        *end = '\0';
        dst += strlen(dst);
        len = dst - buf;
-       DPRINTF(1, ("nmea: gps_send: '%.*s'\n", len - 2, buf));
+       DPRINTF(1, ("%s gps_send: '%.*s'\n", refnumtoa(&peer->srcadr),
+               len - 2, buf));
 
        /* send out the whole stuff */
        if (write(fd, buf, len) == -1)
@@ -1441,7 +1443,7 @@ parse_date(
        /* store results */
        jd->monthday = (u_char)d;
        jd->month    = (u_char)m;
-       jd->year     = (u_char)y;
+       jd->year     = (u_short)y;
 
        return 1;
 }