#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
*/
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);
}
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)) {
if (debug)
printf("arbiter: %s\n", up->latlon);
#endif
- write(pp->io.fd, "B5", 2);
+ write(pp->io.fd, COMMAND_START_BCAST, 2);
}
}
&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;
}
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 != ' ')
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);
+ /* } */
}
#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
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);
}