Commit 499a7443 authored by Eric S. Raymond's avatar Eric S. Raymond

Implement and document path and ppspath options.

While we're at it, give almost all drivers the same baud-rate override option
previousl implemented for NMEA only.
parent ed0d2e93
......@@ -153,8 +153,12 @@ with the Hayes connection and hang-up commands and result codes.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -121,8 +121,12 @@ over the last 16 seconds.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -60,8 +60,12 @@ written as-is to the +clockstats+ file.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Examples ==
......
......@@ -393,8 +393,12 @@ alarms are nonfatal; only the data in the burst are discarded.
Not used by this driver.
+mode+::
Select ICOM mode and device speed.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -34,7 +34,33 @@ L - \n (newline)
== Driver Options ==
This driver does not interpret fudges, option flags, or the mode.
+time1+ 'time'::
Not used by this driver.
+time2+ 'time'::
Not used by this driver.
+stratum+ 'number'::
Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+refid+ 'string'::
Specifies the driver reference identifier, an ASCII string from one to
four characters, with default +DUMB+.
+flag1 {0 | 1}+::
Not used by this driver.
+flag2 {0 | 1}+::
Not used by this driver.
+flag3 {0 | 1}+::
Not used by this driver.
+flag4 {0 | 1}+::
Not used by this driver.
+subtype+::
Not used by this driver.
+mode+::
Enable verbose +clockstats+ recording if set.
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -461,8 +461,12 @@ screen width and looks similar to:
Used to select the device type and serial parameters.
+mode+::
Synonym for subtype, retained for backward compatibility.
+baud+::
Not used by this driver.
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Overrides the default PPS-device path.
+baud+ 'number'::
Not used by this driver. Baud rate is implied by the selected mode.
== Configuration Examples ==
......
......@@ -222,7 +222,11 @@ since the last poll.
Control IBT and strict operating modes.
+mode+::
Synonym for subtype, retained for backward compatibility.
+baud+::
+path+ 'filename'::
Not used by this driver.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Not used by this driver.
[[fn1]]link:#fn1bl[^1^)]Data transmission and decoding is done only once by the
......
......@@ -89,8 +89,12 @@ http://www.symmetricom.com/[Symmetricom].
Setting mode 1 configures for the HP Z3801A.
+mode+::
Synonym for subtype, retained for backward compatibility.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -196,8 +196,12 @@ The error flags are defined as follows in hex:
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -388,8 +388,12 @@ filegen clockstats file clockstats type day enable
Used to select a device type and serial parameters.
+mode+::
Synonym for subtype, retained for backward compatibility.
+baud+::
+path+ 'filename'::
Not used by this driver.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Not used by this driver. The subtype implies the baud rate.
== Configuration Examples ==
......
......@@ -70,8 +70,12 @@ running correctly.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -60,7 +60,11 @@ No +filegen clockstats+ monitor data are produced by this driver.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Not used by this driver.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Not used by this driver.
== Configuration Example ==
......
......@@ -75,8 +75,12 @@ Format].
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -69,9 +69,15 @@ Default setting is 0 = don't log received data and converted utc time.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
----------------------------------------------------------------------------
......
......@@ -240,8 +240,12 @@ switched on by sending the following string.
Not used by this driver.
+mode+::
Used to control GPS sentence selection and logging.
+baud+::
Used to set the baud rate used to talk to the GPS.
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Overrides the default PPS-device path.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -80,8 +80,12 @@ specific receiver in use will be required.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
Not used by this driver.
+path+::
Not used by this driver.
+ppspath+::
Not used by this driver.
+baud+ 'number'::
Not used by this driver.
== Configuration Example ==
......
......@@ -244,9 +244,16 @@ link:#refid[+refid string+]::
+mode+ 'number'::
Synonym for subtype, retained for backward compatibility.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
----------------------------------------------------------------------------
......
......@@ -119,8 +119,12 @@ synchronization without needing the Internet at all.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
Not used by this driver.
+path+::
Not used by this driver.
+ppspath+::
Overrides the default PPS device path.
+baud+ 'number'::
Not used by this driver.
== Configuration Example ==
......
......@@ -182,7 +182,11 @@ for the specific unit.
Not used by this driver.
+mode+::
Can be used to set private mode
+baud+::
+path+ 'filename'::
Not used by this driver.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Not used by this driver.
== Configuration Example ==
......
......@@ -107,12 +107,16 @@ received.
if 0 (default); use the kernel discipline if 1.
+flag4 {0 | 1}+::
Enable verbose +clockstats+ recording if set.
+mode+::
+subtype+::
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -121,8 +121,12 @@ written as-is to the +clockstats+ file.
Not used by this driver.
+mode+::
Not used by this driver.
+baud+::
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
......@@ -25,7 +25,33 @@ link:refclock.html[Reference Clock Drivers]
== Driver Options ==
This driver does not interpret any fudges, option bits, or the mode.
+time1+ 'time'::
Not used by this driver.
+time2+ 'time'::
Not used by this driver.
+stratum+ 'number'::
Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+refid+ 'string'::
Specifies the driver reference identifier, an ASCII string from one to
four characters, with default +GPS+.
+flag1 {0 | 1}+::
Not used by this driver.
+flag2 {0 | 1}+::
Not used by this driver.
+flag3 {0 | 1}+::
Not used by this driver.
+flag4 {0 | 1}+::
Not used by this driver.
+subtype+::
Not used by this driver.
+mode+::
Not used by this driver.
+path+ 'filename'::
Overrides the default device path.
+ppspath+ 'filename'::
Not used by this driver.
+baud+ 'number'::
Overrides the default baud rate.
== Configuration Example ==
......
// Options for refclocks. Included twice.
+refclock+ _drivername_ [+unit+ _u_] [+prefer+] [+subtype+ _int_] [+mode+ _int_] [+minpoll+ _int_] [+maxpoll+ _int_] [+time1+ _sec_] [+time2+ _sec_] [+stratum+ _int_] [+refid+ _string_] [+flag1+ {+0+ | +1+}] [+flag2+ {+0+ | +1+}] [+flag3+ {+0+ | +1+}] [+flag4+ {+0+ | +1+}]::
+refclock+ _drivername_ [+unit+ _u_] [+prefer+] [+subtype+ _int_] [+mode+ _int_] [+minpoll+ _int_] [+maxpoll+ _int_] [+time1+ _sec_] [+time2+ _sec_] [+stratum+ _int_] [+refid+ _string_] [+path+ 'filename'] [+ppspath+ 'filename'] [+baud+ 'number'] [+flag1+ {+0+ | +1+}] [+flag2+ {+0+ | +1+}] [+flag3+ {+0+ | +1+}] [+flag4+ {+0+ | +1+}]::
This command is used to configure reference clocks.
The required _drivername_ argument is the shortname of a driver type
(e.g. +shm+, +nmea+, +generic+; see the "Reference Clock Drivers"
......@@ -61,6 +61,12 @@
defines the reference identifier used by the driver. This string
overrides the default identifier ordinarily assigned by the driver
itself.
+path+ _filepath_;;
Overrides the default device location for this refclock.
+ppspath+ _filepath_;;
Overrides the default PPS device location (if any) for this diver.
+baud+ 'number';;
Overrides the defaults baud rate for this driver.
+flag1+ +{0 | 1}+; +flag2+ +{0 | 1}+; +flag3+ +{0 | 1}+; +flag4+ +{0 | 1}+;;
These four flags are used for customizing the clock driver. The
interpretation of these values, and whether they are used at all, is
......
......@@ -171,6 +171,10 @@ few will be user-visible.
built in a strict NTP Classic compatibility mode that restores the
old 4800bps default.
* Most refclock drivers now support configuration options to override the
default device path, the default PPS device path (if any) and the
serial baud rate.
* The -!m, ->, and -< options of some Classic commands are not
supported. (The argument-parsing framework code that implemented
them in Classic was overcomplicated and buggy and had to be removed.)
......
......@@ -272,6 +272,8 @@ struct peer {
*/
#ifdef REFCLOCK
struct refclockproc *procptr; /* refclock structure pointer */
char * path; /* override path if non-NULL */
char * ppspath; /* override PPS device path if non-NULL */
uint32_t baud; /* baud rate to initialize driver with */
bool is_pps_driver; /* is this the PPS driver? */
uint8_t refclkunit; /* reference clock unit number */
......
......@@ -104,6 +104,8 @@ struct peer_ctl {
uint32_t ttl;
keyid_t peerkey;
uint32_t baud;
char *path;
char *ppspath;
};
typedef struct peer_node_tag peer_node;
......
......@@ -46,10 +46,12 @@ struct key_tok ntp_keywords[] = {
{ "manycastserver", T_Manycastserver, FOLLBY_STRINGS_TO_EOC },
{ "mem", T_Mem, FOLLBY_TOKEN },
{ "multicastclient", T_Multicastclient, FOLLBY_STRINGS_TO_EOC },
{ "path", T_Path, FOLLBY_STRING },
{ "peer", T_Peer, FOLLBY_STRING },
{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC },
{ "pidfile", T_Pidfile, FOLLBY_STRING },
{ "pool", T_Pool, FOLLBY_STRING },
{ "ppspath", T_Ppspath, FOLLBY_STRING },
{ "discard", T_Discard, FOLLBY_TOKEN },
{ "reset", T_Reset, FOLLBY_TOKEN },
{ "restrict", T_Restrict, FOLLBY_TOKEN },
......
......@@ -776,6 +776,14 @@ create_peer_node(
}
break;
case T_Path:
my_node->ctl.path = estrdup(option->value.s);
break;
case T_Ppspath:
my_node->ctl.ppspath = estrdup(option->value.s);
break;
#ifdef REFCLOCK
case T_Baud:
my_node->ctl.baud = option->value.u;
......@@ -3273,6 +3281,8 @@ config_peers(
clktype = (uint8_t)REFCLOCKTYPE(&peer->srcadr);
unit = REFCLOCKUNIT(&peer->srcadr);
peer->path = curr_peer->ctl.path;
peer->ppspath = curr_peer->ctl.ppspath;
peer->baud = curr_peer->ctl.baud;
if (refclock_newpeer(clktype,
unit,
......
......@@ -187,12 +187,14 @@
%token <Integer> T_Orphan
%token <Integer> T_Orphanwait
%token <Integer> T_Panic
%token <Integer> T_Path
%token <Integer> T_Peer
%token <Integer> T_Peerstats
%token <Integer> T_Phone
%token <Integer> T_Pid
%token <Integer> T_Pidfile
%token <Integer> T_Pool
%token <Integer> T_Ppspath
%token <Integer> T_Port
%token <Integer> T_Preempt
%token <Integer> T_Prefer
......@@ -518,6 +520,10 @@ option_boolean
option_string
: T_Refid T_String
{ $$ = create_attr_sval($1, $2); }
| T_Path T_String
{ $$ = create_attr_sval($1, $2); }
| T_Ppspath T_String
{ $$ = create_attr_sval($1, $2); }
;
option_double_keyword
......
......@@ -508,10 +508,10 @@ acts_timeout(
/*
* Open the device in raw mode and link the I/O.
*/
snprintf(device, sizeof(device), DEVICE,
up->unit);
fd = refclock_open(device, SPEED232, LDISC_ACTS |
LDISC_RAW | LDISC_REMOTE);
snprintf(device, sizeof(device), DEVICE, up->unit);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232,
LDISC_ACTS | LDISC_RAW | LDISC_REMOTE);
if (fd < 0) {
msyslog(LOG_ERR, "acts: open fails %m");
return;
......
......@@ -148,7 +148,8 @@ arb_start(
* Open serial port. Use CLK line discipline, if available.
*/
snprintf(device, sizeof(device), DEVICE, unit);
fd = refclock_open(device, SPEED232, LDISC_CLK);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232, LDISC_CLK);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -152,7 +152,9 @@ as2201_start(
* Open serial port. Use CLK line discipline, if available.
*/
snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
fd = refclock_open(gpsdev, SPEED232, LDISC_CLK);
fd = refclock_open(peer->path ? peer->path : gpsdev,
peer->baud ? peer->baud : SPEED232,
LDISC_CLK);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -475,7 +475,8 @@ chu_start(
/*
* Open audio device. Don't complain if not there.
*/
fd_audio = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit);
fd_audio = audio_init(peer->path ? peer->path : DEVICE_AUDIO,
AUDIO_BUFSIZ, unit);
#ifdef DEBUG
if (fd_audio >= 0 && debug)
......@@ -489,7 +490,9 @@ chu_start(
fd = fd_audio;
} else {
snprintf(device, sizeof(device), DEVICE, unit);
fd = refclock_open(device, SPEED232, LDISC_RAW);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232,
LDISC_RAW);
}
#else /* ENABLE_CHU_AUDIO */
......
......@@ -100,11 +100,9 @@ dumbclock_start(
* it's not available.
*/
snprintf(device, sizeof(device), DEVICE, unit);
#ifdef DEBUG
if (debug)
printf ("starting Dumbclock with device %s\n",device);
#endif
fd = refclock_open(device, SPEED232, 0);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232,
0);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -2560,7 +2560,8 @@ parse_start(
(void) snprintf(parsedev, sizeof(parsedev), PARSEDEVICE, unit);
(void) snprintf(parseppsdev, sizeof(parsedev), PARSEPPSDEVICE, unit);
fd232 = tty_open(parsedev, O_RDWR | O_NOCTTY | O_NONBLOCK, 0777);
fd232 = tty_open(peer->path ? peer->path : parsedev,
O_RDWR | O_NOCTTY | O_NONBLOCK, 0777);
if (fd232 == -1)
{
......
......@@ -152,7 +152,8 @@ hpgps_start(
register struct hpgpsunit *up;
struct refclockproc *pp;
int fd;
int speed, ldisc;
int ldisc;
unsigned int speed;
char device[20];
/*
......@@ -167,7 +168,8 @@ hpgps_start(
ldisc |= LDISC_7O1;
speed = SPEED232Z;
}
fd = refclock_open(device, speed, ldisc);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : speed, ldisc);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -319,7 +319,8 @@ irig_start(
/*
* Open audio device
*/
fd = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit);
fd = audio_init(peer->path ? peer->path : DEVICE_AUDIO,
AUDIO_BUFSIZ, unit);
if (fd < 0)
return false;
#ifdef DEBUG
......
......@@ -403,7 +403,9 @@ jupiter_start(
* Open serial port
*/
snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
fd = refclock_open(peer->path ? peer->path : gpsdev,
peer->baud ? peer->baud : SPEED232,
LDISC_RAW);
if (fd <= 0) {
jupiter_debug(peer, "jupiter_start", "open %s: %m",
gpsdev);
......
......@@ -185,7 +185,9 @@ mx4200_start(
* Open serial port
*/
snprintf(gpsdev, sizeof(gpsdev), DEVICE, unit);
fd = refclock_open(gpsdev, SPEED232, LDISC_PPS);
fd = refclock_open(peer->path ? peer->path : gpsdev,
peer->baud ? peer->baud : SPEED232,
LDISC_PPS);
if (fd < 0)
return false;
......
......@@ -142,7 +142,9 @@ neoclock4x_start(int unit,
/* LDISC_STD, LDISC_RAW
* Open serial port. Use CLK line discipline, if available.
*/
fd = refclock_open(dev, B2400, LDISC_STD);
fd = refclock_open(peer->path ? peer->path : dev,
peer->baud ? peer->baud : B2400,
LDISC_STD);
if(fd <= 0)
{
/* coverity[leaked_handle] */
......
......@@ -398,9 +398,8 @@ nmea_start(
struct refclockproc * const pp = peer->procptr;
nmea_unit * const up = emalloc_zero(sizeof(*up));
char device[20];
size_t devlen;
uint32_t rate;
int baudrate;
uint32_t rate;
unsigned int baudrate;
const char * baudtext;
......@@ -475,13 +474,10 @@ nmea_start(
peer->sstclktype = CTL_SST_TS_UHF;
/* Open serial port. Use CLK line discipline, if available. */
devlen = snprintf(device, sizeof(device), DEVICE, unit);
if (devlen >= sizeof(device)) {
msyslog(LOG_ERR, "%s clock device name too long",
refclock_name(peer));
return false; /* buffer overflow */
}
pp->io.fd = refclock_open(device, baudrate, LDISC_CLK);
snprintf(device, sizeof(device), DEVICE, unit);
pp->io.fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : baudrate,
LDISC_CLK);
if (0 >= pp->io.fd) {
pp->io.fd = nmead_open(device);
if (-1 == pp->io.fd)
......@@ -566,8 +562,8 @@ nmea_control(
up->ppsapi_tried = true;
devlen = snprintf(device, sizeof(device), PPSDEV, unit);
if (devlen < sizeof(device)) {
up->ppsapi_fd = open(device, PPSOPENMODE,
S_IRUSR | S_IWUSR);
up->ppsapi_fd = open(peer->ppspath ? peer->ppspath : device,
PPSOPENMODE, S_IRUSR | S_IWUSR);
} else {
up->ppsapi_fd = -1;
msyslog(LOG_ERR, "%s PPS device name too long",
......
......@@ -402,7 +402,9 @@ palisade_start (
/*
* Open serial port.
*/
fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
fd = refclock_open(peer->path ? peer->path : gpsdev,
peer->baud ? peer->baud : SPEED232,
LDISC_RAW);
if (fd <= 0) {
#ifdef DEBUG
printf("Palisade(%d) start: open %s failed\n", unit, gpsdev);
......
......@@ -145,10 +145,11 @@ pps_start(
* not necessarily the port used for the associated radio.
*/
snprintf(device, sizeof(device), DEVICE, unit);
up->fddev = tty_open(device, O_RDWR, 0777);
up->fddev = tty_open(peer->ppspath ? peer->ppspath : device,
O_RDWR, 0777);
if (up->fddev <= 0) {
msyslog(LOG_ERR,
"refclock_pps: %s: %m", device);
"refclock_pps: %m");
return false;
}
......
......@@ -172,7 +172,9 @@ spectracom_start(
* Open serial port. Use CLK line discipline, if available.
*/
snprintf(device, sizeof(device), DEVICE, unit);
fd = refclock_open(device, SPEED232, LDISC_CLK);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232,
LDISC_CLK);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -232,7 +232,8 @@ true_start(
* Open serial port
*/
snprintf(device, sizeof(device), DEVICE, unit);
fd = refclock_open(device, SPEED232, LDISC_CLK);
fd = refclock_open(peer->path ? peer->path : device,
peer->baud ? peer->baud : SPEED232, LDISC_CLK);
if (fd <= 0)
/* coverity[leaked_handle] */
return false;
......
......@@ -128,12 +128,14 @@ zyfer_start(
* Something like LDISC_ACTS that looked for ! would be nice...