]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[BUG 1052] Modify ONCORE driver for linuxPPS which uses a line discipline for the
authorReg Clemens <clemens@ntp.org>
Sun, 10 Aug 2008 22:31:13 +0000 (18:31 -0400)
committerReg Clemens <clemens@ntp.org>
Sun, 10 Aug 2008 22:31:13 +0000 (18:31 -0400)
PPS source.

bk: 489f6c316jafg4ckXF2wWucUyeyrNw

ntpd/refclock_oncore.c

index 0244b50af6d37d7c8d297f9819de19c51b7b2f91..115e70297aca3d9ff7cd2225ffbdbe2f87c553b4 100644 (file)
@@ -594,24 +594,39 @@ oncore_start(
           Since things ALWAYS work if we only open the device once, we check
             to see if the two devices are in fact the same, then proceed to
             do one open or two.
+
+          For use with linuxPPS we assume that the N_TTY file has been opened
+            and that the line discipline has been changed to N_PPS by another
+            program (say ppsldisc) so that the two files expected by the oncore
+            driver can be opened.
+
+          Note that the linuxPPS N_PPS file is just like a N_TTY, so we can do
+            the stat below without error even though the file has already had its
+            line discipline changed by another process.
        */
 
+       stat1.st_dev = stat1.st_ino = -1;
        if (stat(device1, &stat1)) {
                sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
                record_clock_stats(&(instance->peer->srcadr), Msg);
-               exit(1);
        }
 
-       if (stat(device2, &stat2)) {
-               sprintf(Msg, "Can't stat fd2 (%s)\n", device2);
+       if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
+               sprintf(Msg, "Can't open fd1 (%s)\n", device1);
                record_clock_stats(&(instance->peer->srcadr), Msg);
                exit(1);
        }
 
-       if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
-               sprintf(Msg, "Can't open fd1 (%s)\n", device1);
+       /* for LINUX the PPS device is the result of a line discipline.
+          It seems simplest to let an external program create the appropriate
+          /dev/pps<n> file, and only check (carefully) for its existance here
+        */
+
+       stat2.st_dev = stat2.st_ino = -2;
+       if (stat(device2, &stat2)) {
+               sprintf(Msg, "Can't stat fd2 (%s) errno = %d\n", device2, errno);
                record_clock_stats(&(instance->peer->srcadr), Msg);
-               exit(1);
+               record_clock_stats(&(instance->peer->srcadr), "May be line discipline, see if we can open it.");
        }
 
        if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino))   /* same device here */