From: Miroslav Lichvar Date: Fri, 23 May 2014 13:22:11 +0000 (+0200) Subject: refclock: don't include average dispersion in unfiltered samples X-Git-Tag: 1.30-pre1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26e00ffbeb608f43106fec96c94629dbe74e87fd;p=thirdparty%2Fchrony.git refclock: don't include average dispersion in unfiltered samples The dispersion of refclock samples before filtering now includes only offset correction error and precision. This should fix a problem where locked PPS got stuck with large average dispersion and didn't accept new samples due failing check of offset and dispersion. --- diff --git a/refclock.c b/refclock.c index 0cd47541..67f05889 100644 --- a/refclock.c +++ b/refclock.c @@ -351,7 +351,7 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset, LCL_GetOffsetCorrection(sample_time, &correction, &dispersion); UTI_AddDoubleToTimeval(sample_time, correction, &cooked_time); - dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter); + dispersion += instance->precision; if (!valid_sample_time(instance, sample_time)) return 0; @@ -391,7 +391,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second) leap = LEAP_Normal; LCL_GetOffsetCorrection(pulse_time, &correction, &dispersion); UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time); - dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter); + dispersion += instance->precision; if (!valid_sample_time(instance, pulse_time)) return 0; @@ -418,6 +418,8 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second) return 0; } + ref_dispersion += filter_get_avg_sample_dispersion(&refclocks[instance->lock_ref].filter); + UTI_DiffTimevalsToDouble(&sample_diff, &cooked_time, &ref_sample_time); if (fabs(sample_diff) >= 2.0 / rate) { DEBUG_LOG(LOGF_Refclock, "refclock pulse ignored samplediff=%.9f", @@ -829,8 +831,6 @@ filter_get_sample(struct MedianFilter *filter, struct timeval *sample_time, doub y /= n; e /= n; - e -= sqrt(filter->avg_var); - if (n >= 4) { double b0, b1, s2, sb0, sb1;