From ed904f08a4b2221386d2b4ae79baab6185441d16 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 4 Jan 2017 15:46:41 +0100 Subject: [PATCH] hwclock: return timestamp error For now, when converting a raw timestamp, return error of the last sample as the maximum error of the timestamp. This is needed to include the PHC reading delay in the NTP dispersion. --- hwclock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hwclock.c b/hwclock.c index 5ddd5b5..c44a795 100644 --- a/hwclock.c +++ b/hwclock.c @@ -55,6 +55,9 @@ struct HCL_Instance_Record { /* Number of samples */ int n_samples; + /* Maximum error of the last sample */ + double last_err; + /* Flag indicating the offset and frequency values are valid */ int valid_coefs; @@ -151,6 +154,7 @@ HCL_AccumulateSample(HCL_Instance clock, struct timespec *hw_ts, clock->n_samples++; clock->hw_ref = *hw_ts; clock->local_ref = *local_ts; + clock->last_err = err; /* Get new coefficients */ clock->valid_coefs = @@ -196,9 +200,9 @@ HCL_CookTime(HCL_Instance clock, struct timespec *raw, struct timespec *cooked, offset = clock->offset + elapsed / clock->frequency; UTI_AddDoubleToTimespec(&clock->local_ref, offset, cooked); - /* Estimation of the error is not implemented yet */ + /* Fow now, just return the error of the last sample */ if (err) - *err = 0.0; + *err = clock->last_err; return 1; }