Commit 530e444c authored by Luis Fernando Ruiz's avatar Luis Fernando Ruiz Committed by Alessandro Rubini

fine-delay/lib: added a device number parameter to fdelay-board-time

parent 363af122
...@@ -1396,7 +1396,7 @@ to validate the library works as expected: ...@@ -1396,7 +1396,7 @@ to validate the library works as expected:
@smallexample @smallexample
spusa# ./lib/fdelay-board-time 25.5; ./lib/fdelay-board-time get spusa# ./lib/fdelay-board-time 25.5; ./lib/fdelay-board-time get
25.500661824 25.504007360
spusa# ./lib/fdelay-board-time get spusa# ./lib/fdelay-board-time get
34.111048968 34.111048968
spusa# ./lib/fdelay-board-time host spusa# ./lib/fdelay-board-time host
...@@ -1404,6 +1404,11 @@ to validate the library works as expected: ...@@ -1404,6 +1404,11 @@ to validate the library works as expected:
1335974946.493415600 1335974946.493415600
@end smallexample @end smallexample
If more than one @i{fine-delay} board is found, the program will also
print to @i{stderr} how many boards it finds and which it is using.
To select a board different from the default, you can pass
``@t{-i <index>}'' to theprogram, where the index starts from zero.
@c ========================================================================== @c ==========================================================================
@node Input Configuration @node Input Configuration
@section Input Configuration @section Input Configuration
......
...@@ -11,12 +11,22 @@ int main(int argc, char **argv) ...@@ -11,12 +11,22 @@ int main(int argc, char **argv)
struct fdelay_board *b; struct fdelay_board *b;
int i, get = 0, host = 0; int i, get = 0, host = 0;
struct fdelay_time t; struct fdelay_time t;
int dev = 0;
/* Parse, and kill "-i <devindex>" */
if (argc > 2 && !strcmp(argv[1], "-i")) {
dev = strtol(argv[2], NULL, 0);
argv[2] = argv[0];
argc -= 2;
}
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "%s: Use \"%s \"get\"|\"host\"|" fprintf(stderr, "%s: Use \"%s [-i <devindex> \"get\"|\"host\"|"
"<float-value>\"\n", argv[0], argv[0]); "<float-value>\"\n", argv[0], argv[0]);
exit(1); exit(1);
} }
/* Crappy parser */ /* Crappy parser */
if (!strcmp(argv[1], "get")) if (!strcmp(argv[1], "get"))
get = 1; get = 1;
...@@ -47,18 +57,19 @@ int main(int argc, char **argv) ...@@ -47,18 +57,19 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: no boards found\n", argv[0]); fprintf(stderr, "%s: no boards found\n", argv[0]);
exit(1); exit(1);
} }
if (i != 1) { if (i != 1)
fprintf(stderr, "%s: found %i boards, using first one\n", fprintf(stderr, "%s: found %i boards\n", argv[0], i);
argv[0], i);
}
b = fdelay_open(0, -1); b = fdelay_open(dev, -1);
if (!b) { if (!b) {
fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0], fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0],
strerror(errno)); strerror(errno));
exit(1); exit(1);
} }
if (i != 1)
fprintf(stderr, "%s: using board %d\n", argv[0], dev);
if (get) { if (get) {
if (fdelay_get_time(b, &t) < 0) { if (fdelay_get_time(b, &t) < 0) {
fprintf(stderr, "%s: fdelay_get_time(): %s\n", argv[0], fprintf(stderr, "%s: fdelay_get_time(): %s\n", argv[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