Discussion:
[Linuxptp-devel] [PATCH 2/2] phc2sys: allow PPS loop only with system clock.
Miroslav Lichvar
2013-01-17 17:31:40 UTC
Permalink
The PPS time stamps are always made by the system clock, don't allow
running the PPS loop with other clocks.

Signed-off-by: Miroslav Lichvar <***@redhat.com>
---
phc2sys.8 | 3 ++-
phc2sys.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/phc2sys.8 b/phc2sys.8
index adce4ad..a5051c8 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -54,7 +54,8 @@ should be already close to the correct time before
.B phc2sys
is started or the
.B \-s
-option should be used too.
+option should be used too. This option can be used only with the system clock as
+the slave clock.
.TP
.BI \-s " phc-device"
Specify the master clock by device (e.g. /dev/ptp0) or name (e.g. CLOCK_REALTIME
diff --git a/phc2sys.c b/phc2sys.c
index 1c0d8b2..988a3f0 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -378,7 +378,8 @@ int main(int argc, char *argv[])
src = clock_open(phc_device);
}
if (!(device || src != CLOCK_INVALID) ||
- dst_clock.clkid == CLOCK_INVALID) {
+ dst_clock.clkid == CLOCK_INVALID ||
+ (device && dst_clock.clkid != CLOCK_REALTIME)) {
usage(progname);
return -1;
}
--
1.7.11.7
Richard Cochran
2013-01-23 08:47:45 UTC
Permalink
In the PPS loop, instead of setting the system clock from the PHC only
once on start, read PHC with each PPS sample and use the time stamp to
get the whole number of seconds in the offset. This will prevent phc2sys
from losing track of the system clock.
Also, check if the PPS is synchronized to the PHC.
---
Both patches applied.

Thanks,
Richard

Loading...