]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: add option to treat non-PPS refclocks as PPS
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 11 May 2017 11:58:17 +0000 (13:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 26 May 2017 11:33:53 +0000 (13:33 +0200)
Add pps option to the refclock directive to force chronyd to treat any
refclock as a PPS refclock. This is intended for refclocks that may
provide time off by a whole number of seconds due to missing or wrong
TAI/GPS->UTC conversion.

conf.c
refclock.c
refclock.h

diff --git a/conf.c b/conf.c
index d400ee07c0d3fe63a0e3304faa0c75dcfc06e6d3..aafdba31ab2457d7498e6f690d052ad3ecd8bffa 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -674,7 +674,7 @@ static void
 parse_refclock(char *line)
 {
   int n, poll, dpoll, filter_length, pps_rate, min_samples, max_samples, sel_options;
-  int max_lock_age;
+  int max_lock_age, pps_forced;
   uint32_t ref_id, lock_ref_id;
   double offset, delay, precision, max_dispersion;
   char *p, *cmd, *name, *param;
@@ -684,6 +684,7 @@ parse_refclock(char *line)
   poll = 4;
   dpoll = 0;
   filter_length = 64;
+  pps_forced = 0;
   pps_rate = 0;
   min_samples = SRC_DEFAULT_MINSAMPLES;
   max_samples = SRC_DEFAULT_MAXSAMPLES;
@@ -756,6 +757,9 @@ parse_refclock(char *line)
     } else if (!strcasecmp(cmd, "delay")) {
       if (sscanf(line, "%lf%n", &delay, &n) != 1)
         break;
+    } else if (!strcasecmp(cmd, "pps")) {
+      n = 0;
+      pps_forced = 1;
     } else if (!strcasecmp(cmd, "precision")) {
       if (sscanf(line, "%lf%n", &precision, &n) != 1)
         break;
@@ -791,6 +795,7 @@ parse_refclock(char *line)
   refclock->driver_poll = dpoll;
   refclock->poll = poll;
   refclock->filter_length = filter_length;
+  refclock->pps_forced = pps_forced;
   refclock->pps_rate = pps_rate;
   refclock->min_samples = min_samples;
   refclock->max_samples = max_samples;
index 82643aed93612d3101d22b0341177b407154af20..706e2ba4e3f6eae50836372b99b5fe5258fb00d8 100644 (file)
@@ -75,6 +75,7 @@ struct RCL_Instance_Record {
   int driver_polled;
   int poll;
   int leap_status;
+  int pps_forced;
   int pps_rate;
   int pps_active;
   int max_lock_age;
@@ -198,6 +199,7 @@ RCL_AddRefclock(RefclockParameters *params)
   inst->poll = params->poll;
   inst->driver_polled = 0;
   inst->leap_status = LEAP_Normal;
+  inst->pps_forced = params->pps_forced;
   inst->pps_rate = params->pps_rate;
   inst->pps_active = 0;
   inst->max_lock_age = params->max_lock_age;
@@ -362,6 +364,9 @@ RCL_AddSample(RCL_Instance instance, struct timespec *sample_time, double offset
   double correction, dispersion;
   struct timespec cooked_time;
 
+  if (instance->pps_forced)
+    return RCL_AddPulse(instance, sample_time, -offset);
+
   LCL_GetOffsetCorrection(sample_time, &correction, &dispersion);
   UTI_AddDoubleToTimespec(sample_time, correction, &cooked_time);
   dispersion += instance->precision;
index 1fc5f92e80b7aa4e8076d9c9585f71a17017fa5e..a4201c24669a438c62b4dbe567b97ea6f5ac77ef 100644 (file)
@@ -37,6 +37,7 @@ typedef struct {
   int driver_poll;
   int poll;
   int filter_length;
+  int pps_forced;
   int pps_rate;
   int min_samples;
   int max_samples;