option-tester: Add many changes
[ntpsec.git] / docs / driver_generic.adoc
blobd1f7aa9052aed7c76e485cf8d97af66cd6e46154
1 = Generic Reference Driver
2 include::include-html.ad[]
4 == Name
6 refclock_generic - multidevice parse driver for generic time radios and GPSDOs.
8 == Synopsis
10 ["verse",subs="normal"]
11 Name: generic
12 Reference ID: DCF | DCFa | DCFp | GPS | MSF
13 Serial Port: /dev/refclock-'u'; TTY mode according to clock type
14 PPS device: /dev/refclockpps-'u'; alternate PPS device
16 == Warning
18 Most modes of this driver report only two-digit years, and are thus
19 reliant on the system clock to be near correct before samples will be
20 processed properly. You will not be able to use these modes to run
21 autonomously, nor will they reliably recover from a trashed or zeroed
22 system clock.  The only exceptions are the Schweitzer 240x and the
23 Trimble TAIP/TSIP modes.
25 == Description
27 The generic driver supports many different clock
28 types/configurations by plugging type-specific packet-parsing
29 routines into a generic driver framework.
31 Note that some of these subtypes below are to support equipment that
32 has not been commercially available for a long time, report only
33 2-digit years (thus being subject to lingering Y2K problems and
34 possible future issues near century boundaries), and may be removed in
35 a future release.  See
36 https://www.ntpsec.org/removal-plan.html[Feature removals] for a
37 discussion of this issue.
39 The actual receiver status is mapped into various synchronization states
40 generally used by receivers. The driver is configured to interpret the
41 time codes of Meinberg DCF77 AM receivers, DCF77 FM receivers, Meinberg
42 GPS16x/17x receivers, Trimble SV6 GPS, ELV DCF7000, Schmid, Wharton 400A
43 and various low-cost receivers.
45 The reference clock support in NTP contains the necessary configuration
46 tables for those receivers. In addition to supporting several different
47 clock types and multiple devices, the processing of a PPS signal is also
48 provided as a configuration option. The PPS configuration option uses
49 the receiver-generated time stamps for feeding the PPS loopfilter
50 control for much finer clock synchronization.
52 CAUTION: The PPS configuration option is different from the hardware PPS
53 signal, which is also supported (see below), as it controls the way ntpd
54 is synchronized to the reference clock, while the hardware PPS signal
55 controls the way time offsets are determined.
57 The use of the PPS option requires receivers with an accuracy of better
58 than 1ms.
60 == Timecode variables listed by {ntpqman}
62 The ntpq program can read and display several clock variables. These
63 hold the following information:
65 refclock_format::
66   A qualification of the decoded time code format.
67 refclock_states::
68   The overall running time and the accumulated times for the clock event
69   states.
70 refclock_status::
71   Lists the currently active receiver flags. Additional feature flags
72   for the receiver are optionally listed in parentheses.
73 refclock_time::
74   The local time with the offset to UTC (format HHMM).
75 timecode::
76   The actual time code.
78 If PPS information is present, additional variables are available:
80 refclock_ppsskew::
81   The difference between the RS-232-derived timestamp and the PPS
82   timestamp.
83 refclock_ppstime::
84   The PPS timestamp.
86 == Supported Devices
88 Twenty-five clock types are supported by the GENERIC driver
89 and any number of these clocks may be operational at any one time.
91 Note: Under NTPsec, you _must_ use the new configuration syntax
92 (refclock generic subtype N) to declare generic clocks, rather than
93 the old-style syntax with a magic address, unless the software has
94 been built with the +--enable-classic-mode+ option in which case *only*
95 the old-style syntax will work.
97 A note on the implementations:
99 * These implementations were mainly done without actual access to the
100 hardware, thus not all implementations provide full support. The
101 development was done with the help of many kind souls who had the
102 hardware and kindly lent me their time and patience during the
103 development and debugging cycle. Thus for continued support and quality,
104 direct access to the receivers is a big help. Nevertheless I am not
105 prepared to buy these reference clocks - donations to
106 (mailto:kardel@ntp.org[kardel@ntp.org]) are welcome as
107 long as they work within Europe 8-).
109 The pictures below have been archived from the vendors' web pages.
111 Verified implementations are:
113 * *RAWDCF variants*
115 These variants have been tested for correct decoding with my own
116 homegrown receivers. Interfacing with specific commercial products may
117 involve some fiddling with cables. In particular, commercial RAWDCF
118 receivers have a seemingly unlimited number of ways to draw power from
119 the RS-232 port and to encode the DCF77 datastream. You are mainly on
120 your own here unless I have a sample of the receiver.
122 * * https://www.meinberg.de[Meinberg clocks] *
124 These implementations have been verified by the Meinberg people
125 themselves and I have access to one of these clocks.
128 * https://selinc.com[Schweitzer Engineering Laboratories SEL-240x clocks] *
130 This implementation was provided and verified by SEL and
131 https://www.nwtime.org/[Network Time Foundation] has an
132 SEL-2407 in one of its development labs.
134 * *refclock generic subtype 0*
136 *https://www.meinberg.de[Meinberg] https://www.meinbergglobal.com/english/archive/pzf511.htm[PZF5xx receiver family] (FM demodulation/TCXO / 50μs)*
138 WARNING: This equipment is no longer available for commercial sale, and
139 support may be removed in the future.  See:
140 https://www.ntpsec.org/removal-plan.html[Feature removals]
142 * *refclock generic subtype 1*
144 *https://www.meinberg.de[Meinberg] https://www.meinbergglobal.com/english/archive/pzf511.htm[PZF5xx receiver family] (FM demodulation/OCXO / 50μs)*
146 WARNING: This equipment is no longer available for commercial sale, and
147 support may be removed in the future.  See:
148 https://www.ntpsec.org/removal-plan.html[Feature removals]
150 image::pic/pzf511.jpg[https://www.meinberg.de/english/products/pzf-eurocard.htm]
152 * *refclock generic subtype 2*
154 *https://www.meinberg.de[Meinberg] https://www.meinbergglobal.com/english/archive/c51.htm[DCF C51 receiver and similar] (AM demodulation / 4ms)*
156 image:pic/c51.jpg[https://www.meinberg.de/english/products/c51.htm]
158 This subtype expects the Meinberg standard time string format with 9600/7E2.
160 *Note:* subtype 2 must also be used for
161 https://www.meinberg.de/english/products/formfactor.htm#slot_card[Meinberg
162 PCI cards] under Linux, e.g.
163 https://www.meinberg.de/english/products/gps-pcicard.htm[the GPS PCI
164 card] or https://www.meinberg.de/english/products/dcf-pcicard.htm[the
165 DCF77 PCI card]. Please note the
166 https://www.meinberg.de/english/sw/#linux[Meinberg Linux driver] must be
167 installed. That driver emulates a refclock device in order to allow ntpd
168 to access those cards. For details, please refer to the README file
169 that comes with the Meinberg driver package.
171 * *refclock generic subtype 3*
173 https://www.elv.de/[ELV] *DCF7000 (sloppy AM demodulation / 50ms)*
175 WARNING: This equipment is no longer available for commercial sale, and
176 support may be removed in the future.  See:
177 https://www.ntpsec.org/removal-plan.html[Feature removals]
179 * *refclock generic subtype 4*
181 *Walter Schmid DCF receiver Kit (AM demodulation / 1ms)*
183 WARNING: This equipment is no longer available for commercial sale, and
184 support may be removed in the future.  See:
185 https://www.ntpsec.org/removal-plan.html[Feature removals]
187 * *refclock generic subtype 5*
189 *RAW DCF77 100/200ms pulses (Conrad DCF77 receiver module / 5ms)*
191 * *refclock generic subtype 6*
193 *RAW DCF77 100/200ms pulses (TimeBrick DCF77 receiver module / 5ms)*
195 * *refclock generic subtype 7*
197 * https://www.meinberg.de[Meinberg] https://www.meinberg.de/english/products/timesource.htm#gps---freq_sync[GPS16x/GPS17x receivers] (GPS / <<1&mu;s) *
199 image:pic/gps167.jpg[https://www.meinberg.de/english/products/gps-eurocard.htm]
201 This subtype expects either the University of Erlangen time string format
202 or the Meinberg standard time string format at 19200/8N1.
204 The University of Erlangen format is preferred. Newer Meinberg GPS
205 receivers can be configured to transmit that format; for older devices,
206 a special firmware version may be available.
208 In this subtype some additional GPS receiver status information is also
209 read. However, this requires a point-to-point connection.
210 xref:subtype18[Subtype 18] should be used if the device is accessed by a multidrop connection.
212 *Note:* subtype 7 must not be used with Meinberg PCI cards; use subtype 2 instead.
214 * *refclock generic subtype 8*
216 https://www.igel.de/[IGEL] https://www.igel.de/eigelmn.html[clock]
218 image:pic/igclock.gif[https://www.igel.de/eigelmn.html]
220 * *refclock generic subtype 9*
222 *https://www.trimble.com[Trimble] ftp://ftp.trimble.com/pub/sct/embedded/bin/Data%20Sheets/SveeSix2.PDF[SVeeSix GPS receiver] TAIP protocol (GPS / <<1&mu;s)*
224 WARNING: This equipment is no longer available for commercial sale, and
225 support may be removed in the future.  See:
226 https://www.ntpsec.org/removal-plan.html[Feature removals]
228 * *refclock generic subtype 10*
230 *https://www.trimble.com[Trimble] ftp://ftp.trimble.com/pub/sct/embedded/bin/Data%20Sheets/SveeSix2.PDF[SVeeSix GPS receiver] TSIP protocol (GPS / <<1&mu;s) (no kernel support yet)*
232 WARNING: This equipment is no longer available for commercial sale, and
233 support may be removed in the future.  See:
234 https://www.ntpsec.org/removal-plan.html[Feature removals]
236 image:pic/pd_om011.gif[https://www.trimble.com/cgi/omprod.cgi/pd_om011.html]
238 image:pic/pd_om006.gif[https://www.trimble.com/cgi/omprod.cgi/pd_om006.html]
240 * *refclock generic subtype 11*
242 *Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support*
244 * *refclock generic subtype 12*
246 *https://www.hopf-time.com[HOPF] https://www.hopf.com/downloads/manuals/6021gps_v0601_en.pdf[Funkuhr 6021]*
248 image:pic/fg6021.gif[https://www.hopf-time.com/engl/kart6021.html]
250 * *refclock generic subtype 13*
252 *Diem's Computime Radio Clock*
254 * *refclock generic subtype 14*
256 *RAWDCF receiver (DTR=high/RTS=low)*
258 * *refclock generic subtype 15*
260 *WHARTON 400A Series Clocks with a 404.2 Serial Interface*
262 * *refclock generic subtype 16*
264 *RAWDCF receiver (DTR=low/RTS=high)*
266 * *refclock generic subtype 17*
268 *VARITEXT Receiver (MSF)*
270 * [[subtype18]]*refclock generic subtype 18*
272 *https://www.meinberg.de[Meinberg] https://www.meinberg.de/english/products/timesource.htm#gps---freq_sync[GPS16x/GPS17x receivers] (GPS / <<1&mu;s)*
274 This subtype works without additional data communication (version, GPS
275 status etc.) and thus should be used with multidrop, heterogeneous
276 multiclient operation.
278 *Note:* subtype 18 must not be used with Meinberg PCI cards, use subtype 2
279 instead.
281 * *refclock generic subtype 19*
283 *Gude Analog- und Digitalsystem GmbH \'Expert mouseCLOCK USB v2.0'*
285 * *refclock generic subtype 20*
287 *RAWDCF receiver similar to subtype 14, but operating @ 75 baud (DTR=high/RTS=low)*
289 Driving the DCF clocks at 75 baud may help to get them to work with a
290 bunch of common USB serial converters, that do 75 but cannot do 50 baud
291 at all, e.g. those based on Prolific PL2303.
293 * *refclock generic subtype 21*
295 *RAWDCF receiver similar to subtype 16, but operating @ 75 baud (DTR=low/RTS=high)*
297 See comment from subtype 20 clock.
299 * *refclock generic subtype 22*
301 *MEINBERG, subtype 2 but with POWERUP trust*
303 * *refclock generic subtype 23*
305 *MEINBERG, subtype 7 but with POWERUP trust*
307 * *refclock generic subtype 24*
309 *https://selinc.com/[Schweitzer Engineering Laboratories]*
311 Actual data formats and setup requirements of the various clocks can be
312 found in link:parsedata.html[NTP GENERIC clock data formats].
314 == Operation
316 The reference clock support software carefully monitors the state
317 transitions of the receiver. All state changes and exceptional events
318 (such as loss of time code transmission) are logged via the syslog
319 facility. Every hour a summary of the accumulated times for the clock
320 states is listed via syslog.
322 PPS support is only available when the receiver is completely
323 synchronized. The receiver is believed to deliver correct time for an
324 additional period of time after losing synchronization, unless a
325 disruption in time code transmission is detected (possible power loss).
326 The trust period is dependent on the receiver oscillator and thus is a
327 function of clock type.
329 Raw DCF77 pulses can be fed via a level converter to the RXD pin of an
330 RS-232 serial port (pin 3 of a 25-pin connector or pin 2 of a 9-pin
331 connector). The telegrams are decoded and used for synchronization.
332 DCF77 AM receivers can be bought for as little as $25. The accuracy is
333 dependent on the receiver and is somewhere between 2 ms (expensive) and
334 10 ms (cheap). Synchronization ceases when reception of the DCF77 signal
335 deteriorates, since no backup oscillator is available as usually found
336 in other reference clock receivers. So it is important to have a good
337 place for the DCF77 antenna. During transmitter shutdowns you are out of
338 luck unless you have other NTP servers with alternate time sources
339 available.
341 In addition to the PPS loopfilter control, a true PPS hardware signal
342 can be utilized via the PPSAPI interface. PPS pulses are usually fed via
343 a level converter to the DCD pin of an RS-232 serial port (pin 8 of a
344 25-pin connector or pin 1 of a 9-pin connector), where one edge of the pulse
345 -- often the leading edge, but in many cases not -- provides the reference.
346 NTPsec uses the edge of the pulse specified by the driver for the particular
347 hardware used. To select PPS support, the subtype parameter is the subtype
348 value as above plus 128. If 128 is not added to the subtype value, PPS will
349 be detected to be available but will not be used.
351 == Hardware PPS support
353 For PPS to be used, add 128 to the subtype parameter.
355 If the PPS signal is fed in from a device different from the device
356 providing the serial communication (/dev/refclock-\{0..3}), this device
357 is configured as /dev/refclockpps-\{0..3}. This allows the PPS
358 information to be fed in e.g. via the parallel port (if supported by the
359 underlying operation system) and the date/time telegrams to be handled
360 via the serial port.
362 == Monitor Data
364 Clock state statistics are written hourly to the syslog
365 service. Online information can be found by examining the clock
366 variables via the ntpq cv command.
368 Some devices have quite extensive additional information
369 (GPS16x/GPS17x, Trimble). The driver reads out much of the internal GPS
370 data and makes it accessible via clock variables. To find out about
371 additional variable names, query for the clock_var_list variable on a
372 specific clock association as shown below.
374 First let ntpq display the table of associations:
376 -------------------------------------------------------------
377   ntpq> as
378   ind assID status  conf reach auth  condition last_event cnt
379   ===========================================================
380   1   19556  9154   yes   yes  none  falsetick  reachable  5
381   2   19557  9435   yes   yes  none  candidate clock expt  3
382   3   19558  9714   yes   yes  none   pps.peer  reachable  1
383 -------------------------------------------------------------
386 Then switch to raw output. This may be required because of display
387 limitations in ntpq/ntpd - so large lists need to be retrieved in
388 several queries.
390 ----------------------------------------
391   ntpq> raw
392   Output set to raw
393 ----------------------------------------
395 Use the cv command to read the list of clock variables of a selected
396 association:
398 ----------------------------------------
399   ntpq> cv 19557 clock_var_list
400 ----------------------------------------
402 The long output of the command above looks similar to:
404 ----------------------------------------
405   assID=19557 status=0x0000,
406   clock_var_list="type,timecode,poll,noreply,badformat,baddata,fudgetime1,
407   fudgetime2,stratum,refid,flags,device,clock_var_list,refclock_time,refclock_status,
408   refclock_format,refclock_states,refclock_id,refclock_iomode,refclock_driver_version,
409   meinberg_gps_status,gps_utc_correction,gps_message,meinberg_antenna_status,gps_tot_51,
410   gps_tot_63,gps_t0a,gps_cfg[1],gps_health[1],gps_cfg[2],gps_health[2],gps_cfg[3],
411   gps_health[3],gps_cfg[4],gps_health[4],gps_cfg[5]"
412 ----------------------------------------
414 Then use the cv command again to list selected clock variables. The
415 following command must be entered as a single line:
417 ----------------------------------------
418   ntpq> cv 19557 refclock_status,refclock_format,refclock_states,refclock_id,    refclock_iomode,refclock_driver_version,meinberg_gps_status,gps_utc_correction,    gps_message,meinberg_antenna_status,gps_tot_51,gps_tot_63,gps_t0a,gps_cfg[1],    gps_health[1],gps_cfg[2],gps_health[2],gps_cfg[3],gps_health[3],gps_cfg[4],    gps_health[4],gps_cfg[5]
419 ----------------------------------------
421 The output of the command above is wrapped around depending on the
422 screen width and looks similar to:
424 ----------------------------------------
425   status=0x0003,
426   refclock_status="UTC DISPLAY; TIME CODE; PPS; POSITION; (LEAP INDICATION;    PPS SIGNAL; POSITION)",
427   refclock_format="Meinberg GPS Extended",
428   refclock_states="*NOMINAL: 21:21:36 (99.99%); FAULT: 00:00:03 (0.00%);  running time: 21:21:39",
429   refclock_id="GPS", refclock_iomode="normal",
430   refclock_driver_version="refclock_parse.c,v 4.77 2006/08/05 07:44:49
431   kardel RELEASE_20060805_A",
432   meinberg_gps_status="[0x0000] <OK>",
433   gps_utc_correction="current correction 14 sec, last correction on c7619a00.00000000  Sun, Jan  1 2006  0:00:00.000",
434   gps_message="/PFU3SOP-4WG14EPU0V1KA",
435   meinberg_antenna_status="RECONNECTED on 2006-07-18 08:13:20.0000000
436   (+0000)    UTC CORR, LOCAL TIME, reconnect clockoffset +0.0000000 s,
437   disconnect time 0000-00-00 00:00:00.0000000 (+0000) ",
438   gps_tot_51="week 1400 + 3 days + 42300.0000000 sec",
439   gps_tot_63="week 1400 + 3 days + 42294.0000000 sec",
440   gps_t0a="week 1400 + 5 days + 71808.0000000 sec",
441   gps_cfg[1]="[0x9] BLOCK II", gps_health[1]="[0x0] OK;SIGNAL OK",
442   gps_cfg[2]="[0x0] BLOCK I", gps_health[2]="[0x3f] PARITY;MULTIPLE ERRS",
443   gps_cfg[3]="[0x9] BLOCK II", gps_health[3]="[0x0] OK;SIGNAL OK",
444   gps_cfg[4]="[0x9] BLOCK II", gps_health[6]="[0x0] OK;SIGNAL OK",
445   gps_cfg[5]="[0x9] BLOCK II"
446 ----------------------------------------
448 == Driver Options
450 +unit+ 'number'::
451   The driver unit number, defaulting to 0. Used as a distinguishing
452   suffix in the driver device name.
453 +time1+ _time_ ::
454   Specifies the time offset calibration factor, in seconds and fraction.
455   The default value depends on the clock type.
456 +time2+ _time_ ::
457   If flag1 is 0, time2 specifies the offset of the PPS signal from the
458   actual time (PPS fine tuning).  If flag1 is 1, time2 specifies the
459   number of seconds a receiver with a premium local oscillator can be
460   trusted after losing synchronisation.
461 +stratum+ _stratum_ ::
462   The stratum for this reference clock.
463 +refid+ _refid_ ::
464   The reference id for this reference clock.
466 +flag1 {0 | 1}+::
467   If 0, the fudge factor time2 refers to the PPS offset. +
468   If 1, time2 refers to the TRUST TIME.
469 +flag2 {0 | 1}+::
470   If flag2 is 1, sample PPS on CLEAR instead of on ASSERT.
471 +flag3 {0 | 1}+::
472   If flag3 is 1, link kernel PPS tracking to this refclock instance.
473 +flag4 {0 | 1}+::
474   Delete next leap second instead of adding it. (You'll need to wait a
475   bit for that to happen 8-)
476 +subtype+::
477   Used to select the device type and serial parameters.
478 +mode+::
479   Synonym for subtype, retained for backward compatibility.
480 +path+ 'filename'::
481   Overrides the default device path.
482 +ppspath+ 'filename'::
483   Overrides the default PPS-device path.
484 +baud+ 'number'::
485   Not used by this driver.  Baud rate is implied by the selected mode.
487 == Configuration Examples
489 See the examples above under "Supported devices"
491 == Making your own generic clocks
493 The generic clock mechanism deviates from the way other NTP reference
494 clocks work. For a short description of how to build generic reference
495 clocks, see link:generic_howto.html[making generic clocks].
497 Additional Information
499 link:refclock.html[Reference Clock Drivers]
501 '''''
503 include::includes/footer.adoc[]