forked from Minki/linux
ptp: Add a command line option in testptp to set a specific PTP time
Signed-off-by: Manfred Rudigier <manfred.rudigier@omicron.at> Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b620cb3e82
commit
271c83de61
@ -131,7 +131,8 @@ static void usage(char *progname)
|
|||||||
" -P val enable or disable (val=1|0) the system clock PPS\n"
|
" -P val enable or disable (val=1|0) the system clock PPS\n"
|
||||||
" -s set the ptp clock time from the system time\n"
|
" -s set the ptp clock time from the system time\n"
|
||||||
" -S set the system time from the ptp clock time\n"
|
" -S set the system time from the ptp clock time\n"
|
||||||
" -t val shift the ptp clock time by 'val' seconds\n",
|
" -t val shift the ptp clock time by 'val' seconds\n"
|
||||||
|
" -T val set the ptp clock time to 'val' seconds\n",
|
||||||
progname);
|
progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +173,7 @@ int main(int argc, char *argv[])
|
|||||||
int perout = -1;
|
int perout = -1;
|
||||||
int pin_index = -1, pin_func;
|
int pin_index = -1, pin_func;
|
||||||
int pps = -1;
|
int pps = -1;
|
||||||
|
int seconds = 0;
|
||||||
int settime = 0;
|
int settime = 0;
|
||||||
|
|
||||||
int64_t t1, t2, tp;
|
int64_t t1, t2, tp;
|
||||||
@ -179,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
progname = strrchr(argv[0], '/');
|
progname = strrchr(argv[0], '/');
|
||||||
progname = progname ? 1+progname : argv[0];
|
progname = progname ? 1+progname : argv[0];
|
||||||
while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:v"))) {
|
while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:T:v"))) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
oneshot = atoi(optarg);
|
oneshot = atoi(optarg);
|
||||||
@ -234,6 +236,10 @@ int main(int argc, char *argv[])
|
|||||||
case 't':
|
case 't':
|
||||||
adjtime = atoi(optarg);
|
adjtime = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'T':
|
||||||
|
settime = 3;
|
||||||
|
seconds = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(progname);
|
usage(progname);
|
||||||
return 0;
|
return 0;
|
||||||
@ -326,6 +332,16 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settime == 3) {
|
||||||
|
ts.tv_sec = seconds;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
if (clock_settime(clkid, &ts)) {
|
||||||
|
perror("clock_settime");
|
||||||
|
} else {
|
||||||
|
puts("set time okay");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (extts) {
|
if (extts) {
|
||||||
memset(&extts_request, 0, sizeof(extts_request));
|
memset(&extts_request, 0, sizeof(extts_request));
|
||||||
extts_request.index = index;
|
extts_request.index = index;
|
||||||
|
Loading…
Reference in New Issue
Block a user