]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/html/drivers/driver20.html
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / ntp / html / drivers / driver20.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head>
3     <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Generic NMEA GPS Receiver</title>
4     <!-- Changed by: Harlan &, 31-Mar-2014 -->
5     <link href="scripts/style.css" type="text/css" rel="stylesheet">
6     <style type="text/css">
7       table.dlstable { font-size:85%; }
8       td.ttf{ font-family:Courier; font-weight:bold; }
9     </style></head>
10
11
12
13   <body>
14     <h3>Generic NMEA GPS Receiver</h3>
15 <p>Last update:
16   <!-- #BeginDate format:En2m -->31-Mar-2014  03:55<!-- #EndDate -->
17   UTC</p>
18     <hr>
19     <h4>Synopsis</h4>
20
21     <p>
22       Address: 127.127.20.<i>u</i><br>
23       Reference ID: <tt>GPS</tt><br>
24       Driver ID: <tt>GPS_NMEA</tt><br>
25       Serial Port: <tt>/dev/gps<i>u</i></tt>; 4800 - 115200 bps, 8-bits, no parity<br>
26       Serial Port: <tt>/dev/gpspps<i>u</i></tt>; for just the PPS signal (this
27       is tried first for PPS, before <tt>/dev/gps<i>u</i></tt>)<br>
28       Serial Port: <tt>/dev/gps<i>u</i></tt>; symlink to server:port (for nmead)<br>
29       Features: <tt>tty_clk</tt>
30     </p>
31
32     <h4>Description</h4>
33
34     <p>
35       This driver supports GPS receivers with
36       the <tt>$GPRMC</tt>, <tt>$GPGLL</tt>, <tt>$GPGGA</tt>, <tt>$GPZDA</tt>
37       and <tt>$GPZDG</tt> NMEA sentences by default.&nbsp; Note that Accord's
38       custom NMEA sentence <tt>$GPZDG</tt> reports using the GPS timescale,
39       while the rest of the sentences report UTC.&nbsp; The difference between
40       the two is a whole number of seconds which increases with each leap
41       second insertion in UTC.&nbsp; To avoid problems mixing UTC and GPS
42       timescales, the driver disables processing of UTC sentences
43       once <tt>$GPZDG</tt> is received.
44     </p>
45     <p>
46       The driver expects the receiver to be set up to transmit at least one
47       supported sentence every second.
48     </p>
49     <p>
50       The accuracy depends on the receiver used. Inexpensive GPS models are
51       available with a claimed PPS signal accuracy of
52       1 &mu;s or better relative to the broadcast
53       signal. However, in most cases the actual accuracy is limited by the
54       precision of the timecode and the latencies of the serial interface and
55       operating system.
56     </p>
57     <p>
58       If the Operating System supports PPSAPI
59       (<a href="http://www.ietf.org/rfc/rfc2783.txt">RFC 2783</a>), fudge flag1
60       1 enables its use.
61     </p>
62     <p>
63       The various GPS sentences that this driver recognises look like this:<br>
64       (others quietly ignored)
65     </p>
66
67     <p><table class="dlstable" border="1">
68       <caption>Accepted NMEA sentences</caption>
69       <tbody><tr>
70         <th>Sentence</th>
71         <th>Vendor</th>
72       </tr><tr>
73         <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>
74       </tr><tr>
75         <td class="ttf">$GPGLL,LAT,LAT_REF,LON,LON_REF,UTC,POS_STAT*CS&lt;cr&gt;&lt;lf&gt;</td>
76       </tr><tr>
77         <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>
78       </tr><tr>
79         <td class="ttf">$GPZDA,UTC,DD,MM,YYYY,TH,TM,*CS&lt;cr&gt;&lt;lf&gt;</td>
80       </tr><tr>
81         <td class="ttf">$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;</td>
82         <td>Accord</td>
83       </tr>
84     </tbody></table></p>
85
86     <p><table class="dlstable" border="1">
87       <caption>NMEA data items</caption>
88       <tbody><tr>
89         <th>Symbol</th>
90         <th>Meaning and Format</th>
91       </tr>
92       
93       <tr>
94         <td class="ttf">UTC</td>
95         <td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])</td>
96       </tr><tr>
97         <td class="ttf">POS_STAT</td>
98         <td>Position status. (A = Data valid, V = Data invalid)</td>
99       </tr><tr>
100         <td class="ttf">LAT</td>
101         <td>Latitude (llll.ll)</td>
102       </tr><tr>
103         <td class="ttf">LAT_REF</td>
104         <td>Latitude direction. (N = North, S = South)</td>
105       </tr><tr>
106         <td class="ttf">LON</td>
107         <td>Longitude (yyyyy.yy)</td>
108       </tr><tr>
109         <td class="ttf">LON_REF</td>
110         <td>Longitude direction (E = East, W = West)</td>
111       </tr><tr>
112         <td class="ttf">SPD</td>
113         <td>Speed over ground. (knots) (x.x)</td>
114       </tr><tr>
115         <td class="ttf">HDG</td>
116         <td>Heading/track made good (degrees True) (x.x)</td>
117       </tr><tr>
118         <td class="ttf">DATE</td>
119         <td>Date (ddmmyy)</td>
120       </tr><tr>
121         <td class="ttf">MAG_VAR</td>
122         <td>Magnetic variation (degrees) (x.x)</td>
123       </tr><tr>
124         <td class="ttf">MAG_REF</td>
125         <td>Magnetic variation (E = East, W = West)</td>
126       </tr><tr>
127         <td class="ttf">FIX_MODE</td>
128         <td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
129       </tr><tr>
130         <td class="ttf">SAT_USED</td>
131         <td>Number of Satellites used in solution</td>
132       </tr><tr>
133         <td class="ttf">HDOP</td>
134         <td>Horizontal Dilution of Precision</td>
135       </tr><tr>
136         <td class="ttf">ALT</td>
137         <td>Antenna Altitude</td>
138       </tr><tr>
139         <td class="ttf">ALT_UNIT</td>
140         <td>Altitude Units (Metres/Feet)</td>
141       </tr><tr>
142         <td class="ttf">GEO</td>
143         <td>Geoid/Elipsoid separation</td>
144       </tr><tr>
145         <td class="ttf">G_UNIT</td>
146         <td>Geoid units (M/F)</td>
147       </tr><tr>
148         <td class="ttf">D_AGE</td>
149         <td>Age of last DGPS Fix</td>
150       </tr><tr>
151         <td class="ttf">D_REF</td>
152         <td>Reference ID of DGPS station</td>
153       </tr><tr>
154         <td class="ttf">GPSTIME</td>
155         <td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])</td>
156       </tr><tr>
157         <td class="ttf">DD</td>
158         <td>Day of the month (1-31)</td>
159       </tr><tr>
160         <td class="ttf">MM</td>
161         <td>Month of the year (1-12)</td>
162       </tr><tr>
163         <td class="ttf">YYYY</td>
164         <td>Year</td>
165       </tr><tr>
166         <td class="ttf">AA.BB</td>
167         <td>Denotes the signal strength (should be &lt; 05.00)</td>
168       </tr><tr>
169         <td class="ttf">V</td>
170         <td>GPS sync status<br>
171           &nbsp;&nbsp;&nbsp;'0' =&gt; INVALID time,<br>
172           &nbsp;&nbsp;&nbsp;'1' =&gt; accuracy of +/- 20ms,<br>
173           &nbsp;&nbsp;&nbsp;'2' =&gt; accuracy of +/- 100ns</td>
174       </tr><tr>
175         <td class="ttf">CS</td>
176         <td> Checksum</td>
177       </tr><tr>
178         <td class="ttf">&lt;cr&gt;&lt;lf&gt;</td>
179         <td>Sentence terminator.</td>
180       </tr>
181     </tbody></table></p>
182
183
184     <h4>The 'mode' byte</h4>
185     
186     <p>
187       Specific GPS sentences and bitrates may be selected by setting bits of
188       the 'mode' in the server configuration line:<br> &nbsp;&nbsp;<tt>server
189       127.127.20.x mode X</tt>
190     </p>
191
192     <table border="1">
193       <caption>mode byte bits and bit groups</caption>
194       <tbody><tr>
195         <th align="center">Bit</th>
196         <th align="center">Decimal</th>
197         <th align="center">Hex</th>
198         <th align="left">Meaning</th>
199       </tr>
200       
201       <tr>
202         <td align="center">0</td>
203         <td align="center">1</td>
204         <td align="center">1</td>
205         <td>process <tt>$GPMRC</tt></td>
206       </tr><tr>
207         <td align="center">1</td>
208         <td align="center">2</td>
209         <td align="center">2</td>
210         <td>process <tt>$GPGGA</tt></td>
211       </tr><tr>
212         <td align="center">2</td>
213         <td align="center">4</td>
214         <td align="center">4</td>
215         <td>process <tt>$GPGLL</tt></td>
216       </tr><tr>
217         <td align="center">3</td>
218         <td align="center">8</td>
219         <td align="center">8</td>
220         <td>process <tt>$GPZDA</tt> or <tt>$GPZDG</tt></td>
221       </tr><tr>
222         <td rowspan="6" align="center">4-6</td>
223         <td align="center">0</td>
224         <td align="center">0</td>
225         <td>linespeed 4800 bps</td>
226       </tr><tr>
227         <td align="center">16</td>
228         <td align="center">0x10</td>
229         <td>linespeed 9600 bps</td>
230       </tr><tr>
231         <td align="center">32</td>
232         <td align="center">0x20</td>
233         <td>linespeed 19200 bps</td>
234       </tr><tr>
235         <td align="center">48</td>
236         <td align="center">0x30</td>
237         <td>linespeed 38400 bps</td>
238       </tr><tr>
239         <td align="center">64</td>
240         <td align="center">0x40</td>
241         <td>linespeed 57600 bps</td>
242       </tr><tr>
243         <td align="center">80</td>
244         <td align="center">0x50</td>
245         <td>linespeed 115200 bps</td>
246       </tr><tr>
247         <td align="center">7</td>
248         <td align="center">128</td>
249         <td align="center">0x80</td>
250         <td>Write the sub-second fraction of the receive time stamp to the
251         clockstat file for all recognised NMEA sentences. This can be used to
252         get a useful value for fudge time2.<br><strong>Caveat:</strong> This
253         will fill your clockstat file rather fast. Use it only temporarily to
254         get the numbers for the NMEA sentence of your choice.</td>
255       </tr>
256       </tr><tr>
257         <td align="center">8</td>
258         <td align="center">256</td>
259         <td align="center">0x100</td>
260         <td>process <tt>$PGRMF</tt></td>
261       </tr><tr>
262         <td align="center">9-15</td>
263         <td align="center"></td>
264         <td align="center">0xFE00</td>
265         <td>reserved - leave 0</td>
266       </tr><tr>
267         <td align="center">16</td>
268         <td align="center">65536</td>
269         <td align="center">0x10000</td>
270         <td>Append extra statistics to the clockstats line.
271         Details below.</td>
272       </tr>
273     </tbody></table> 
274
275  
276     <p>
277       The default (mode 0) is to process all supported sentences at a linespeed
278       of 4800 bps, which results in the first one received and recognised in
279       each cycle being used.&nbsp; If only specific sentences should be
280       recognised, then the mode byte must be chosen to enable only the selected
281       ones.&nbsp; Multiple sentences may be selected by adding their mode bit
282       values, but of those enabled still only the first received sentence in a
283       cycle will be used.&nbsp; Using more than one sentence per cycle is
284       impossible, because
285       </p><ul>
286         <li>there is only <a href="#fudgetime2">fudge time2</a> available to
287           compensate for transmission delays but every sentence would need a
288           different one and
289         </li><li>using more than one sentence per cycle overstuffs the internal data
290           filters.
291       </li></ul>
292       The driver uses 4800 bits per second by default, but faster bitrates can
293       be selected using bits 4 to 6 of the mode field.
294     <p></p>
295
296     <p>
297       <strong>Caveat:</strong> Using higher line speeds does not necessarily
298       increase the precision of the timing device.&nbsp; Higher line speeds are
299       not necessarily helpful for the NMEA driver, either.&nbsp; They can be
300       used to accomodate for an amount of data that does not fit into a
301       1-second cycle at 4800 bps, but high-speed high-volume NMEA data is likely
302       to cause trouble with the serial line driver since NMEA supports no
303       protocol handshake.&nbsp; Any device that is exclusively used for time
304       synchronisation purposes should be configured to transmit the relevant
305       data only, e.g. one <tt>$GPRMC</tt> or <tt>$GPZDA</tt> per second, at a
306       linespeed of 4800 bps or 9600 bps.
307     </p>
308
309     <h4>Monitor Data</h4>
310
311     <p>The last GPS sentence that is accepted or rejected is written to the
312     clockstats file and available with <code>ntpq -c clockvar</code>.
313     (Logging the rejected sentences lets you see/debug why they were rejected.)
314     Filtered sentences are not logged.</p>
315
316     <p>
317       If the 0x10000 mode bit is on and clockstats is enabled, several extra
318       counters will be appended to the NMEA sentence that gets logged.
319       For example:
320 <pre>
321 56299 76876.691 127.127.20.20 $GPGGA,212116.000,3726.0785,N,12212.2605,W,1,05,2.0,17.0,M,-25.7,M,,0000*5C  228 64 0 0 64 0
322 </pre>
323     </p>
324
325     <table border="1">
326       <caption>Clockstats</caption>
327       <tbody><tr>
328         <th align="center">Column</th>
329         <th align="center">Sample</th>
330         <th align="left">Meaning</th>
331       </tr>
332       
333       <tr>
334         <td align="center">1</td>
335         <td align="center">56299</td>
336         <td>MJD</td>
337       </tr><tr>
338         <td align="center">2</td>
339         <td align="center">76876.691</td>
340         <td>Time of day in seconds</td>
341       </tr><tr>
342         <td align="center">3</td>
343         <td align="center">127.127.20.20</td>
344         <td>IP Address from server config line</td>
345       </tr><tr>
346         <td align="center">4</td>
347         <td align="center">$GPGGA,...0*5C</td>
348         <td>NMEA Sentence</td>
349       </tr><tr>
350         <td align="center">5</td>
351         <td align="center">228</td>
352         <td>Number of sentences received</td>
353       </tr><tr>
354         <td align="center">6</td>
355         <td align="center">64</td>
356         <td>Number of sentences accepted and used for timekeeping</td>
357       </tr><tr>
358         <td align="center">7</td>
359         <td align="center">0</td>
360         <td>Number of sentences rejected because they were marked invalid (poor signal)</td>
361       </tr><tr>
362         <td align="center">8</td>
363         <td align="center">0</td>
364         <td>Number of sentences rejected because of bad checksum or invalid date/time</td>
365       </tr><tr>
366         <td align="center">9</td>
367         <td align="center">64</td>
368         <td>Number of sentences filtered by mode bits or same second</td>
369       </tr><tr>
370         <td align="center">10</td>
371         <td align="center">0</td>
372         <td>Number of PPS pulses used, overrides NMEA sentences</td>
373       </tr>
374     </tbody></table>
375
376     Sentences like $GPGSV that don't contain the time will get
377     counted in the total but otherwise ignored.
378
379     <p>
380       <a href="https://support.ntp.org/bin/view/Support/ConfiguringNMEARefclocks">Configuring
381       NMEA Refclocks</a> might give further useful hints for specific hardware
382       devices that exhibit strange or curious behaviour.
383     </p>
384
385     <p>
386       To make a specific setting, select the corresponding decimal values from
387       the mode byte table, add them all together and enter the resulting
388       decimal value into the clock configuration line.
389     </p>
390
391     <h4>Setting up the Garmin GPS-25XL</h4>
392
393     Switch off all output with by sending it the following string.
394     <pre>"$PGRMO,,2&lt;cr&gt;&lt;lf&gt;"</pre>
395     <p>Now switch only $GPRMC on by sending it the following string.</p>
396     <pre>"$PGRMO,GPRMC,1&lt;cr&gt;&lt;lf&gt;"</pre>
397
398     <p>On some systems the PPS signal isn't switched on by default. It can be
399     switched on by sending the following string.</p>
400     <pre>"$PGRMC,,,,,,,,,,,,2&lt;cr&gt;&lt;lf&gt;"</pre>
401
402     <h4>Fudge Factors</h4>
403
404     <dl>
405       <dt><tt>time1 <i>time</i></tt></dt>
406       <dd>Specifies the PPS time offset calibration factor, in seconds and fraction, with default 0.0.</dd>
407       <dt><a name="fudgetime2"><tt>time2 <i>time</i></tt></a></dt>
408       <dd>Specifies the serial end of line time offset calibration factor, in seconds and fraction, with default
409         0.0.</dd>
410       <dt><tt>stratum <i>number</i></tt></dt>
411       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.</dd>
412       <dt><tt>refid <i>string</i></tt></dt>
413       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with
414         default <tt>GPS</tt>.</dd>
415       <dt><tt>flag1 0 | 1</tt></dt>
416       <dd>Disable PPS signal processing if 0 (default); enable PPS signal processing if 1.</dd>
417       <dt><tt>flag2 0 | 1</tt></dt>
418       <dd>If PPS signal processing is enabled, capture the pulse on the rising edge if 0 (default); capture on the
419         falling edge if 1.</dd>
420       <dt><tt>flag3 0 | 1</tt></dt>
421       <dd>If PPS signal processing is enabled, use the <tt>ntpd</tt> clock discipline if 0 (default); use the kernel
422         discipline if 1.</dd>
423       <dt><tt>flag4 0 | 1</tt></dt>
424       <dd>Obscures location in timecode: 0 for disable (default), 1 for enable.</dd>
425     </dl>
426
427     <p>Additional Information</p>
428     <p><tt>flag1</tt>, <tt>flag2</tt>, and <tt>flag3</tt> are ignored under Windows.</p>
429     <p><a href="../refclock.html">Reference Clock Drivers</a></p>
430     <hr>
431     <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
432   </body></html>