From: Harlan Stenn Date: Wed, 5 Dec 2007 06:24:01 +0000 (-0500) Subject: maximum-likelihood digit and DSYNC fixes from Dave Mills X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=332bbc487006bafed2efbc32218396f9638d4282;p=thirdparty%2Fntp.git maximum-likelihood digit and DSYNC fixes from Dave Mills bk: 47564401aucfcTXu6fR91zJoHnQWUw --- diff --git a/ChangeLog b/ChangeLog index dab00f289b..0e3dc30725 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* refclock_wwv.c: maximum-likelihood digit and DSYNC fixes from Dave Mills. * [Bug 967] preemptable associations are lost forever on a step. * ntp_config.c: [CID 48] missing "else" clause. * [Bug 833] ntpq config keyword is quote-mark unfriendly. diff --git a/ntpd/refclock_wwv.c b/ntpd/refclock_wwv.c index e126056cbc..2fb7b3e0c4 100644 --- a/ntpd/refclock_wwv.c +++ b/ntpd/refclock_wwv.c @@ -155,10 +155,10 @@ * These bits indicate various alarm conditions, which are decoded to * form the quality character included in the timecode. */ -#define CMPERR 1 /* digit or misc bit compare error */ -#define LOWERR 2 /* low bit or digit amplitude or SNR */ -#define NINERR 4 /* less than nine digits in minute */ -#define SYNERR 8 /* not tracking second sync */ +#define CMPERR 0x1 /* digit or misc bit compare error */ +#define LOWERR 0x2 /* low bit or digit amplitude or SNR */ +#define NINERR 0x4 /* less than nine digits in minute */ +#define SYNERR 0x8 /* not tracking second sync */ /* * Watchcat timeouts (watch) @@ -465,7 +465,6 @@ char dstcod[] = { struct decvec { int radix; /* radix (3, 4, 6, 10) */ int digit; /* current clock digit */ - int mldigit; /* maximum-likelihood digit */ int count; /* match count */ double digprb; /* max digit probability */ double digsnr; /* likelihood function (dB) */ @@ -2174,26 +2173,23 @@ wwv_corr4( * not considered correct until all nine clock digits have * reached threshold. This is intended as eye candy, but avoids * mistakes when the signal is low and the SNR is very marginal. - * once correctly set, the maximum-likelihood digit is ignored - * on the assumption the clock will always be correct unless for - * some reason it drifts to a different second. */ - vp->mldigit = mldigit; if (vp->digprb < BTHR || vp->digsnr < BSNR) { - vp->count = 0; up->status |= BGATE; } else { - up->status |= DSYNC; if (vp->digit != mldigit) { - vp->count = 0; up->alarm |= CMPERR; - if (!(up->status & INSYNC)) + if (vp->count > 0) + vp->count--; + if (vp->count == 0) vp->digit = mldigit; } else { if (vp->count < BCMP) vp->count++; - if (vp->count == BCMP) + if (vp->count == BCMP) { + up->status |= DSYNC; up->digcnt++; + } } } if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & @@ -2201,7 +2197,7 @@ wwv_corr4( sprintf(tbuf, "wwv4 %2d %04x %3d %4d %5.0f %2d %d %d %d %5.0f %5.1f", up->rsec - 1, up->status, up->gain, up->yepoch, - up->epomax, vp->radix, vp->digit, vp->mldigit, + up->epomax, vp->radix, vp->digit, mldigit, vp->count, vp->digprb, vp->digsnr); record_clock_stats(&peer->srcadr, tbuf); #ifdef DEBUG