]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, refclock_conf.c, refclock_oncore.c:
authorHarlan Stenn <stenn@ntp.org>
Wed, 13 Sep 2000 02:43:10 +0000 (02:43 -0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 13 Sep 2000 02:43:10 +0000 (02:43 -0000)
  * ntpd/refclock_conf.c:
  * ntpd/refclock_oncore.c: Re-enabled oncore driver for HAVE_PPSAPI
  case only.
  * ntpd/refclock_oncore.c: shmem_fname added.  oncore_init_shmem()
  updated.
  (oncore_start): Comment cleanup
  (oncore_read_config): Move call to oncore_shmem_init()
  (oncore_init_shmem): Prototype change
  (oncore_init_shmem): Don't exit on errors
  (oncore_msg_any): timespec/timeval cleanup
  (oncore_msg_Cj_id): shmem_fname changes
  (oncore_msg_BaEaHa): saw_At bugfix
  (oncore_get_timestamp): Added current_mode/current_params.  Commented.
  Added time_pps_getcap() calls.
  From: Reg Clemens <reg@dwf.com>
ChangeLog, ntp_update:
  Added -d to update flags, fix pass 1 comment.
ChangeLog, ntp_tty.h, icom.c:
  Added include/ntp_tty.h, used in libntp/icom.c
ChangeLog, refclock_parse.c:
  WHARTON fixes

bk: 39bee9bejZ_GMRZ31K0yI5rYXdCLQw

ChangeLog
include/ntp_tty.h [new file with mode: 0644]
libntp/icom.c
ntp_update
ntpd/refclock_conf.c
ntpd/refclock_oncore.c
ntpd/refclock_parse.c

index 6a3fa231917c21a7382f563fb3f9b3d0296227cd..62e2a4c1d0f2791a2140c9a906205701f1eb19e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
 2000-09-12  Harlan Stenn  <stenn@whimsy.udel.edu>
 
+       * ntpd/refclock_conf.c: 
+       * ntpd/refclock_oncore.c: Re-enabled oncore driver for HAVE_PPSAPI
+       case only.
+
+2000-09-12  Philippe De Muyter  <phdm@macqel.be>
+
+        * ntpd/refclock_parse.c (we400a_pollinfo): Useless variable removed.
+        [WHARTON slot]: Set NO_POLL, NO_INIT and NO_DATA; fix `fixed format'
+        and `offset' fields.
+
+       * include/ntp_tty.h: New file
+       * libntp/icom.c: Use it.
+
+       * ntp_update (UPDATE_OPTIONS): Use -d, too.  Fix Pass 1 comment.
+
+2000-09-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: shmem_fname added.  oncore_init_shmem()
+       updated. 
+       (oncore_start): Comment cleanup
+       (oncore_read_config): Move call to oncore_shmem_init()
+       (oncore_init_shmem): Prototype change
+       (oncore_init_shmem): Don't exit on errors
+       (oncore_msg_any): timespec/timeval cleanup
+       (oncore_msg_Cj_id): shmem_fname changes
+       (oncore_msg_BaEaHa): saw_At bugfix
+       (oncore_get_timestamp): Added current_mode/current_params.  Commented.
+       Added time_pps_getcap() calls.
+       From: Reg Clemens <reg@dwf.com>
+
        * ntpd/ntp_io.c (input_handler): Better recvfrom() error message
        From: Dean Gibson <timekeeper@tcp-udp.net>
 
diff --git a/include/ntp_tty.h b/include/ntp_tty.h
new file mode 100644 (file)
index 0000000..3e12c8d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * ntp_tty.h - header file for serial lines handling
+ */
+
+#ifndef NTP_TTY_H
+#define NTP_TTY_H
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#define TTY    struct sgttyb
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#define TTY    struct termio
+#ifndef tcsetattr
+#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
+#endif
+#ifndef TCSANOW
+#define TCSANOW        TCSETA
+#endif
+#ifndef TCIFLUSH
+#define TCIFLUSH 0
+#endif
+#ifndef TCOFLUSH
+#define TCOFLUSH 1
+#endif
+#ifndef TCIOFLUSH
+#define TCIOFLUSH 2
+#endif
+#ifndef tcflush
+#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
+#endif
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#define TTY    struct termios
+#endif
+
+#if defined(HAVE_SYS_MODEM_H)
+#include <sys/modem.h>
+#endif
+
+#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
+#define BSD_TTYS
+#endif /* SYSV_TTYS STREAM BSD_TTYS */
+
+/*
+ * Line discipline flags. These require line discipline or streams
+ * modules to be installed/loaded in the kernel. If specified, but not
+ * installed, the code runs as if unspecified.
+ */
+#define LDISC_STD      0x0     /* standard */
+#define LDISC_CLK      0x1     /* tty_clk \n intercept */
+#define LDISC_CLKPPS   0x2     /* tty_clk \377 intercept */
+#define LDISC_ACTS     0x4     /* tty_clk #* intercept */
+#define LDISC_CHU      0x8     /* depredated */
+#define LDISC_PPS      0x10    /* ppsclock, ppsapi */
+#define LDISC_RAW      0x20    /* raw binary */
+
+#endif /* NTP_TTY_H */
index 4d6efc57f78405eef4546f2923de7bdc30f1f90b..3b9a9a5d00df7ee42fae93a89638989a74b174f7 100644 (file)
@@ -8,17 +8,11 @@
 #include "icom.h"
 #include <unistd.h>
 #include <stdio.h>
-
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#endif /* HAVE_TERMIOS_H */
-#ifdef HAVE_SYS_TERMIOS_H
-# include <sys/termios.h>
-#endif /* HAVE_SYS_TERMIOS_H */
-
 #include <fcntl.h>
 #include <errno.h>
 
+#include "ntp_tty.h"
+
 /*
  * Scraps
  */
@@ -142,7 +136,7 @@ icom_init(
        int speed,              /* line speed */
        int trace               /* trace flags */       )
 {
-       struct termios ttyb;
+       TTY ttyb;
        int fd;
 
        flags = trace;
index 87b2fa95c5d24054d4d1793da36245505ad82986..2615958fcd6570eaa3a1b58306d2fd56784ffb4b 100755 (executable)
@@ -26,7 +26,7 @@
 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
 
 
-UPDATE_OPTIONS=-P
+UPDATE_OPTIONS="-P -d"
 # Add -d to create any directories that exist in the repository but not
 #        locally.
 # Add -A to reset any sticky tags, dates, or `-k' options.
@@ -48,7 +48,7 @@ else
     set -- $UPDATE_OPTIONS ${1+"$@"}
 fi
 
-echo "Pass 1: Updating autoconf and bison generated files"
+echo "Pass 1: Updating autoconf and bison source files"
 find . -name configure.in -o -name '*.y' -o -name copyright.htm | grep -v '^\./A\.'| xargs cvs -q update
 
 echo "Pass 2: Updating full tree"
index e1662bf79999955192b2b3bc5b584393be19f5d8..2b25459479b0d135eef6aa4460990844f9bed2b2 100644 (file)
@@ -186,7 +186,7 @@ extern  struct refclock refclock_palisade;
 #define refclock_palisade refclock_none
 #endif
 
-#if defined(CLOCK_ONCORE) && defined(HAVE_PPSAPI) && 0
+#if defined(CLOCK_ONCORE) && defined(HAVE_PPSAPI)
 extern struct refclock refclock_oncore;
 #else
 #define refclock_oncore refclock_none
index 72cafe59123e2d96fcd780f8937e61c78303483a..000346663f3241f45dff71daafe26afcf161d7e9 100644 (file)
@@ -83,7 +83,7 @@
 #include <config.h>
 #endif
 
-#if defined(REFCLOCK) && defined(CLOCK_ONCORE) && defined(HAVE_PPSAPI) && 0
+#if defined(REFCLOCK) && defined(CLOCK_ONCORE) && defined(HAVE_PPSAPI)
 
 #include <stdio.h>
 #include <ctype.h>
@@ -221,6 +221,7 @@ struct instance {
        long    offset;         /* ns */
 
        u_char  *shmem;
+       char    *shmem_fname;
        u_int   shmem_Cb;
        u_int   shmem_Ba;
        u_int   shmem_Ea;
@@ -277,7 +278,7 @@ static      void    oncore_sendmsg       P((int fd, u_char *, size_t));
 static void    oncore_shutdown      P((int, struct peer *));
 static int     oncore_start         P((int, struct peer *));
 static void    oncore_get_timestamp P((struct instance *, long, long));
-static void    oncore_init_shmem    P((struct instance *, char *));
+static void    oncore_init_shmem    P((struct instance *));
 static void    oncore_print_As      P((struct instance *));
 
 static void    oncore_msg_any     P((struct instance *, u_char *, size_t, int));
@@ -646,7 +647,7 @@ oncore_start(
                instance->pps_p.clear_offset.tv_nsec = 0;
        }
        instance->pps_p.mode |= PPS_TSFMT_TSPEC;
-       instance->pps_p.mode &= mode;           /* only do it if it is legal */
+       instance->pps_p.mode &= mode;           /* only set what is legal */
 
        if (time_pps_setparams(instance->pps_h, &instance->pps_p) < 0) {
                perror("time_pps_setparams");
@@ -871,8 +872,16 @@ oncore_read_config(
                for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++)
                        continue;
 
-               if (!strncmp(cc, "STATUS", (size_t) 6)) {
-                       oncore_init_shmem(instance, ca);
+               /*
+                * move call to oncore_shmem_init() from here to after
+                * we have determined Oncore Model, so we can ignore
+                * request if model doesnt 'support' it
+                */
+
+               if (!strncmp(cc, "STATUS", (size_t) 6) || !strncmp(cc, "SHMEM", (size_t) 5)) {
+                       i = strlen(ca);
+                       instance->shmem_fname = (char *) malloc((unsigned) (i+1));
+                       strcpy(instance->shmem_fname, ca);
                        continue;
                }
 
@@ -996,8 +1005,7 @@ oncore_read_config(
 
 static void
 oncore_init_shmem(
-       struct instance *instance,
-       char *filename
+       struct instance *instance
        )
 {
 #ifdef ONCORE_SHMEM_STATUS
@@ -1010,6 +1018,12 @@ oncore_init_shmem(
                return;
 
        instance->shmem_first++;
+
+       if ((instance->statusfd = open(instance->shmem_fname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) {
+               perror(instance->shmem_fname);
+               return;
+       }
+
        n = 1;
        for (mp = oncore_messages; mp->flag[0]; mp++) {
                mp->shmem = n;
@@ -1035,21 +1049,16 @@ oncore_init_shmem(
        oncore_shmem_length = n + 2;
        fprintf(stderr, "ONCORE: SHMEM length: %d bytes\n", (int) oncore_shmem_length);
 
-       instance->statusfd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0644);
-       if (instance->statusfd < 0) {
-               perror(filename);
-               exit(4);
-       }
        buf = malloc(oncore_shmem_length);
        if (buf == NULL) {
                perror("malloc");
-               exit(4);
+               return;
        }
        memset(buf, 0, sizeof(buf));
        i = write(instance->statusfd, buf, oncore_shmem_length);
        if (i != oncore_shmem_length) {
-               perror(filename);
-               exit(4);
+               perror(instance->shmem_fname);
+               return;
        }
        free(buf);
        instance->shmem = (u_char *) mmap(0, oncore_shmem_length,
@@ -1062,7 +1071,7 @@ oncore_init_shmem(
        if (instance->shmem == (u_char *)MAP_FAILED) {
                instance->shmem = 0;
                close (instance->statusfd);
-               exit(4);
+               return;
        }
        for (mp = oncore_messages; mp->flag[0]; mp++) {
                l = mp->shmem;
@@ -1321,7 +1330,11 @@ oncore_msg_any(
        int i;
        const char *fmt = oncore_messages[idx].fmt;
        const char *p;
+#ifdef HAVE_STRUCT_TIMESPEC
+       struct timespec tv;
+#else
        struct timeval tv;
+#endif
 
        if (debug > 3) {
                GETTIMEOFDAY(&tv, 0);
@@ -1536,11 +1549,19 @@ oncore_msg_Cj_id(
         */
 
 /*BAD M12*/ if (instance->model == ONCORE_M12 && instance->version == 1 && instance->revision <= 3) {
-               instance->shmem = 0;
+               instance->shmem_fname = 0;
                cp = "*** SHMEM turned off for ONCORE M12 ***";
                record_clock_stats(&(instance->peer->srcadr), cp);
        }
 
+       /*
+        * we now know model number and have zeroed
+        * instance->shmem_fname if SHMEM is not supported
+        */
+
+       if (instance->shmem_fname);
+               oncore_init_shmem(instance);
+
        if (instance->shmem)
                cp = "SHMEM is available";
        else
@@ -1573,7 +1594,6 @@ oncore_msg_Cj_id(
                cp = "state = ONCORE_TEST_SENT";
                record_clock_stats(&(instance->peer->srcadr), cp);
                instance->timeout = 4;
-
        }
 }
 
@@ -1941,7 +1961,7 @@ fprintf(stderr, "ONCORE: DEBUG BITS: (%x %x), (%x %x),  %x %x %x %x %x\n",
 
                /* stuck in here as it only gets done once */
 
-               if (!instance->saw_At) {
+               if (instance->chan != 12 && !instance->saw_At) {
                        cp = "Not Good, no @@At command, must be a GT/GT+";
                        record_clock_stats(&(instance->peer->srcadr), cp);
                        oncore_sendmsg(instance->ttyfd, oncore_cmd_Av1, sizeof(oncore_cmd_Av1));
@@ -2241,6 +2261,8 @@ oncore_get_timestamp(
        struct timeval  *tsp = 0;
 #endif
 #ifdef HAVE_PPSAPI
+       int     current_mode;
+       pps_params_t current_params;
        struct timespec timeout;
        pps_info_t pps_i;
 #else  /* ! HAVE_PPSAPI */
@@ -2381,7 +2403,42 @@ oncore_get_timestamp(
        else
                instance->pps_p.clear_offset.tv_nsec  = -dt2;
 
-       if (time_pps_setparams(instance->pps_h, &instance->pps_p))
+       /* The following code is necessary, and not just a time_pps_setparams,
+        * using the saved instance->pps_p, since some other process on the
+        * machine may have diddled with the mode bits (say adding something
+        * that it needs).  We take what is there and ADD what we need.
+        * [[ The results from the time_pps_getcap is unlikely to change so
+        *    we could probably just save it, but I choose to do the call ]]
+        * Unfortunately, there is only ONE set of mode bits in the kernel per
+        * interface, and not one set for each open handle.
+        *
+        * There is still a race condition here where we might mess up someone
+        * elses mode, but if he is being careful too, he should survive.
+        */
+
+       if (time_pps_getcap(instance->pps_h, &current_mode) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_ioctl: time_pps_getcap failed: %m");
+               return (0);
+       }
+
+       if (time_pps_getparams(instance->pps_h, &current_params) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_ioctl: time_pps_getparams failed: %m");
+               return (0);
+       }
+
+               /* or current and mine */
+       current_params.mode |= instance->pps_p.mode;
+               /* but only set whats legal */
+       current_params.mode &= current_mode;
+
+       current_params.assert_offset.tv_sec = 0;
+       current_params.assert_offset.tv_nsec = -dt2;
+       current_params.clear_offset.tv_sec = 0;
+       current_params.clear_offset.tv_nsec = -dt2;
+
+       if (time_pps_setparams(instance->pps_h, &current_params))
                perror("time_pps_setparams");
 #else
        /* if not PPSAPI, no way to inform kernel of OFFSET, just add the */
index 95b93aa2fce13c3667c449ef40b333794412b9a1..2acd38abcb8e8e0505920ee5883d0a32edcc169e 100644 (file)
@@ -767,8 +767,6 @@ static poll_info_t rcc8000_pollinfo = { RCC_POLLRATE, RCC_POLLCMD, RCC_CMDSIZE }
 #define COMPUTIME_SAMPLES     5
 #define COMPUTIME_KEEP        3
 
-static poll_info_t we400a_pollinfo = { 60, "T", 1 };
-
 /*
  * Varitext Radio Clock Receiver
  */
@@ -1169,18 +1167,18 @@ static struct parse_clockinfo
        },
        {                               /* mode 15 */
                0,                              /* operation flags (io modes) */
-               poll_dpoll,                     /* active poll routine */
-               poll_init,                      /* active poll init routine */
+               NO_POLL,                        /* active poll routine */
+               NO_INIT,                        /* active poll init routine */
                NO_EVENT,                       /* special event handling (e.g. reset clock) */
                NO_END,                         /* active poll end routine */
                NO_MESSAGE,                     /* process a lower layer message */
-               ((void *)(&we400a_pollinfo)),   /* local data area for "poll" mechanism */
+               NO_DATA,                        /* local data area for "poll" mechanism */
                0,                              /* rootdelay */
-               1.0 / 960,                      /* current offset by which the RS232
+               11.0 /* bits */ / 9600,         /* current offset by which the RS232
                                                time code is delayed from the actual time */
                DCF_ID,                         /* ID code */
                "WHARTON 400A Series clock",    /* device name */
-               "WHARTON 400A Series clock Output Format 5",    /* fixed format */
+               "WHARTON 400A Series clock Output Format 1",    /* fixed format */
                        /* Must match a format-name in a libparse/clk_xxx.c file */
                DCF_TYPE,                       /* clock type (ntp control) */
                (1*60*60),                      /* time to trust oscillator after loosing synch */