]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.
authorDave Hart <hart@ntp.org>
Sat, 9 Oct 2010 10:10:10 +0000 (10:10 +0000)
committerDave Hart <hart@ntp.org>
Sat, 9 Oct 2010 10:10:10 +0000 (10:10 +0000)
[Bug 1659] Support Truetime Satellite Clocks on Windows.

bk: 4cb03f8233Rb9q4gPtMn_gS-XNucEA

ChangeLog
ntpd/refclock_arbiter.c
ntpd/refclock_true.c
ports/winnt/include/config.h
ports/winnt/vc6/ntpd.dsp
ports/winnt/vs2003/ntpd.vcproj
ports/winnt/vs2005/ntpd.vcproj
ports/winnt/vs2008/ntpd/ntpd.vcproj

index 2b0538378ab67640a4883e6626fd92705e3e1f7f..ca6c30881fb0621c9807eb52d8786ce07323684d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,9 @@
 ---
 
-* [Bug 1643]: Range-check the decoding of the RIPE-NCC status codes.
-* [Bug 1644]: cvo.sh should use lsb_release to identify linux distros.
+* [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.
+* [Bug 1643] Range-check the decoding of the RIPE-NCC status codes.
+* [Bug 1644] cvo.sh should use lsb_release to identify linux distros.
+* [Bug 1659] Support Truetime Satellite Clocks on Windows.
 
 ---
 (4.2.6p3-RC2) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>
index 35bee70dd60da015dbf8393c02570694424e2ce9..8e92c0fbffcf42bb5b86ff30a1aed0b426f7a9cc 100644 (file)
 #include <stdio.h>
 #include <ctype.h>
 
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
 /*
  * This driver supports the Arbiter 1088A/B Satellite Controlled Clock.
  * The claimed accuracy of this clock is 100 ns relative to the PPS
 #define MAXSTA         40      /* max length of status string */
 #define MAXPOS         80      /* max length of position string */
 
+#ifdef PRE_NTP420
+#define MODE ttlmax
+#else
+#define MODE ttl
+#endif
+
+#define COMMAND_HALT_BCAST ( (peer->MODE % 2) ? "O0" : "B0" )
+#define COMMAND_START_BCAST ( (peer->MODE % 2) ? "O5" : "B5" )
+
 /*
  * ARB unit control structure
  */
@@ -175,7 +190,17 @@ arb_start(
        peer->precision = PRECISION;
        pp->clockdesc = DESCRIPTION;
        memcpy((char *)&pp->refid, REFID, 4);
-       write(pp->io.fd, "B0", 2);
+       if (peer->MODE > 1) {
+               msyslog(LOG_NOTICE, "ARBITER: Invalid mode %d", peer->MODE);
+               close(fd);
+               pp->io.fd = -1;
+               free(up);
+               return (0);
+       }
+#ifdef DEBUG
+       if(debug) { printf("arbiter: mode = %d.\n", peer->MODE); }
+#endif
+       write(pp->io.fd, COMMAND_HALT_BCAST, 2);
        return (1);
 }
 
@@ -268,7 +293,7 @@ arb_receive(
                        if (pp->sloppyclockflag & CLK_FLAG4)
                                write(pp->io.fd, "LA", 2);
                        else
-                               write(pp->io.fd, "B5", 2);
+                               write(pp->io.fd, COMMAND_START_BCAST, 2);
                        return;
 
                } else if (!strncmp(tbuf, "LA", 2)) {
@@ -296,7 +321,7 @@ arb_receive(
                        if (debug)
                                printf("arbiter: %s\n", up->latlon);
 #endif
-                       write(pp->io.fd, "B5", 2);
+                       write(pp->io.fd, COMMAND_START_BCAST, 2);
                }
        }
 
@@ -325,7 +350,7 @@ arb_receive(
            &syncchar, &pp->year, &pp->day, &pp->hour,
            &pp->minute, &pp->second) != 6) {
                refclock_report(peer, CEVNT_BADREPLY);
-               write(pp->io.fd, "B0", 2);
+               write(pp->io.fd, COMMAND_HALT_BCAST, 2);
                return;
        }
 
@@ -375,13 +400,13 @@ arb_receive(
            case 'F':           /* clock failure */
                pp->disp = MAXDISPERSE;
                refclock_report(peer, CEVNT_FAULT);
-               write(pp->io.fd, "B0", 2);
+               write(pp->io.fd, COMMAND_HALT_BCAST, 2);
                return;
 
            default:
                pp->disp = MAXDISPERSE;
                refclock_report(peer, CEVNT_BADREPLY);
-               write(pp->io.fd, "B0", 2);
+               write(pp->io.fd, COMMAND_HALT_BCAST, 2);
                return;
        }
        if (syncchar != ' ')
@@ -398,9 +423,9 @@ arb_receive(
        else if (peer->disp > MAXDISTANCE)
                refclock_receive(peer);
 
-       if (up->tcswitch >= MAXSTAGE) {
-               write(pp->io.fd, "B0", 2);
-       }
+       /* if (up->tcswitch >= MAXSTAGE) { */
+       write(pp->io.fd, COMMAND_HALT_BCAST, 2);
+       /* } */
 }
 
 
index 0d773d27f5f491b1a4b0db343936f51fdc08d3b4..e2520c0dc1c360b87cf8a0e574a7d535bd5c66cd 100644 (file)
 #include <stdio.h>
 #include <ctype.h>
 
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
 /* This should be an atom clock but those are very hard to build.
  *
  * The PCL720 from P C Labs has an Intel 8253 lookalike, as well as a bunch
@@ -290,7 +296,16 @@ true_start(
        up->pollcnt = 2;
        up->type = t_unknown;
        up->state = s_Base;
+
+       /*
+        * Send a CTRL-C character at the start,
+        * just in case the clock is already
+        * sending timecodes
+        */
+       true_send(peer, "\03\r");
+       
        true_doevent(peer, e_Init);
+
        return (1);
 }
 
index 0a05788a8767d9bd3d80c8017da468f1e33329a7..e206dc7aae6ba5fc04e6ef0cca2a68f5683c295a 100644 (file)
@@ -303,6 +303,7 @@ typedef __int32 int32_t;    /* define a typedef for int32_t */
 # define REFCLOCK                      /* from ntpd.mak */
 
 /* # define CLOCK_PARSE  */
+# define CLOCK_ARBITER
 # define CLOCK_ARCRON_MSF
 # define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER    /* timepps.h */
 # define HAVE_TIMEPPS_H
@@ -321,6 +322,7 @@ typedef __int32 int32_t;    /* define a typedef for int32_t */
 # define CLOCK_SPECTRACOM      /* refclock_wwvb.c */
 # define CLOCK_TRIMBLEDC
 # define CLOCK_TRIMTSIP 1
+# define CLOCK_TRUE
 
 # define NTP_LITTLE_ENDIAN             /* from libntp.mak */
 # define NTP_POSIX_SOURCE
index 9a5b7bcb7474d1313bd00132ff8c678c113c637e..3eb33a2ba4fc0b1267b94127d658af9fdb59280a 100644 (file)
@@ -502,7 +502,6 @@ SOURCE=..\..\..\ntpd\refclock_acts.c
 # Begin Source File\r
 \r
 SOURCE=..\..\..\ntpd\refclock_arbiter.c\r
-# PROP Exclude_From_Build 1\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -644,7 +643,6 @@ SOURCE=..\..\..\ntpd\refclock_trak.c
 # Begin Source File\r
 \r
 SOURCE=..\..\..\ntpd\refclock_true.c\r
-# PROP Exclude_From_Build 1\r
 # End Source File\r
 # Begin Source File\r
 \r
index 9e6580d9ddabc207e4f7b9423996bc3f876e3d1b..7860324fefb4c7b0be7af8eb40b5e5f6cae49f4a 100644 (file)
                        <File
                                RelativePath="..\..\..\ntpd\refclock_arbiter.c">
                                <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="TRUE">
+                                       Name="Release|Win32">
                                        <Tool
                                                Name="VCCLCompilerTool"
                                                Optimization="2"
                                                BrowseInformation="1"/>
                                </FileConfiguration>
                                <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="TRUE">
+                                       Name="Debug|Win32">
                                        <Tool
                                                Name="VCCLCompilerTool"
                                                Optimization="0"
                        <File
                                RelativePath="..\..\..\ntpd\refclock_true.c">
                                <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="TRUE">
+                                       Name="Release|Win32">
                                        <Tool
                                                Name="VCCLCompilerTool"
                                                Optimization="2"
                                                BrowseInformation="1"/>
                                </FileConfiguration>
                                <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="TRUE">
+                                       Name="Debug|Win32">
                                        <Tool
                                                Name="VCCLCompilerTool"
                                                Optimization="0"
index 36a5b433bebe15c12926495081a2e33783d80228..cb48d5f8fde02358b4c03a577229e31e10062427 100644 (file)
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                </FileConfiguration>
                                <FileConfiguration
                                        Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                </FileConfiguration>
                                <FileConfiguration
                                        Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
index c9a4631dee8bff11b9a783118cdb0080a9305b99..bdef164790b3561572306dc95e5f7cfdd385193e 100644 (file)
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                </FileConfiguration>
                                <FileConfiguration
                                        Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                >
                                <FileConfiguration
                                        Name="Release|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"
                                </FileConfiguration>
                                <FileConfiguration
                                        Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
                                        >
                                        <Tool
                                                Name="VCCLCompilerTool"