Add refclock precision
This commit is contained in:
parent
b9b0326d15
commit
5fb5551c36
4 changed files with 18 additions and 3 deletions
|
@ -2315,6 +2315,9 @@ to be inaccurate (in seconds). Increasing the value is useful to
|
|||
avoid having no majority in the source selection algorithm or to make
|
||||
the algorithm prefer other refclocks. The default is 1e-9 (1
|
||||
nanosecond).
|
||||
@item precision
|
||||
Refclock precision (in seconds). The default is 1e-6 (1 microsecond)
|
||||
for SHM refclock, and 1e-9 (1 nanosecond) for SOCK and PPS refclocks.
|
||||
@end table
|
||||
|
||||
@c }}}
|
||||
|
|
7
conf.c
7
conf.c
|
@ -437,7 +437,7 @@ parse_refclock(const char *line)
|
|||
{
|
||||
int i, n, poll, dpoll, filter_length, pps_rate;
|
||||
unsigned long ref_id, lock_ref_id;
|
||||
double offset, delay;
|
||||
double offset, delay, precision;
|
||||
const char *tmp;
|
||||
char name[5], cmd[10 + 1], *param;
|
||||
unsigned char ref[5];
|
||||
|
@ -452,6 +452,7 @@ parse_refclock(const char *line)
|
|||
pps_rate = 0;
|
||||
offset = 0.0;
|
||||
delay = 1e-9;
|
||||
precision = 0.0;
|
||||
ref_id = 0;
|
||||
lock_ref_id = 0;
|
||||
|
||||
|
@ -507,6 +508,9 @@ parse_refclock(const char *line)
|
|||
} else if (!strncasecmp(cmd, "delay", 5)) {
|
||||
if (sscanf(line, "%lf%n", &delay, &n) != 1)
|
||||
break;
|
||||
} else if (!strncasecmp(cmd, "precision", 9)) {
|
||||
if (sscanf(line, "%lf%n", &precision, &n) != 1)
|
||||
break;
|
||||
} else {
|
||||
LOG(LOGS_WARN, LOGF_Configure, "Unknown refclock parameter %s at line %d", cmd, line_number);
|
||||
break;
|
||||
|
@ -522,6 +526,7 @@ parse_refclock(const char *line)
|
|||
refclock_sources[i].pps_rate = pps_rate;
|
||||
refclock_sources[i].offset = offset;
|
||||
refclock_sources[i].delay = delay;
|
||||
refclock_sources[i].precision = precision;
|
||||
refclock_sources[i].ref_id = ref_id;
|
||||
refclock_sources[i].lock_ref_id = lock_ref_id;
|
||||
|
||||
|
|
10
refclock.c
10
refclock.c
|
@ -78,6 +78,7 @@ struct RCL_Instance_Record {
|
|||
unsigned long lock_ref;
|
||||
double offset;
|
||||
double delay;
|
||||
double precision;
|
||||
SCH_TimeoutID timeout_id;
|
||||
SRC_Instance source;
|
||||
};
|
||||
|
@ -166,11 +167,14 @@ RCL_AddRefclock(RefclockParameters *params)
|
|||
|
||||
if (strncmp(params->driver_name, "SHM", 4) == 0) {
|
||||
inst->driver = &RCL_SHM_driver;
|
||||
inst->precision = 1e-6;
|
||||
} else if (strncmp(params->driver_name, "SOCK", 4) == 0) {
|
||||
inst->driver = &RCL_SOCK_driver;
|
||||
inst->precision = 1e-9;
|
||||
pps_source = 1;
|
||||
} else if (strncmp(params->driver_name, "PPS", 4) == 0) {
|
||||
inst->driver = &RCL_PPS_driver;
|
||||
inst->precision = 1e-9;
|
||||
pps_source = 1;
|
||||
} else {
|
||||
LOG_FATAL(LOGF_Refclock, "unknown refclock driver %s", params->driver_name);
|
||||
|
@ -194,6 +198,8 @@ RCL_AddRefclock(RefclockParameters *params)
|
|||
inst->lock_ref = params->lock_ref_id;
|
||||
inst->offset = params->offset;
|
||||
inst->delay = params->delay;
|
||||
if (params->precision > 0.0)
|
||||
inst->precision = params->precision;
|
||||
inst->timeout_id = -1;
|
||||
inst->source = NULL;
|
||||
|
||||
|
@ -351,7 +357,7 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset,
|
|||
|
||||
LCL_GetOffsetCorrection(sample_time, &correction, &dispersion);
|
||||
UTI_AddDoubleToTimeval(sample_time, correction, &cooked_time);
|
||||
dispersion += LCL_GetSysPrecisionAsQuantum() + filter_get_avg_sample_dispersion(&instance->filter);
|
||||
dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
|
||||
|
||||
if (!valid_sample_time(instance, sample_time))
|
||||
return 0;
|
||||
|
@ -377,7 +383,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
|||
|
||||
LCL_GetOffsetCorrection(pulse_time, &correction, &dispersion);
|
||||
UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time);
|
||||
dispersion += LCL_GetSysPrecisionAsQuantum() + filter_get_avg_sample_dispersion(&instance->filter);
|
||||
dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
|
||||
|
||||
if (!valid_sample_time(instance, pulse_time))
|
||||
return 0;
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct {
|
|||
unsigned long lock_ref_id;
|
||||
double offset;
|
||||
double delay;
|
||||
double precision;
|
||||
} RefclockParameters;
|
||||
|
||||
typedef struct RCL_Instance_Record *RCL_Instance;
|
||||
|
|
Loading…
Reference in a new issue