From: Dave Hart Date: Sat, 9 Oct 2010 10:10:10 +0000 (+0000) Subject: [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows. X-Git-Tag: NTP_4_2_7P62~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcd2e60f02833bdac03e4a348403672b2a485713;p=thirdparty%2Fntp.git [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows. [Bug 1659] Support Truetime Satellite Clocks on Windows. bk: 4cb03f8233Rb9q4gPtMn_gS-XNucEA --- diff --git a/ChangeLog b/ChangeLog index 2b0538378..ca6c30881 100644 --- 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 diff --git a/ntpd/refclock_arbiter.c b/ntpd/refclock_arbiter.c index 35bee70dd..8e92c0fbf 100644 --- a/ntpd/refclock_arbiter.c +++ b/ntpd/refclock_arbiter.c @@ -17,6 +17,12 @@ #include #include +#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 @@ -97,6 +103,15 @@ #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); + /* } */ } diff --git a/ntpd/refclock_true.c b/ntpd/refclock_true.c index 0d773d27f..e2520c0dc 100644 --- a/ntpd/refclock_true.c +++ b/ntpd/refclock_true.c @@ -21,6 +21,12 @@ #include #include +#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); } diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 0a05788a8..e206dc7aa 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -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 diff --git a/ports/winnt/vc6/ntpd.dsp b/ports/winnt/vc6/ntpd.dsp index 9a5b7bcb7..3eb33a2ba 100644 --- a/ports/winnt/vc6/ntpd.dsp +++ b/ports/winnt/vc6/ntpd.dsp @@ -502,7 +502,6 @@ SOURCE=..\..\..\ntpd\refclock_acts.c # Begin Source File SOURCE=..\..\..\ntpd\refclock_arbiter.c -# PROP Exclude_From_Build 1 # End Source File # Begin Source File @@ -644,7 +643,6 @@ SOURCE=..\..\..\ntpd\refclock_trak.c # Begin Source File SOURCE=..\..\..\ntpd\refclock_true.c -# PROP Exclude_From_Build 1 # End Source File # Begin Source File diff --git a/ports/winnt/vs2003/ntpd.vcproj b/ports/winnt/vs2003/ntpd.vcproj index 9e6580d9d..7860324fe 100644 --- a/ports/winnt/vs2003/ntpd.vcproj +++ b/ports/winnt/vs2003/ntpd.vcproj @@ -1010,8 +1010,7 @@ + Name="Release|Win32"> + Name="Debug|Win32"> + Name="Release|Win32"> + Name="Debug|Win32">