refclock: add option to treat non-PPS refclocks as PPS
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.
This commit is contained in:
parent
cff15f91d4
commit
f31f68ae8e
3 changed files with 12 additions and 1 deletions
7
conf.c
7
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue