Skip to content

Commit

Permalink
utils: unify scan across all utilities and update man pages
Browse files Browse the repository at this point in the history
this ensures you can do a "-S" on any utility, and it scans the same way
on all different utilities.

Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
rgetz authored and pcercuei committed Feb 17, 2022
1 parent d397c40 commit 8268715
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
7 changes: 5 additions & 2 deletions man/iio_attr.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ Read and Write IIO Context attributes
.B \-D \-\-debug-attr
Read and Write IIO Debug attributes
.TP
.B \-S, \-\-Scan
Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip:usb'. If no argument is given, it checks all that are availble.
.B \-S, \-\-scan
Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'.
Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'.
vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only)
If no argument is given, it checks all that are availble.
.TP
.B \-h, \-\-help
Tells
Expand Down
5 changes: 4 additions & 1 deletion man/iio_info.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ with no address part
.RE
.TP
.B \-S, \-\-scan
Scan for available backends
Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'.
Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'.
vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only)
If no argument is given, it checks all that are availble.
.TP
.B \-a, \-\-auto
Scan for available contexts and if only one is available use it.
Expand Down
7 changes: 6 additions & 1 deletion man/iio_readdev.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ Buffer timeout in milliseconds. 0 = no timeout. Default is 0.
.TP
.B \-a, \-\-auto
Scan for available contexts and if only one is available use it.

.TP
.B \-S, \-\-scan
Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'.
Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'.
vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only)
If no argument is given, it checks all that are availble.
.SH RETURN VALUE
If the specified device is not found, a non-zero exit code is returned.

Expand Down
6 changes: 6 additions & 0 deletions man/iio_writedev.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ normally returned from
.IP serial:[port]
.IP local
with no address part
.TP
.B \-S, \-\-scan
Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'.
Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'.
vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only)
If no argument is given, it checks all that are availble.
.RE
.TP
.B \-t \-\-trigger
Expand Down
6 changes: 6 additions & 0 deletions tests/iio_adi_xflow_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ int main(int argc, char **argv)
char unit;
int ret;
struct option *opts;
bool do_scan = false;

argw = dup_argv(MY_NAME, argc, argv);

Expand All @@ -188,6 +189,8 @@ int main(int argc, char **argv)
case 'T':
break;
case 'S':
do_scan = true;
/* FALLTHROUGH */
case 'a':
if (!optarg && argc > optind && argv[optind] != NULL
&& argv[optind][0] != '-')
Expand Down Expand Up @@ -215,6 +218,9 @@ int main(int argc, char **argv)
}
free(opts);

if (do_scan)
return EXIT_SUCCESS;

if (optind + 1 != argc) {
fprintf(stderr, "Incorrect number of arguments.\n\n");
usage(MY_NAME, options, options_descriptions);
Expand Down
6 changes: 6 additions & 0 deletions tests/iio_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int main(int argc, char **argv)
int c;
char * name;
struct option *opts;
bool do_scan = false;

argw = dup_argv(MY_NAME, argc, argv);

Expand All @@ -102,6 +103,8 @@ int main(int argc, char **argv)
case 'T':
break;
case 'S':
do_scan = true;
/* FALLTHRU */
case 'a':
if (!optarg && argc > optind && argv[optind] != NULL
&& argv[optind][0] != '-')
Expand All @@ -114,6 +117,9 @@ int main(int argc, char **argv)
}
free(opts);

if (do_scan)
return EXIT_SUCCESS;

if ((argc - optind) < 2 || (argc - optind) > 3) {
usage(MY_NAME, options, options_descriptions);
return EXIT_SUCCESS;
Expand Down

0 comments on commit 8268715

Please sign in to comment.