#define BSD_TTYS
#endif /* SYSV_TTYS STREAM BSD_TTYS */
-#define SAMPLE(x) pp->filter[pp->coderecv++ % MAXSTAGE] = (x); \
- if (pp->coderecv % MAXSTAGE == pp->codeproc % MAXSTAGE) \
- pp->codeproc++;
+#define SAMPLE(x) pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \
+ pp->filter[pp->coderecv] = (x); \
+ if (pp->coderecv == pp->codeproc) \
+ pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
/*
* Macros to determine the clock type and unit numbers from a
int hour; /* hour of day */
int minute; /* minute of hour */
int second; /* second of minute */
- int msec; /* millisecond of second */
- long usec; /* microsecond of second (alt) */
+ long nsec; /* nanosecond of second */
u_long yearstart; /* beginning of year */
int coderecv; /* put pointer */
int codeproc; /* get pointer */
- l_fp lastref; /* timecode timestamp */
- l_fp lastrec; /* local timestamp */
+ l_fp lastref; /* reference timestamp */
+ l_fp lastrec; /* receive timestamp */
double offset; /* mean offset */
double disp; /* sample dispersion */
double jitter; /* jitter (mean squares) */
*/
void
refclock_process_offset(
- struct refclockproc *pp,
- l_fp offset,
- l_fp lastrec,
+ struct refclockproc *pp, /* refclock structure pointer */
+ l_fp lasttim, /* last timecode timestamp */
+ l_fp lastrec, /* last receive timestamp */
double fudge
)
{
+ l_fp lftemp;
double doffset;
- pp->lastref = offset;
pp->lastrec = lastrec;
- L_SUB(&offset, &lastrec);
- LFPTOD(&offset, doffset);
+ lftemp = lasttim;
+ L_SUB(&lftemp, &lastrec);
+ LFPTOD(&lftemp, doffset);
SAMPLE(doffset + fudge);
}
*/
int
refclock_process(
- struct refclockproc *pp
+ struct refclockproc *pp /* refclock structure pointer */
)
{
- l_fp offset;
+ l_fp offset, ltemp;
/*
* Compute the timecode timestamp from the days, hours, minutes,
if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui))
return (0);
- if (pp->usec) {
- TVUTOTSF(pp->usec, offset.l_uf);
- } else {
- MSUTOTSF(pp->msec, offset.l_uf);
- }
+ offset.l_uf = 0;
+ DTOLFP(pp->nsec / 1e9, <emp);
+ L_ADD(&offset, <emp);
refclock_process_offset(pp, offset, pp->lastrec,
pp->fudgetime1);
return (1);
*/
static int
refclock_sample(
- struct refclockproc *pp
+ struct refclockproc *pp /* refclock structure pointer */
)
{
int i, j, k, m, n;
if (pp->codeproc == pp->coderecv)
return (0);
n = 0;
- while (pp->codeproc != pp->coderecv)
- off[n++] = pp->filter[pp->codeproc++ % MAXSTAGE];
+ while (pp->codeproc != pp->coderecv) {
+ off[n++] = pp->filter[pp->codeproc];
+ pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
+ }
if (n > 1)
qsort((char *)off, (size_t)n, sizeof(double), refclock_cmpl_fp);
if (!peer->reach)
report_event(EVNT_REACH, peer);
peer->reach |= 1;
- peer->reftime = peer->org = pp->lastrec;
+ peer->reftime = pp->lastref;
+ peer->org = pp->lastrec;
peer->rootdispersion = pp->disp + SQRT(pp->jitter);
get_systime(&peer->rec);
if (!refclock_sample(pp))
* timestamp by noting its value is earlier than the buffer
* timestamp, but not more than one second earlier.
*/
- dpt = (char *)&rbufp->recv_space;
+ dpt = rbufp->recv_buffer;
dpend = dpt + rbufp->recv_length;
trtmp = rbufp->recv_time;
if (i > 0)
*dp = '\0';
#ifdef DEBUG
- if (debug > 1 && i > 0)
- printf("refclock_gtlin: fd %d time %s timecode %d %s\n",
- rbufp->fd, ulfptoa(&trtmp, 6), i, lineptr);
+ if (debug > 1) {
+ if (i > 0)
+ printf("refclock_gtlin: fd %d time %s timecode %d %s\n",
+ rbufp->fd, ulfptoa(&trtmp, 6), i, lineptr);
+ else
+ printf("refclock_gtlin: fd %d time %s\n",
+ rbufp->fd, ulfptoa(&trtmp, 6));
+ }
#endif
*tsptr = trtmp;
return (i);
bug->values[2] = pp->hour;
bug->values[3] = pp->minute;
bug->values[4] = pp->second;
- bug->values[5] = pp->msec;
+ bug->values[5] = pp->nsec;
bug->values[6] = pp->yearstart;
bug->values[7] = pp->coderecv;
bug->stimes = 0xfffffffc;
* waiting for carrier loss or long-space disconnect, but we do
* these clumsy things anyway.
*/
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
pp->sloppyclockflag &= ~CLK_FLAG1;
up->pollcnt = 0;
(void)write(pp->io.fd, &hangup, 1);
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
}
#else
'6' : ('0' + up->quality));
pp->a_lastcode[pp->lencode + 1] = '\0'; /* Terminate for printf(). */
record_clock_stats(&peer->srcadr, pp->a_lastcode);
-
- /* We don't use the micro-/milli- second part... */
- pp->usec = 0;
- pp->msec = 0;
-
n = sscanf(pp->a_lastcode, "o%2d%2d%2d%1d%2d%2d%2d%1d%1d",
&pp->hour, &pp->minute, &pp->second,
&wday, &pp->day, &month, &pp->year, &bst, &status);
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
}
* Timecode format: "yy:ddd:hh:mm:ss.mmm"
*/
if (sscanf(pp->a_lastcode, "%2d:%3d:%2d:%2d:%2d.%3d", &pp->year,
- &pp->day, &pp->hour, &pp->minute, &pp->second, &pp->msec)
+ &pp->day, &pp->hour, &pp->minute, &pp->second, &pp->nsec)
!= 6) {
refclock_report(peer, CEVNT_BADREPLY);
return;
}
+ pp->nsec *= 1000000;
/*
* Test for synchronization (this is a temporary crock).
peer->refid = pp->refid;
else
peer->refid = sys_prefer->srcadr.sin_addr.s_addr;
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
peer->burst = ASTAGE;
}
refclock_report(peer, CEVNT_BADTIME);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
}
struct vmedate *
* calls since it is transmitted a few seconds ahead of the
* timestamp.
*/
- pp->msec = 0;
got_good=0;
if (sscanf(pp->a_lastcode, "Y %d/%d/%d", &up->year,&up->month,&up->day))
{
refclock_report(peer, CEVNT_BADTIME);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
up->lasthour = pp->hour;
}
int fd_audio; /* audio port file descriptor */
double comp[SIZE]; /* decompanding table */
int port; /* codec port */
- int gain; /* codec input gain */
+ int gain; /* codec gain */
int mongain; /* codec monitor gain */
int clipcnt; /* sample clip count */
int seccnt; /* second interval counter */
* correct and can be selected to discipline the clock.
*/
if (temp > 0) {
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
} else if (pp->sloppyclockflag & CLK_FLAG4) {
record_clock_stats(&peer->srcadr, pp->a_lastcode);
}
up->errflg = CEVNT_BADREPLY;
return (0);
}
- L_CLR(&offset);
if (!clocktime(pp->day, pp->hour, pp->minute, 0, GMT,
up->tstamp[0].l_ui, &pp->yearstart, &offset.l_ui)) {
up->errflg = CEVNT_BADTIME;
return (0);
}
+ offset.l_uf = 0;
for (i = 0; i < up->ntstamp; i++)
- refclock_process_offset(pp, offset, up->tstamp[i], FUDGE +
- pp->fudgetime1);
+ refclock_process_offset(pp, offset, up->tstamp[i],
+ FUDGE + pp->fudgetime1);
+ pp->lastref = up->timestamp;
return (i);
}
&datum_pts->yearstart,
&datum_pts->lastref.l_ui) ) {
+ datum_pts->lastref.l_uf = 0;
error = datum_pts->lastref.l_ui - datum_pts->lastrec.l_ui;
#ifdef DEBUG_DATUM_PTC
** necessary to use fudge factors in the ntp.conf file. Maybe later we will.
*/
/*LFPTOD(&tstmp, doffset);*/
+ datum_pts->lastref = datum_pts->lastrec;
refclock_receive(datum_pts->peer);
/*
/*
* We get down to business. Check the timecode format...
*/
- pp->msec = 0;
got_good=0;
if (sscanf(pp->a_lastcode,"%02d:%02d:%02d",
&hours,&minutes,&seconds) == 3)
refclock_report(peer, CEVNT_BADTIME);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
up->lasthour = pp->hour;
}
{
pp->minute = BP1(7)*10 + BP2(7);
pp->second = BP1(8)*10 + BP2(8);
- pp->msec = BP1(9)*10 + BP2(9);
- pp->usec = BP1(10);
+ pp->nsec = (BP1(9)*10 + BP2(9)) * 1000000;
+ pp->nsec += BP1(10) * 1000;
} else {
pp->hour = BP1(5)*10 + BP2(5);
pp->minute = BP1(6)*10 + BP2(6);
pp->second = BP1(7)*10 + BP2(7);
- pp->msec = BP1(8)*10 + BP2(8);
- pp->usec = BP1(9);
+ pp->nsec = (BP1(8)*10 + BP2(8)) * 1000000;
+ pp->nsec += BP1(9) * 1000;
}
if((pp->hour == 10) && (pp->minute == 10))
if (!refclock_process(pp))
refclock_report(peer, CEVNT_BADTIME);
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
return;
}
l_fp tstmp;
time_t tloc;
struct tm *tadr;
+ long ltemp;
vme->hour = tptr->hr;
vme->minute = tptr->mn;
vme->second = tptr->sec;
- vme->usec = tptr->frac;
+ vme->nsec = tptr->frac * 1000;
#ifdef DEBUG
if (debug)
printf("vme: %3d %02d:%02d:%02d.%06ld %1x\n",
vme->day, vme->hour, vme->minute, vme->second,
- vme->usec, tptr->status);
+ vme->nsec, tptr->status);
#endif
if (tptr->status ) { /* Status 0 is locked to ref., 1 is not */
vme_report_event(vme, CEVNT_BADREPLY);
msyslog(LOG_ERR, "refclock_gpsvme: bad data!!");
return;
}
- TVUTOTSF(vme->usec, vme->lastref.l_uf);
+ vme->lastref.l_uf = 0;
+ DTOLFP(vme->nsec / 1e9, <emp);
+ L_ADD(&vme->lastrec, <emp);
tstmp = vme->lastref;
L_SUB(&tstmp, &vme->lastrec);
vme->coderecv++;
L_ADD(&tstmp, &(fudgefactor[vme->unit]));
-
+ vme->lastref = vme->lastrec;
refclock_receive(vme->peer);
}
bug->values[4] = (u_long)vme->hour;
bug->values[5] = (u_long)vme->minute;
bug->values[6] = (u_long)vme->second;
- bug->values[7] = (u_long)vme->usec;
+ bug->values[7] = (u_long)vme->nsec;
bug->values[9] = vme->yearstart;
bug->stimes = 0x1c;
bug->times[0] = vme->lastref;
*/
static int speed[] = {B1200, B2400, B4800, B9600};
-/*
- * Unit control structure
- */
-struct heathunit {
- int pollcnt; /* poll message counter */
- l_fp tstamp; /* timestamp of last poll */
-};
-
/*
* Function prototypes
*/
struct peer *peer
)
{
- register struct heathunit *up;
struct refclockproc *pp;
int fd;
char device[20];
(void)sprintf(device, DEVICE, unit);
if (!(fd = refclock_open(device, speed[peer->ttlmax & 0x3], 0)))
return (0);
-
- /*
- * Allocate and initialize unit structure
- */
- if (!(up = (struct heathunit *)
- emalloc(sizeof(struct heathunit)))) {
- (void) close(fd);
- return (0);
- }
- memset((char *)up, 0, sizeof(struct heathunit));
pp = peer->procptr;
pp->io.clock_recv = heath_receive;
pp->io.srcclock = (caddr_t)peer;
pp->io.fd = fd;
if (!io_addclock(&pp->io)) {
(void) close(fd);
- free(up);
return (0);
}
- pp->unitptr = (caddr_t)up;
/*
* Initialize miscellaneous variables
peer->burst = NSTAGE;
pp->clockdesc = DESCRIPTION;
memcpy((char *)&pp->refid, REFID, 4);
- up->pollcnt = 2;
return (1);
}
struct peer *peer
)
{
- register struct heathunit *up;
struct refclockproc *pp;
pp = peer->procptr;
- up = (struct heathunit *)pp->unitptr;
io_closeclock(&pp->io);
- free(up);
}
struct recvbuf *rbufp
)
{
- register struct heathunit *up;
struct refclockproc *pp;
struct peer *peer;
l_fp trtmp;
*/
peer = (struct peer *)rbufp->recv_srcclock;
pp = peer->procptr;
- up = (struct heathunit *)pp->unitptr;
pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX,
&trtmp);
- /*
- * We get a buffer and timestamp for each <cr>; however, we use
- * the timestamp captured at the RTS modem control line toggle
- * on the assumption that's what the radio bases the timecode
- * on. Apparently, the radio takes about a second to make up its
- * mind to send a timecode, so the receive timestamp is
- * worthless.
- */
- pp->lastrec = up->tstamp;
- up->pollcnt = 2;
-#ifdef DEBUG
- if (debug)
- printf("heath: timecode %d %s\n", pp->lencode,
- pp->a_lastcode);
-#endif
-
/*
* We get down to business, check the timecode format and decode
* its contents. If the timecode has invalid length or is not in
if (!isdigit((int)dsec))
pp->leap = LEAP_NOTINSYNC;
else {
- pp->msec = (dsec - '0') * 100;
+ pp->nsec = (dsec - '0') * 100000000;
pp->leap = LEAP_NOWARNING;
}
if (!refclock_process(pp))
struct peer *peer
)
{
- register struct heathunit *up;
struct refclockproc *pp;
int bits = TIOCM_RTS;
* At each poll we check for timeout and toggle the RTS modem
* control line, then take a timestamp. Presumably, this is the
* event the radio captures to generate the timecode.
+ * Apparently, the radio takes about a second to make up its
+ * mind to send a timecode, so the receive timestamp is
+ * worthless.
*/
pp = peer->procptr;
- up = (struct heathunit *)pp->unitptr;
- pp->polls++;
/*
* We toggle the RTS modem control lead (GC-1000) and sent a T
*/
if (ioctl(pp->io.fd, TIOCMBIC, (char *)&bits) < 0)
refclock_report(peer, CEVNT_FAULT);
- get_systime(&up->tstamp);
- ioctl(pp->io.fd, TIOCMBIS, (char *)&bits);
+ get_systime(&pp->lastrec);
if (write(pp->io.fd, "T", 1) != 1)
refclock_report(peer, CEVNT_FAULT);
+ ioctl(pp->io.fd, TIOCMBIS, (char *)&bits);
if (peer->burst > 0)
return;
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
- peer->burst = NSTAGE;
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+ if (debug)
+ printf("heath: timecode %d %s\n", pp->lencode,
+ pp->a_lastcode);
+#endif
+ peer->burst = MAXSTAGE;
+ pp->polls++;
}
#else
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
-
record_clock_stats(&peer->srcadr, pp->a_lastcode);
-
return;
}
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
#if 0
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
/*
* o The modulation index is less than MODMIN (0.5). This usually means
* overdriven IRIG signal or wrong IRIG format.
*
- * o A frame synchronization error has occurred. This usually means wrong
- * IRIG signal format or the IRIG signal source has lost
+ * o A frame synchronization error has occurred. This usually means
+ * wrong IRIG signal format or the IRIG signal source has lost
* synchronization (signature control).
*
* o A data decoding error has occurred. This usually means wrong IRIG
#define PI 3.1415926535 /* the real thing */
/*
- * Experimentally determined fudge factors
+ * Experimentally determined filter delays
*/
-#define IRIG_B .0019 /* IRIG-B phase delay */
-#define IRIG_E .0019 /* IRIG-E phase delay */
+#define IRIG_B .0019 /* IRIG-B filter delay */
+#define IRIG_E .0019 /* IRIG-E filter delay */
/*
* Data bit definitions
#define IRIG_ERR_DECODE 0x10 /* frame decoding error */
#define IRIG_ERR_CHECK 0x20 /* second numbering discrepancy */
#define IRIG_ERR_ERROR 0x40 /* codec error (overrun) */
+#define IRIG_ERR_SIGERR 0x80 /* IRIG status error (Spectracom) */
/*
* IRIG unit control structure
u_char timecode[21]; /* timecode string */
l_fp timestamp; /* audio sample timestamp */
l_fp tick; /* audio sample increment */
- double comp[SIZE]; /* decompanding table */
double integ[BAUD]; /* baud integrator */
double phase, freq; /* logical clock phase and frequency */
double zxing; /* phase detector integrator */
double irig_b; /* IRIG-B signal amplitude */
double irig_e; /* IRIG-E signal amplitude */
int errflg; /* error flags */
- int pollcnt; /* poll counter */
+ /*
+ * Audio codec variables
+ */
+ double comp[SIZE]; /* decompanding table */
int port; /* codec port */
int gain; /* codec gain */
int mongain; /* codec monitor gain */
int clipcnt; /* sample clipped count */
int seccnt; /* second interval counter */
- int decim; /* sample decimation factor */
/*
* RF variables
double lastsig; /* last carrier sample */
double xxing; /* phase detector interpolated output */
double fdelay; /* filter delay */
+ int decim; /* sample decimation factor */
int envphase; /* envelope phase */
int envptr; /* envelope phase pointer */
int carphase; /* carrier phase */
/*
* Decoder variables
*/
- l_fp montime; /* reference timestamp for eyeball */
- int timecnt; /* timecode counter */
int pulse; /* cycle counter */
int cycles; /* carrier cycles */
int dcycles; /* data cycles */
* Global variables
*/
static char hexchar[] = { /* really quick decoding table */
- '0', '8', '4', 'c', /* 0000 0001 0010 0011 */
- '2', 'a', '6', 'e', /* 0100 0101 0110 0111 */
- '1', '9', '5', 'd', /* 1000 1001 1010 1011 */
- '3', 'b', '7', 'f' /* 1100 1101 1110 1111 */
+ '0', '8', '4', 'c', /* 0000 0001 0010 0011 */
+ '2', 'a', '6', 'e', /* 0100 0101 0110 0111 */
+ '1', '9', '5', 'd', /* 1000 1001 1010 1011 */
+ '3', 'b', '7', 'f' /* 1100 1101 1110 1111 */
};
up->decim = 1;
up->fdelay = IRIG_B;
up->gain = 127;
- up->pollcnt = 2;
/*
* The companded samples are encoded sign-magnitude. The table
up->comp[i] = up->comp[i - 1] + step;
up->comp[OFFSET + i] = -up->comp[i];
if (i % 16 == 0)
- step *= 2.;
+ step *= 2.;
}
DTOLFP(1. / SECOND, &up->tick);
return (1);
/*
* IRIG-B filter. 4th-order elliptic, 800-Hz highpass, 0.3 dB
- * passband ripple, -50 dB stopband ripple, phase delay -.0022
+ * passband ripple, -50 dB stopband ripple, phase delay .0022
* s)
*/
irig_b = (up->hpf[4] = up->hpf[3]) * 2.322484e-01;
up->badcnt = (up->badcnt + 1) % up->decim;
if (up->badcnt == 0) {
if (up->decim == 1)
- irig_base(peer, irig_b);
+ irig_base(peer, irig_b);
else
- irig_base(peer, irig_e);
+ irig_base(peer, irig_e);
}
}
up->maxsignal = up->intmax;
up->noise = up->intmin;
if (up->maxsignal < DRPOUT)
- up->errflg |= IRIG_ERR_AMP;
+ up->errflg |= IRIG_ERR_AMP;
if (up->intmax > 0)
- up->modndx = (up->intmax - up->intmin) / up->intmax;
+ up->modndx = (up->intmax - up->intmin) /
+ up->intmax;
else
- up->modndx = 0;
+ up->modndx = 0;
if (up->modndx < MODMIN)
- up->errflg |= IRIG_ERR_MOD;
+ up->errflg |= IRIG_ERR_MOD;
up->intmin = 1e6; up->intmax = 0;
if (up->errflg & (IRIG_ERR_AMP | IRIG_ERR_FREQ |
- IRIG_ERR_MOD | IRIG_ERR_SYNCH)) {
+ IRIG_ERR_MOD | IRIG_ERR_SYNCH)) {
up->tc = MINTC;
up->tcount = 0;
}
* the slice level and left-shifted in the decoding register.
*/
if (up->carphase != 7)
- return;
+ return;
env = (up->lastenv[2] - up->lastenv[6]) / 2.;
lope = (up->lastint[2] - up->lastint[6]) / 2.;
if (lope > up->intmax)
- up->intmax = lope;
+ up->intmax = lope;
if (lope < up->intmin)
- up->intmin = lope;
+ up->intmin = lope;
/*
* Pulse code demodulator and reference timestamp. The decoder
*/
up->pulse = (up->pulse + 1) % 10;
if (up->pulse == 1)
- up->envmax = env;
+ up->envmax = env;
else if (up->pulse == 9)
- up->envmin = env;
+ up->envmin = env;
up->dcycles <<= 1;
if (env >= (up->envmax + up->envmin) / 2.)
- up->dcycles |= 1;
+ up->dcycles |= 1;
up->cycles <<= 1;
if (lope >= (up->maxsignal + up->noise) / 2.)
- up->cycles |= 1;
+ up->cycles |= 1;
if ((up->cycles & 0x303c0f03) == 0x300c0300) {
l_fp ltemp;
int bitz;
* persist for lots of samples.
*/
if (up->pulse != 9)
- up->errflg |= IRIG_ERR_SYNCH;
+ up->errflg |= IRIG_ERR_SYNCH;
up->pulse = 9;
dtemp = BAUD - up->zxing;
i = up->envxing - up->envphase;
if (i < 0)
- i -= i;
+ i -= i;
if (i <= 1) {
up->tcount++;
if (up->tcount > 50 * up->tc) {
up->tc++;
if (up->tc > MAXTC)
- up->tc = MAXTC;
+ up->tc = MAXTC;
up->tcount = 0;
up->envxing = up->envphase;
} else {
* zero crossing.
*/
DTOLFP(up->decim * (dtemp / SECOND + 1.) + up->fdelay,
- <emp);
+ <emp);
pp->lastrec = up->timestamp;
L_SUB(&pp->lastrec, <emp);
bitz = up->dcycles & 0xfc;
switch(bitz) {
- case 0x00:
- case 0x80:
+ case 0x00:
+ case 0x80:
irig_decode(peer, BIT0);
break;
- case 0xc0:
- case 0xe0:
- case 0xf0:
+ case 0xc0:
+ case 0xe0:
+ case 0xf0:
irig_decode(peer, BIT1);
break;
- case 0xf8:
- case 0xfc:
+ case 0xf8:
+ case 0xfc:
irig_decode(peer, BITP);
break;
- default:
+ default:
irig_decode(peer, 0);
up->errflg |= IRIG_ERR_DECODE;
}
/*
* Local variables
*/
- char syncchar; /* sync character (Spectracom only) */
+ char syncchar; /* sync character (Spectracom) */
char sbs[6]; /* binary seconds since 0h */
char spare[2]; /* mulligan digits */
up->bitcnt = 1;
up->fieldcnt = 0;
up->lastbit = 0;
- up->montime = pp->lastrec;
if (up->errflg == 0) {
- up->timecnt++;
refclock_process(pp);
- }
- if (up->timecnt >= MAXSTAGE) {
- refclock_receive(peer);
- up->timecnt = 0;
- up->pollcnt = 2;
+ pp->lastref = up->timestamp;
}
up->errflg = 0;
}
if (up->xptr < 2)
up->xptr = 2 * FIELD;
up->timecode[--up->xptr] = hexchar[(up->bits >> 5) &
- 0xf];
+ 0xf];
up->timecode[--up->xptr] = hexchar[up->bits & 0xf];
up->fieldcnt = (up->fieldcnt + 1) % FIELD;
if (up->fieldcnt == 0) {
/*
- * End of field. Decode the timecode, adjust the
- * gain and set the input port. Set the port
- * here on the assumption somebody might even
- * change it on-wing.
+ * End of field. Decode the timecode and wind
+ * the clock. Not all IRIG generators have the
+ * year; if so, it is nonzero after year 2000.
+ * Not all have the hardware status bit; if so,
+ * it is lit when the source is okay and dim
+ * when bad. We watch this only if the year is
+ * nonzero. Not all are configured for signature
+ * control. If so, all BCD digits are set to
+ * zero if the source is bad. In this case the
+ * refclock_process() will reject the timecode
+ * as invalid.
*/
up->xptr = 2 * FIELD;
if (sscanf((char *)up->timecode,
- "%6s%2d%c%2s%3d%2d%2d%2d",
- sbs, &pp->year, &syncchar, spare, &pp->day,
- &pp->hour, &pp->minute, &pp->second) != 8)
- pp->leap = LEAP_NOTINSYNC;
+ "%6s%2d%c%2s%3d%2d%2d%2d", sbs, &pp->year,
+ &syncchar, spare, &pp->day, &pp->hour,
+ &pp->minute, &pp->second) != 8)
+ pp->leap = LEAP_NOTINSYNC;
else
- pp->leap = LEAP_NOWARNING;
+ pp->leap = LEAP_NOWARNING;
up->second = (up->second + up->decim) % 60;
+ if (pp->year > 0) {
+ pp->year += 2000;
+ if (syncchar == '0')
+ up->errflg |= IRIG_ERR_CHECK;
+ }
if (pp->second != up->second)
- up->errflg |= IRIG_ERR_CHECK;
+ up->errflg |= IRIG_ERR_CHECK;
up->second = pp->second;
sprintf(pp->a_lastcode,
- "%02x %c %2d %3d %02d:%02d:%02d %4.0f %3d %6.3f %2d %2d %6.3f %6.1f %s",
- up->errflg, syncchar, pp->year, pp->day,
- pp->hour, pp->minute, pp->second,
- up->maxsignal, up->gain, up->modndx,
- up->envxing, up->tc, up->yxing, up->freq *
- 1e6 / SECOND, ulfptoa(&up->montime, 6));
+ "%02x %c %2d %3d %02d:%02d:%02d %4.0f %3d %6.3f %2d %2d %6.3f %6.1f",
+ up->errflg, syncchar, pp->year, pp->day,
+ pp->hour, pp->minute, pp->second,
+ up->maxsignal, up->gain, up->modndx,
+ up->envxing, up->tc, up->yxing, up->freq *
+ 1e6 / SECOND);
pp->lencode = strlen(pp->a_lastcode);
- if (up->timecnt == 0 || pp->sloppyclockflag &
- CLK_FLAG4)
- record_clock_stats(&peer->srcadr,
- pp->a_lastcode);
+ if (pp->sloppyclockflag & CLK_FLAG4) {
+ record_clock_stats(&peer->srcadr,
+ pp->a_lastcode);
#ifdef DEBUG
- if (debug > 2)
- printf("irig: %s\n", pp->a_lastcode);
+ if (debug)
+ printf("irig: %s\n",
+ pp->a_lastcode);
#endif /* DEBUG */
+ }
}
}
up->lastbit = bit;
/*
* irig_poll - called by the transmit procedure
*
- * This routine keeps track of status. If nothing is heard for two
- * successive poll intervals, a timeout event is declared and any
- * orphaned timecode updates are sent to foster care.
+ * This routine sweeps up the timecode updates since the last poll. For
+ * IRIG-B there should be at least 60 updates; for IRIG-E there should
+ * be at least 6. If nothing is heard, a timeout event is declared and
+ * any orphaned timecode updates are sent to foster care.
*/
static void
irig_poll(
pp = peer->procptr;
up = (struct irigunit *)pp->unitptr;
- /*
- * Keep book for tattletales
- */
- if (up->pollcnt == 0) {
+ if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
- up->timecnt = 0;
return;
+ } else {
+ refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+ if (debug)
+ printf("irig: %s\n", pp->a_lastcode);
+#endif /* DEBUG */
}
- up->pollcnt--;
pp->polls++;
}
up->clipcnt = 0;
}
-
#else
int refclock_irig_bs;
#endif /* REFCLOCK */
pp->hour = up->hour ;
pp->minute = up->minute ;
pp->second = up->second ;
- pp->msec = up->msecond ;
- pp->usec = 0;
+ pp->nsec = up->msecond * 1000000;
/*
* JST to UTC
sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d JST",
up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
- record_clock_stats ( &peer->srcadr, sLogText ) ;
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
-
+ record_clock_stats ( &peer->srcadr, sLogText ) ;
}
/**************************************************************************************************/
pp->year, pp->day,
pp->hour, pp->minute, pp->second,
prettydate(&pp->lastrec), lfptoa(&pp->offset, 6));
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
/*
pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui)) {
return ("jupiter_process: clocktime failed");
}
- if (pp->usec) {
- TVUTOTSF(pp->usec, offset.l_uf);
- } else {
- MSUTOTSF(pp->msec, offset.l_uf);
- }
+ offset.l_uf = 0;
+ DTOLFP(pp->nsec / 1e9, <emp);
+ L_ADD(&offset, <emp);
L_ADD(&offset, &pp->fudgetime1);
up->lastref = offset; /* save last reference time */
L_SUB(&offset, &pp->lastrec); /* form true offset */
pp->hour = jt->hour;
pp->minute = jt->minute;
pp->second = jt->second;
- pp->msec = 0;
- pp->usec = 0;
}
/* XXX debugging */
leitch->state = STATE_IDLE;
break;
}
+ leitch->reftime1.l_uf = 0;
#ifdef DEBUG
if (debug)
fprintf(stderr, "%lu\n", (u_long)leitch->reftime1.l_ui);
ext_enable = 0;
}
#endif /* KERNEL_PLL STA_CLK */
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
pp->fudgetime1 = 0;
}
mx4200_debug(peer, "%4d-%03d %02d:%02d:%02d at %s, %.6f\n",
pp->year, pp->day, pp->hour, pp->minute, pp->second,
prettydate(&pp->lastrec), pp->offset);
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
/*
pp->hour = hour;
pp->minute = minute;
pp->second = second;
- pp->msec = 0;
- pp->usec = 0;
/*
* Toss if sentence is marked invalid
/* Default to 0 milliseconds, if decimal convert milliseconds in
one, two or three digits
*/
- pp->msec = 0;
+ pp->nsec = 0;
if (dp[6] == '.') {
if (isdigit((int)dp[7])) {
- pp->msec = (dp[7] - '0') * 100;
+ pp->nsec = (dp[7] - '0') * 100000000;
if (isdigit((int)dp[8])) {
- pp->msec += (dp[8] - '0') * 10;
+ pp->nsec += (dp[8] - '0') * 10000000;
if (isdigit((int)dp[9])) {
- pp->msec += (dp[9] - '0');
+ pp->nsec += (dp[9] - '0') * 1000000;
}
}
}
}
if (pp->hour > 23 || pp->minute > 59 || pp->second > 59
- || pp->msec > 1000) {
+ || pp->nsec > 1000000000) {
refclock_report(peer, CEVNT_BADTIME);
return;
}
*/
if (nmea_pps(up, &rd_tmp) == 1) {
pp->lastrec = up->tstamp = rd_tmp;
- pp->msec = 0;
+ pp->nsec = 0;
}
#endif /* HAVE_PPSAPI */
if (!up->polled)
return;
up->polled = 0;
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
/* If we get here - what we got from the clock is OK, so say so */
ts.l_ui += JAN_1970;
instance->pp->lastrec = ts;
- instance->pp->msec = 0;
ts_tmp = ts;
ts_tmp.l_ui = 0; /* zero integer part */
/*
instance->pp->dispersion = instance->pp->skew = 0;
*/
+ instance->pp->lastref = instance->pp->lastrec;
refclock_receive(instance->peer);
}
}
secint = (long) secs;
secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
- pp->usec = (long) (secfrac * 1000000);
+ pp->nsec = (long) (secfrac * 1000000000);
secint %= 86400; /* Only care about today */
pp->hour = secint / 3600;
if (debug > 1)
printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%06ld %02d/%02d/%04d UTC %02d\n",
up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
- pp->second, pp->usec, mb(12), mb(11), pp->year, GPS_UTC_Offset);
+ pp->second, pp->nsec, mb(12), mb(11), pp->year, GPS_UTC_Offset);
#endif
/* Only use this packet when no
* 8F-AD's are being received
return 0;
}
- pp->usec = (long) (getdbl((u_char *) &mb(3)) * 1000000);
+ pp->nsec = (long) (getdbl((u_char *) &mb(3)) * 1000000);
if ((pp->day = day_of_year(&mb(14))) < 0)
break;
if (debug > 1)
printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%06ld %02d/%02d/%04d UTC %02x %s\n",
up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
- pp->second, pp->usec, mb(15), mb(14), pp->year,
+ pp->second, pp->nsec, mb(15), mb(14), pp->year,
mb(19), *Tracking_Status[st]);
#endif
return 1;
printf(
"palisade_receive: unit %d: %4d %03d %02d:%02d:%02d.%06ld\n",
up->unit, pp->year, pp->day, pp->hour, pp->minute,
- pp->second, pp->usec);
+ pp->second, pp->nsec);
#endif
/*
*/
(void) sprintf(pp->a_lastcode,"%4d %03d %02d:%02d:%02d.%06ld",
- pp->year,pp->day,pp->hour,pp->minute, pp->second,pp->usec);
+ pp->year,pp->day,pp->hour,pp->minute, pp->second,pp->nsec);
pp->lencode = 24;
#ifdef PALISADE
printf("palisade_receive: unit %d: %s\n",
up->unit, prettydate(&pp->lastrec));
#endif
-
+ pp->lastref = pp->lastrec;
refclock_receive(peer
#ifdef PALISADE
, &pp->offset, 0, pp->dispersion,
pp->hour = tp->tm_hour;
pp->minute = tp->tm_min;
pp->second = tp->tm_sec;
- pp->usec = buf[16] * 31250;
+ pp->nsec = buf[16] * 31250000;
if (buf[17] & 1)
- pp->usec += 500000;
+ pp->nsec += 500000000;
#ifdef DEBUG
if (debug)
pp->leap = LEAP_NOTINSYNC;
else
pp->leap = LEAP_NOWARNING;
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
}
#else
/*
* Interface definitions
*/
-#define DEVICE "/dev/pst%d" /* device name and unit */
+#define DEVICE "/dev/wwv%d" /* device name and unit */
#define SPEED232 B9600 /* uart speed (9600 baud) */
#define PRECISION (-10) /* precision assumed (about 1 ms) */
#define WWVREFID "WWV\0" /* WWV reference ID */
* Unit control structure
*/
struct pstunit {
- u_char tcswitch; /* timecode switch */
+ int tcswitch; /* timecode switch */
char *lastptr; /* pointer to timecode data */
};
* Initialize miscellaneous variables
*/
peer->precision = PRECISION;
- peer->burst = NSTAGE;
pp->clockdesc = DESCRIPTION;
memcpy((char *)&pp->refid, WWVREFID, 4);
+ peer->burst = MAXSTAGE;
return (1);
}
* Note we get a buffer and timestamp for each <cr>, but only
* the first timestamp is retained.
*/
- if (!up->tcswitch)
+ if (up->tcswitch == 0)
pp->lastrec = trtmp;
up->tcswitch++;
pp->lencode = up->lastptr - pp->a_lastcode;
if (up->tcswitch < 3)
return;
-#ifdef DEBUG
- if (debug)
- printf("pst: timecode %d %s\n", pp->lencode,
- pp->a_lastcode);
-#endif
/*
* We get down to business, check the timecode format and decode
* Timecode format:
* "ahh:mm:ss.fffs yy/dd/mm/ddd frdzycchhSSFTttttuuxx"
*/
- if (sscanf(pp->a_lastcode, "%c%2d:%2d:%2d.%3d%c %9s%3d%13s%4ld",
- &mchar, &pp->hour, &pp->minute, &pp->second,
- &pp->msec, &daychar, junque, &pp->day,
- info, <emp) != 10) {
+ if (sscanf(pp->a_lastcode,
+ "%c%2d:%2d:%2d.%3ld%c %9s%3d%13s%4ld",
+ &mchar, &pp->hour, &pp->minute, &pp->second, &pp->nsec,
+ &daychar, junque, &pp->day, info, <emp) != 10) {
refclock_report(peer, CEVNT_BADREPLY);
return;
}
+ pp->nsec *= 1000000;
/*
* Decode synchronization, quality and last update. If
memcpy((char *)&pp->refid, WWVREFID, 4);
if (peer->stratum <= 1)
peer->refid = pp->refid;
- pp->disp = PST_PHI * ltemp;
+ if (ltemp == 0)
+ pp->lastref = pp->lastrec;
+ pp->disp = PST_PHI * ltemp * 60;
/*
* Process the new sample in the median filter and determine the
/*
* Time to poll the clock. The PSTI/Traconex clock responds to a
* "QTQDQMT" by returning a timecode in the format specified
- * above. If nothing is heard from the clock for two polls,
- * declare a timeout and keep going.
+ * above. Note there is no checking on state, since this may not
+ * be the only customer reading the clock. Only one customer
+ * need poll the clock; all others just listen in. If the clock
+ * becomes unreachable, declare a timeout and keep going.
*/
pp = peer->procptr;
up = (struct pstunit *)pp->unitptr;
up->lastptr = pp->a_lastcode;
if (write(pp->io.fd, "QTQDQMT", 6) != 6)
refclock_report(peer, CEVNT_FAULT);
- else
- pp->polls++;
if (peer->burst > 0)
return;
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
refclock_receive(peer);
- peer->burst = NSTAGE;
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+ if (debug)
+ printf("pst: timecode %d %s\n", pp->lencode,
+ pp->a_lastcode);
+#endif
+ peer->burst = MAXSTAGE;
+ pp->polls++;
}
#else
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
}
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
+ refclock_receive(peer);
+ pp->lastref = pp->lastrec;
record_clock_stats(&peer->srcadr, pp->a_lastcode);
refclock_receive(peer);
peer->burst = NSTAGE;
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
}
refclock_report(peer, CEVNT_BADTIME);
return;
}
+ off.l_uf = 0;
#endif
pp->usec = true_sample720();
* If clock is good we send a NOMINAL message so that
* any previous BAD messages are nullified
*/
- refclock_report(peer, CEVNT_NOMINAL);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ refclock_report(peer, CEVNT_NOMINAL);
/*
* We have succedded in answering the poll.
* proper format, we declare bad format and exit.
*/
syncchar = leapchar = modechar = ' ';
- pp->msec = 0;
-
switch (pp->lencode ) {
case LEN33X:
/*
* T = DST <-> STD transition indicators
*
*/
- if (sscanf(pp->a_lastcode, "%c%1d%c%4d%3d%*c%2d:%2d:%2d.%2d%c",
+ if (sscanf(pp->a_lastcode, "%c%1d%c%4d%3d%*c%2d:%2d:%2d.%2ld%c",
&syncchar, &quality, &modechar, &pp->year, &pp->day,
&pp->hour, &pp->minute, &pp->second,
- &pp->msec,&leapchar) == 10) {
- pp->msec *= 10; /* M320 returns 10's of msecs */
+ &pp->nsec, &leapchar) == 10) {
+ pp->nsec *= 10000000; /* M320 returns 10's of msecs */
if (leapchar == 'I' ) leapchar = '+';
if (leapchar == 'D' ) leapchar = '-';
if (syncchar != '?' ) syncchar = ':';
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
- refclock_receive(peer);
+ pp->lastref = pp->lastrec;
+ refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
peer->burst = NSTAGE;
}
* protocol module to chuck out the data. Finaly, we unhook the
* timeout, arm for the next call, fold the tent and go home.
*/
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
+ pp->lastref = pp->lastrec;
refclock_receive(peer);
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
pp->sloppyclockflag &= ~CLK_FLAG1;
up->pollcnt = 0;
up->state = 0;
struct wwvunit {
l_fp timestamp; /* audio sample timestamp */
l_fp tick; /* audio sample increment */
- double comp[SIZE]; /* decompanding table */
double phase, freq; /* logical clock phase and frequency */
double monitor; /* audio monitor point */
int fd_icom; /* ICOM file descriptor */
int errflg; /* error flags */
+ int watch; /* watchcat */
+ int swatch; /* second sync watchcat */
+
+ /*
+ * Audio codec variables
+ */
+ double comp[SIZE]; /* decompanding table */
int port; /* codec port */
int gain; /* codec gain */
int mongain; /* codec monitor gain */
int clipcnt; /* sample clipped count */
- int watch; /* watchcat */
- int swatch; /* second sync watchcat */
/*
* Variables used to establish basic system timing
up = (struct wwvunit *)pp->unitptr;
if (pp->coderecv == pp->codeproc)
up->errflg = CEVNT_TIMEOUT;
- else
- pp->polls++;
if (up->errflg)
refclock_report(peer, up->errflg);
up->errflg = 0;
+ pp->polls++;
}
/*
* If all nine digits have been found and compared correctly,
* determine the current offset from the time of century and the
- * sample timestamp. If in second sync, declare victory and
- * clamp the root dispersion.
+ * sample timestamp. If in second sync for a couple of minutes,
+ * declare victory.
*/
if (up->digcnt >= 9 && (up->alarm & (3 << SYNERR)) == 0) {
up->status |= INSYNC;
up->watch = 0;
pp->disp = 0;
+ pp->lastref = up->timestamp;
}
up->rsec = nsec;
if (up->status & INSYNC) {
1].digit * 10 + up->decvec[DA + 2].digit * 100;
pp->year = up->decvec[YR].digit + up->decvec[YR +
1].digit * 10;
- if (pp->year < UTCYEAR)
- pp->year += 2000;
- else
- pp->year += 1900;
+ pp->year += 2000;
L_CLR(&offset);
if (!clocktime(pp->day, pp->hour, pp->minute,
pp->second, GMT, up->timestamp.l_ui,
#define DESCRIPTION "Spectracom WWVB/GPS Receivers" /* WRU */
#define LENWWVB0 22 /* format 0 timecode length */
+#define LENWWVB1 22 /* format 1 timecode length */
#define LENWWVB2 24 /* format 2 timecode length */
#define LENWWVB3 29 /* format 3 timecode length */
#define MONLIN 15 /* number of monitoring lines */
peer->precision = PRECISION;
pp->clockdesc = DESCRIPTION;
memcpy((char *)&pp->refid, REFID, 4);
- peer->burst = NSTAGE;
+ peer->burst = MAXSTAGE;
return (1);
}
pp->lastrec = up->laststamp;
up->laststamp = trtmp;
up->tcswitch = 1;
-#ifdef DEBUG
- if (debug)
- printf("wwvb: timecode %d %s\n", pp->lencode,
- pp->a_lastcode);
-#endif
/*
* We get down to business, check the timecode format and decode
*/
syncchar = qualchar = leapchar = dstchar = ' ';
tz = 0;
- pp->msec = 0;
switch (pp->lencode) {
- case LENWWVB0:
+ case LENWWVB0:
/*
* Timecode format 0: "I ddd hh:mm:ss DTZ=nn"
"%c %3d %2d:%2d:%2d%c%cTZ=%2d",
&syncchar, &pp->day, &pp->hour, &pp->minute,
&pp->second, &tmpchar, &dstchar, &tz) == 8)
+ pp->nsec = 0;
break;
- case LENWWVB2:
+ case LENWWVB2:
/*
* Timecode format 2: "IQyy ddd hh:mm:ss.mmm LD" */
if (sscanf(pp->a_lastcode,
- "%c%c %2d %3d %2d:%2d:%2d.%3d %c",
+ "%c%c %2d %3d %2d:%2d:%2d.%3ld %c",
&syncchar, &qualchar, &pp->year, &pp->day,
- &pp->hour, &pp->minute, &pp->second, &pp->msec,
+ &pp->hour, &pp->minute, &pp->second, &pp->nsec,
&leapchar) == 9)
+ pp->nsec *= 1000000;
break;
- case LENWWVB3:
+ case LENWWVB3:
/*
* Timecode format 3: "0003I yyyymmdd hhmmss+0000SL#"
&pp->minute, &pp->second, &dstchar, &leapchar) == 8)
{
pp->day = ymd2yd(pp->year, month, day);
+ pp->nsec = 0;
break;
}
- default:
+ default:
/*
* Unknown format: If dumping internal table, record
case ' ':
pp->disp = .001;
+ pp->lastref = pp->lastrec;
break;
case 'A':
pollchar = 'T';
if (write(pp->io.fd, &pollchar, 1) != 1)
refclock_report(peer, CEVNT_FAULT);
- else
- pp->polls++;
if (peer->burst > 0)
return;
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
- record_clock_stats(&peer->srcadr, pp->a_lastcode);
refclock_receive(peer);
- peer->burst = NSTAGE;
+ record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+ if (debug)
+ printf("wwvb: timecode %d %s\n", pp->lencode,
+ pp->a_lastcode);
+#endif
+ peer->burst = MAXSTAGE;
+ pp->polls++;
/*
* If the monitor flag is set (flag4), we dump the internal