phc2sys: add selecting clock by name.
This allows synchronization of a PHC to the system clock. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
2f3b9f718f
commit
d0714a9fac
|
@ -53,8 +53,8 @@ is started or the
|
||||||
option should be used too.
|
option should be used too.
|
||||||
.TP
|
.TP
|
||||||
.BI \-s " phc-device"
|
.BI \-s " phc-device"
|
||||||
Specify the device of the master clock (e.g. /dev/ptp0). When this option is
|
Specify the master clock by device (e.g. /dev/ptp0) or name (e.g. CLOCK_REALTIME
|
||||||
used together with the
|
for the system clock). When this option is used together with the
|
||||||
.B \-d
|
.B \-d
|
||||||
option, the master clock is read only on start to fix an offset over 0.5
|
option, the master clock is read only on start to fix an offset over 0.5
|
||||||
seconds which cannot be fixed with PPS alone.
|
seconds which cannot be fixed with PPS alone.
|
||||||
|
@ -65,8 +65,8 @@ Similar to the
|
||||||
option, but specified by the interface which provides the master clock.
|
option, but specified by the interface which provides the master clock.
|
||||||
.TP
|
.TP
|
||||||
.BI \-c " phc-device"
|
.BI \-c " phc-device"
|
||||||
Specify the device of the slave clock (e.g. /dev/ptp1). The default slave clock
|
Specify the slave clock by device (e.g. /dev/ptp1) or name. The default is
|
||||||
is the system clock (CLOCK_REALTIME).
|
CLOCK_REALTIME (the system clock).
|
||||||
.TP
|
.TP
|
||||||
.BI \-P " kp"
|
.BI \-P " kp"
|
||||||
Specify the proportional constant of the PI controller. The default is 0.7.
|
Specify the proportional constant of the PI controller. The default is 0.7.
|
||||||
|
|
12
phc2sys.c
12
phc2sys.c
|
@ -44,7 +44,17 @@
|
||||||
|
|
||||||
static clockid_t clock_open(char *device)
|
static clockid_t clock_open(char *device)
|
||||||
{
|
{
|
||||||
int fd = open(device, O_RDWR);
|
int fd;
|
||||||
|
|
||||||
|
if (device[0] != '/') {
|
||||||
|
if (!strcasecmp(device, "CLOCK_REALTIME"))
|
||||||
|
return CLOCK_REALTIME;
|
||||||
|
|
||||||
|
fprintf(stderr, "unknown clock %s\n", device);
|
||||||
|
return CLOCK_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open(device, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "cannot open %s: %m\n", device);
|
fprintf(stderr, "cannot open %s: %m\n", device);
|
||||||
return CLOCK_INVALID;
|
return CLOCK_INVALID;
|
||||||
|
|
Loading…
Reference in New Issue