mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
refclock: improve precision with large offset
If a SHM or PHC refclock has a very large offset compensated by the offset option, or ignored with the pps or local option, there is a persistent loss of precision in the calculation of the sample offset using the double format. Rework the code to delay the calculation of the accumulated offset to include the specificed compensation and remaining correction of the system clock, where the calculation can be split to improve the precision. In the pps mode ignore integer seconds competely. The precision of the SOCK refclock is now limited to 1 nanosecond due to the extra double->timespec->double conversion.
This commit is contained in:
@@ -143,7 +143,7 @@ static int phc_poll(RCL_Instance instance)
|
||||
{
|
||||
struct phc_instance *phc;
|
||||
struct timespec phc_ts, sys_ts, local_ts;
|
||||
double offset, phc_err, local_err;
|
||||
double phc_err, local_err;
|
||||
|
||||
phc = (struct phc_instance *)RCL_GetDriverData(instance);
|
||||
|
||||
@@ -157,11 +157,10 @@ static int phc_poll(RCL_Instance instance)
|
||||
return 0;
|
||||
}
|
||||
|
||||
offset = UTI_DiffTimespecsToDouble(&phc_ts, &sys_ts);
|
||||
DEBUG_LOG("PHC offset: %+.9f err: %.9f",
|
||||
UTI_DiffTimespecsToDouble(&phc_ts, &sys_ts), phc_err);
|
||||
|
||||
DEBUG_LOG("PHC offset: %+.9f err: %.9f", offset, phc_err);
|
||||
|
||||
return RCL_AddSample(instance, &sys_ts, offset, LEAP_Normal);
|
||||
return RCL_AddSample(instance, &sys_ts, &phc_ts, LEAP_Normal);
|
||||
}
|
||||
|
||||
RefclockDriver RCL_PHC_driver = {
|
||||
|
||||
Reference in New Issue
Block a user