* DECstation 5000/240 and Alpha AXP, additional kernel
* modifications provide a true microsecond clock and nanosecond
* clock, respectively.
+ *
+ * Important note: The kernel discipline is used only if the
+ * offset is less than 0.5 s, as anything higher can lead to
+ * overflow problems. This might occur if some misguided lad set
+ * the step threshold to something ridiculous. No problem; use
+ * the ntp discipline until the residual offset sinks beneath
+ * the waves.
*/
- if (pll_control && kern_enable) {
+ if (pll_control && kern_enable && fabs(clock_offset) < .5) {
/*
* We initialize the structure for the ntp_adjtime()
# endif
#endif /* TTYCLK */
-#ifdef HAVE_PPSCLOCK_H
-#include <sys/ppsclock.h>
-#endif /* HAVE_PPSCLOCK_H */
-
#ifdef KERNEL_PLL
#include "ntp_syscall.h"
#endif /* KERNEL_PLL */
#define MAXUNIT 4 /* max units */
#define FUDGEFAC .1 /* fudge correction factor */
-int fdpps; /* pps file descriptor */
-int cal_enable; /* enable refclock calibrate */
+#ifdef PPS
+int fdpps; /* ppsclock legacy */
+#endif /* PPS */
+int cal_enable; /* enable refclock calibrate */
/*
* Type/unit peer index. Used to find the peer structure for control and
msyslog(LOG_ERR, "refclock_open: %s: %m", dev);
return (0);
}
-
- /*
- * This little jewel lights up the PPS file descriptor if the
- * device name matches the name in the pps line in the
- * configuration file. This is so the atom driver can glom onto
- * the right device. Very silly.
- */
- if (strcmp(dev, pps_device) == 0)
- fdpps = fd;
+#ifdef PPS
+ fdpps = fd; /* ppsclock legacy */
+#endif /* PPS */
/*
* The following sections initialize the serial line port in
-
/*
* refclock_atom - clock driver for 1-pps signals
*/
pp->unitptr = (caddr_t)up;
/*
- * Open PPS device. If this fails and some driver has already
- * opened the associated radio device, fdpps has the file
- * descriptor for it.
+ * Open PPS device. This can be any serial or parallel port and
+ * not necessarily the port used for the associated radio.
*/
sprintf(device, DEVICE, unit);
up->fddev = open(device, O_RDWR, 0777);
- if (up->fddev <= 0 && fdpps > 0) {
- strcpy(device, pps_device);
- up->fddev = fdpps;
- }
if (up->fddev <= 0) {
msyslog(LOG_ERR,
"refclock_atom: %s: %m", device);
}
/*
- * Light off the PPSAPI interface. If this PPS device is shared
- * with the radio device, take the default options from the pps
- * command. This is for legacy purposes.
+ * Light off the PPSAPI interface.
*/
if (time_pps_create(up->fddev, &up->handle) < 0) {
msyslog(LOG_ERR,
up = (struct ppsunit *)pp->unitptr;
if (up->handle == 0)
return (-1);
+
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info,
&timeout) < 0)
return (-1);
+
if (up->pps_params.mode & PPS_CAPTUREASSERT) {
if (pps_info.assert_sequence ==
up->pps_info.assert_sequence)
return (1);
+
ts = up->pps_info.assert_timestamp;
} else if (up->pps_params.mode & PPS_CAPTURECLEAR) {
if (pps_info.clear_sequence ==
up->pps_info.clear_sequence)
return (1);
+
ts = up->pps_info.clear_timestamp;
} else {
return (-1);
peer = pps_peer;
if (peer == 0) /* nobody home */
return (1);
+
pp = peer->procptr;
/*
/*
* Valid time is returned only if the prefer peer has survived
- * the intersection algorithm and within clock_max of local time
+ * the intersection algorithm and within 0.5 s of local time
* and not too long ago. This ensures the PPS time is within
* +-0.5 s of the local time and the seconds numbering is
* unambiguous. Note that the leap bits are set no-warning on
*/
if (peer->burst > 0)
return;
+
peer->leap = LEAP_NOTINSYNC;
if (pp->codeproc == pp->coderecv) {
refclock_report(peer, CEVNT_TIMEOUT);
peer->burst = ASTAGE;
return;
- } else if (fabs(sys_prefer->offset) > clock_max) {
+ } else if (fabs(sys_prefer->offset) > 0.5) {
pp->codeproc = pp->coderecv;
peer->burst = ASTAGE;
return;