Modify minimum skew checking

This commit is contained in:
Miroslav Lichvar 2013-06-14 16:27:15 +02:00
parent 3d1be1cd75
commit f7e2d7c2ec

View file

@ -39,6 +39,9 @@
/* ================================================== */ /* ================================================== */
/* The minimum allowed skew */
#define MIN_SKEW 1.0e-12
static int are_we_synchronised; static int are_we_synchronised;
static int enable_local_stratum; static int enable_local_stratum;
static int local_stratum; static int local_stratum;
@ -174,6 +177,8 @@ REF_Initialise(void)
/* We have read valid data */ /* We have read valid data */
our_frequency_ppm = file_freq_ppm; our_frequency_ppm = file_freq_ppm;
our_skew = 1.0e-6 * file_skew_ppm; our_skew = 1.0e-6 * file_skew_ppm;
if (our_skew < MIN_SKEW)
our_skew = MIN_SKEW;
LOG(LOGS_INFO, LOGF_Reference, "Frequency %.3f +/- %.3f ppm read from %s", file_freq_ppm, file_skew_ppm, drift_file); LOG(LOGS_INFO, LOGF_Reference, "Frequency %.3f +/- %.3f ppm read from %s", file_freq_ppm, file_skew_ppm, drift_file);
LCL_SetAbsoluteFrequency(our_frequency_ppm); LCL_SetAbsoluteFrequency(our_frequency_ppm);
} else { } else {
@ -688,11 +693,9 @@ REF_SetReference(int stratum,
assert(initialised); assert(initialised);
/* Avoid getting NaNs */ /* Guard against dividing by zero */
if (skew < 1e-12) if (skew < MIN_SKEW)
skew = 1e-12; skew = MIN_SKEW;
if (our_skew < 1e-12)
our_skew = 1e-12;
/* If we get a serious rounding error in the source stats regression /* If we get a serious rounding error in the source stats regression
processing, there is a remote chance that the skew argument is a processing, there is a remote chance that the skew argument is a
@ -869,6 +872,9 @@ REF_SetManualReference
... */ ... */
are_we_synchronised = 0; are_we_synchronised = 0;
if (skew < MIN_SKEW)
skew = MIN_SKEW;
our_skew = skew; our_skew = skew;
our_residual_freq = 0.0; our_residual_freq = 0.0;