forked from richardcochran/linuxptp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linuxptp: add phc_ctl program to help debug PHC devices
This is an updated version of a script I wrote a couple years ago for debugging the PHC when writing a new driver. I figured that it might be handy for the LinuxPTP project to include, as it can give some insight into the PHC directly. I have updated it to make use of the shared code here, in order to reduce duplication. Hopefully this is of some use to everyone. Signed-off-by: Jacob Keller <[email protected]>
- Loading branch information
1 parent
3e858ba
commit bdb6a35
Showing
4 changed files
with
684 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/phc2sys | ||
/pmc | ||
/ptp4l | ||
/phc_ctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
.TH PHC_CTL 8 "June 2014" "linuxptp" | ||
.SH NAME | ||
phc_ctl \- directly control PHC device clock | ||
|
||
.SH SYNOPSIS | ||
.B phc_ctl | ||
[ options ] <device> [ commands ] | ||
|
||
.SH DESCRIPTION | ||
.B phc_ctl | ||
is a program which can be used to directly control a PHC clock device. | ||
Typically, it is used for debugging purposes, and has little use for general | ||
control of the device. For general control of PHC clock devices, | ||
.B phc2sys (8) | ||
should be preferred. | ||
|
||
<device> may be either CLOCK_REALTIME, any /dev/ptpX device, or any ethernet | ||
device which supports ethtool's get_ts_info ioctl. | ||
|
||
.SH OPTIONS | ||
.TP | ||
.BI \-l " print-level" | ||
Set the maximum syslog level of messages which should be printed or sent to the | ||
system logger. The default is 6 (LOG_INFO). | ||
.TP | ||
.BI \-q | ||
Do not send messages to syslog. By default messages will be sent. | ||
.TP | ||
.BI \-Q | ||
Do not print messages to standard output. By default messages will be printed. | ||
.TP | ||
.BI \-h | ||
Display a help message. | ||
.TP | ||
.B \-v | ||
Prints the software version and exits. | ||
|
||
.SH COMMANDS | ||
|
||
.B phc_ctl | ||
is controlled by passing commands which take either an optional or required | ||
parameter. The commands (outlined below) will control aspects of the PHC clock | ||
device. These commands may be useful for inspecting or debugging the PHC | ||
driver, but may have adverse side effects on running instances of | ||
.B ptp4l (8) | ||
or | ||
.B phc2sys (8) | ||
|
||
.TP | ||
.BI set " seconds" | ||
Set the PHC clock time to the value specified in seconds. Defaults to reading | ||
CLOCK_REALTIME if no value is provided. | ||
.TP | ||
.BI get | ||
Get the current time of the PHC clock device. | ||
.TP | ||
.BI adj " seconds" | ||
Adjust the PHC clock by an amount of seconds provided. This argument is required. | ||
.TP | ||
.BI freq " ppb" | ||
Adjust the frequency of the PHC clock by the specified parts per billion. If no | ||
argument is provided, it will attempt to read the current frequency and report | ||
it. | ||
.TP | ||
.BI cmp | ||
Compare the PHC clock device to CLOCK_REALTIME, using the best method available. | ||
.TP | ||
.BI caps | ||
Display the device capabiltiies. This is the default command if no commands are | ||
provided. | ||
.TP | ||
.BI wait " seconds" | ||
Sleep the process for the specified period of time, waking up and resuming | ||
afterwards. This command may be useful for sanity checking whether the PHC | ||
clock is running as expected. | ||
|
||
The arguments specified in seconds are read as double precision floating point | ||
values, and will scale to nanoseconds. This means providing a value of 5.5 | ||
means 5 and one half seconds. This allows specifying fairly precise values for time. | ||
|
||
.SH EXAMPLES | ||
|
||
Read the current clock time from the device | ||
.RS | ||
\f(CWphc_ctl /dev/ptp0 get\fP | ||
.RE | ||
|
||
Set the PHC clock time to CLOCK_REALTIME | ||
.RS | ||
\f(CWphc_ctl /dev/ptp0 set\fP | ||
.RE | ||
|
||
Set PHC clock time to 0 (seconds since Epoch) | ||
.RS | ||
\f(CWphc_ctl /dev/ptp0 set 0.0\fP | ||
.RE | ||
|
||
Quickly sanity check frequency slewing by setting slewing frequency by positive | ||
10%, resetting clock to 0.0 time, waiting for 10 seconds, and then reading | ||
time. The time read back should be (roughly) 11 seconds, since the clock was | ||
slewed 10% faster. | ||
.RS | ||
\f(CWphc_ctl /dev/ptp0 freq 100000000 set 0.0 wait 10.0 get | ||
.RE | ||
|
||
.SH SEE ALSO | ||
.BR ptp4l (8) | ||
.BR phc2sys (8) |
Oops, something went wrong.