SYNOPSISphc_ctl [ options ] <device> [ commands ]
DESCRIPTIONphc_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, 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.
- -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).
- Do not send messages to syslog. By default messages will be sent.
- Do not print messages to standard output. By default messages will be printed.
- Display a help message.
Prints the software version and exits.
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 ptp4l (8) or phc2sys (8)
- set seconds
- Set the PHC clock time to the value specified in seconds. Defaults to reading CLOCK_REALTIME if no value is provided.
- Get the current time of the PHC clock device.
- adj seconds
- Adjust the PHC clock by an amount of seconds provided. This argument is required.
- 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.
- Compare the PHC clock device to CLOCK_REALTIME, using the best method available.
- Display the device capabiltiies. This is the default command if no commands are provided.
- 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.
Read the current clock time from the device
- phc_ctl /dev/ptp0 get
Set the PHC clock time to CLOCK_REALTIME
- phc_ctl /dev/ptp0 set
Set PHC clock time to 0 (seconds since Epoch)
- phc_ctl /dev/ptp0 set 0.0
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.
- phc_ctl /dev/ptp0 freq 100000000 set 0.0 wait 10.0 get