Commit 61950e82 authored by Stefan Sørensen's avatar Stefan Sørensen Committed by David S. Miller

ptp: Allow selecting trigger/event index in testptp

Currently the trigger/event is hardcoded to 0, this patch adds
a new command line argument -i to select an arbitrary trigger/
event.
Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a13aff06
...@@ -117,6 +117,7 @@ static void usage(char *progname) ...@@ -117,6 +117,7 @@ static void usage(char *progname)
" -f val adjust the ptp clock frequency by 'val' ppb\n" " -f val adjust the ptp clock frequency by 'val' ppb\n"
" -g get the ptp clock time\n" " -g get the ptp clock time\n"
" -h prints this message\n" " -h prints this message\n"
" -i val index for event/trigger\n"
" -k val measure the time offset between system and phc clock\n" " -k val measure the time offset between system and phc clock\n"
" for 'val' times (Maximum 25)\n" " for 'val' times (Maximum 25)\n"
" -p val enable output with a period of 'val' nanoseconds\n" " -p val enable output with a period of 'val' nanoseconds\n"
...@@ -154,6 +155,7 @@ int main(int argc, char *argv[]) ...@@ -154,6 +155,7 @@ int main(int argc, char *argv[])
int capabilities = 0; int capabilities = 0;
int extts = 0; int extts = 0;
int gettime = 0; int gettime = 0;
int index = 0;
int oneshot = 0; int oneshot = 0;
int pct_offset = 0; int pct_offset = 0;
int n_samples = 0; int n_samples = 0;
...@@ -167,7 +169,7 @@ int main(int argc, char *argv[]) ...@@ -167,7 +169,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:ghk:p:P:sSt:v"))) { while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:p:P:sSt:v"))) {
switch (c) { switch (c) {
case 'a': case 'a':
oneshot = atoi(optarg); oneshot = atoi(optarg);
...@@ -190,6 +192,9 @@ int main(int argc, char *argv[]) ...@@ -190,6 +192,9 @@ int main(int argc, char *argv[])
case 'g': case 'g':
gettime = 1; gettime = 1;
break; break;
case 'i':
index = atoi(optarg);
break;
case 'k': case 'k':
pct_offset = 1; pct_offset = 1;
n_samples = atoi(optarg); n_samples = atoi(optarg);
...@@ -301,7 +306,7 @@ int main(int argc, char *argv[]) ...@@ -301,7 +306,7 @@ int main(int argc, char *argv[])
if (extts) { if (extts) {
memset(&extts_request, 0, sizeof(extts_request)); memset(&extts_request, 0, sizeof(extts_request));
extts_request.index = 0; extts_request.index = index;
extts_request.flags = PTP_ENABLE_FEATURE; extts_request.flags = PTP_ENABLE_FEATURE;
if (ioctl(fd, PTP_EXTTS_REQUEST, &extts_request)) { if (ioctl(fd, PTP_EXTTS_REQUEST, &extts_request)) {
perror("PTP_EXTTS_REQUEST"); perror("PTP_EXTTS_REQUEST");
...@@ -375,7 +380,7 @@ int main(int argc, char *argv[]) ...@@ -375,7 +380,7 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
memset(&perout_request, 0, sizeof(perout_request)); memset(&perout_request, 0, sizeof(perout_request));
perout_request.index = 0; perout_request.index = index;
perout_request.start.sec = ts.tv_sec + 2; perout_request.start.sec = ts.tv_sec + 2;
perout_request.start.nsec = 0; perout_request.start.nsec = 0;
perout_request.period.sec = 0; perout_request.period.sec = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment