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:
@smallexample
spusa# ./lib/fdelay-board-time 25.5; ./lib/fdelay-board-time get
25.500661824
25.504007360
spusa# ./lib/fdelay-board-time get
34.111048968
spusa# ./lib/fdelay-board-time host
......@@ -1404,6 +1404,11 @@ to validate the library works as expected:
1335974946.493415600
@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 ==========================================================================
@node Input Configuration
@section Input Configuration
......
......@@ -11,12 +11,22 @@ int main(int argc, char **argv)
struct fdelay_board *b;
int i, get = 0, host = 0;
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) {
fprintf(stderr, "%s: Use \"%s \"get\"|\"host\"|"
fprintf(stderr, "%s: Use \"%s [-i <devindex> \"get\"|\"host\"|"
"<float-value>\"\n", argv[0], argv[0]);
exit(1);
}
/* Crappy parser */
if (!strcmp(argv[1], "get"))
get = 1;
......@@ -47,18 +57,19 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: no boards found\n", argv[0]);
exit(1);
}
if (i != 1) {
fprintf(stderr, "%s: found %i boards, using first one\n",
argv[0], i);
}
if (i != 1)
fprintf(stderr, "%s: found %i boards\n", argv[0], i);
b = fdelay_open(0, -1);
b = fdelay_open(dev, -1);
if (!b) {
fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0],
strerror(errno));
exit(1);
}
if (i != 1)
fprintf(stderr, "%s: using board %d\n", argv[0], dev);
if (get) {
if (fdelay_get_time(b, &t) < 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