From a60fc73e7b212232e1476e3bb00fb09540267063 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 19 Jan 2017 16:28:49 +0100 Subject: [PATCH] refclock_phc: add nocrossts option --- doc/chrony.conf.adoc | 7 ++++--- refclock_phc.c | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 3dc4189..e4b0616 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -402,9 +402,10 @@ refclock SOCK /var/run/chrony.ttyS0.sock *PHC*::: PTP hardware clock (PHC) driver. The parameter is the path to the device of the PTP clock, which for example can be synchronised by *ptp4l* from -http://linuxptp.sourceforge.net[*linuxptp*]. PTP clocks are typically kept in -TAI instead of UTC, so the *offset* option should be used to compensate for the -current UTC-TAI offset. For example: +http://linuxptp.sourceforge.net[*linuxptp*]. String *:nocrossts* can be +appended to the path to disable use of precise cross timestamping. PTP clocks +are typically kept in TAI instead of UTC, so the *offset* option should be used +to compensate for the current UTC-TAI offset. For example: + ---- refclock PHC /dev/ptp0 poll 3 dpoll -2 offset -36 diff --git a/refclock_phc.c b/refclock_phc.c index 2bbed3d..e505b32 100644 --- a/refclock_phc.c +++ b/refclock_phc.c @@ -42,6 +42,7 @@ struct phc_instance { int fd; int mode; + int nocrossts; }; static int phc_initialise(RCL_Instance instance) @@ -61,6 +62,7 @@ static int phc_initialise(RCL_Instance instance) phc = MallocNew(struct phc_instance); phc->fd = phc_fd; phc->mode = 0; + phc->nocrossts = RCL_GetDriverOption(instance, "nocrossts") ? 1 : 0; RCL_SetDriverData(instance, phc); return 1; @@ -83,8 +85,8 @@ static int phc_poll(RCL_Instance instance) phc = (struct phc_instance *)RCL_GetDriverData(instance); - if (!SYS_Linux_GetPHCSample(phc->fd, 0, RCL_GetPrecision(instance), &phc->mode, - &phc_ts, &sys_ts, &err)) + if (!SYS_Linux_GetPHCSample(phc->fd, phc->nocrossts, RCL_GetPrecision(instance), + &phc->mode, &phc_ts, &sys_ts, &err)) return 0; offset = UTI_DiffTimespecsToDouble(&phc_ts, &sys_ts);