]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
hwclock: return timestamp error
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 4 Jan 2017 14:46:41 +0000 (15:46 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 6 Jan 2017 12:12:19 +0000 (13:12 +0100)
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

index 5ddd5b583a7c2602629353eb2005f84565a7316d..c44a795034bbce83739b54fcb4eeeeb9b1753059 100644 (file)
--- 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;
 }