]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
PPS cleanup from Dave Mills.
authorHarlan Stenn <stenn@ntp.org>
Thu, 25 Mar 2004 03:04:57 +0000 (22:04 -0500)
committerHarlan Stenn <stenn@ntp.org>
Thu, 25 Mar 2004 03:04:57 +0000 (22:04 -0500)
bk: 40624c59WmPZsCo30Tz9OhOZkueUUQ

include/ntpd.h
ntpd/ntp_config.c
ntpd/ntp_loopfilter.c
ntpd/ntp_refclock.c
ntpd/refclock_atom.c

index b3697b35dfb273a72cad54b78f337483dd76c029..b45b371f19038621598fc7e1997f7040fb92cebf 100644 (file)
@@ -219,7 +219,6 @@ extern  int sock_hash P((struct sockaddr_storage *));
 /* ntp_config.c */
 extern char const *    progname;
 extern char    sys_phone[][MAXDIAL];   /* ACTS phone numbers */
-extern char    pps_device[];           /* PPS device name */
 #if defined(HAVE_SCHED_SETSCHEDULER)
 extern int     config_priority_override;
 extern int     config_priority;
@@ -390,7 +389,7 @@ extern u_long       sys_received;           /* packets received */
 
 /* ntp_refclock.c */
 #ifdef REFCLOCK
-#if defined(PPS) || defined(HAVE_PPSAPI)
+#ifdef PPS
 extern int     fdpps;                  /* pps file descriptor */
 #endif /* PPS */
 #endif
index 701d5c3c289b1166add3f9e59aca41052a54f579..a870e212e3155e6e0dfb0ebdf9ae231b5a7e5818 100644 (file)
@@ -342,7 +342,6 @@ static char res_file[MAX_PATH];
 char const *progname;
 char   sys_phone[MAXPHONE][MAXDIAL]; /* ACTS phone numbers */
 char   *keysdir = NTP_KEYSDIR; /* crypto keys directory */
-char   pps_device[MAXPPS + 1]; /* PPS device name */
 #if defined(HAVE_SCHED_SETSCHEDULER)
 int    config_priority_override = 0;
 int    config_priority;
index 62c3f9258a66c1ba681953f7c47081450596e963..ece80a1573b0b6a85d27ae93528713cfaeec7d9f 100644 (file)
@@ -477,8 +477,15 @@ local_clock(
         * 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()
index 42ed134ab923fdd987b1a4c376b9b0e5647ca40a..e0e9d461f9f384c25f07227cf8e37e2d9a553839 100644 (file)
 # 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
@@ -731,15 +729,9 @@ refclock_open(
                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
index 51153aeb5f1a2d1418180e56dced2336a9cc7442..0a52222c65368c819dfac1fbf66a80ed5262e16f 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * refclock_atom - clock driver for 1-pps signals
  */
@@ -167,16 +166,11 @@ atom_start(
        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);
@@ -184,9 +178,7 @@ atom_start(
        }
 
        /*
-        * 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,
@@ -335,21 +327,25 @@ atom_pps(
        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);
@@ -401,6 +397,7 @@ pps_sample(
        peer = pps_peer;
        if (peer == 0)          /* nobody home */
                return (1);
+
        pp = peer->procptr;
 
        /*
@@ -453,7 +450,7 @@ atom_poll(
 
        /*
         * 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
@@ -462,6 +459,7 @@ atom_poll(
         */
        if (peer->burst > 0)
                return;
+
        peer->leap = LEAP_NOTINSYNC;
        if (pp->codeproc == pp->coderecv) {
                refclock_report(peer, CEVNT_TIMEOUT);
@@ -473,7 +471,7 @@ atom_poll(
                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;