mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
tools:iio: rework program parameters
In generic_buffer.c: sort program parameters alphabetically and provide usage information In lsiio.c: drop unused parameters Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
1e7c34788d
commit
e06e3d7112
@ -168,6 +168,19 @@ void process_scan(char *data,
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
printf("Usage: generic_buffer [options]...\n"
|
||||
"Capture, convert and output data from IIO device buffer\n"
|
||||
" -c <n> Do n conversions\n"
|
||||
" -e Disable wait for event (new data)\n"
|
||||
" -g Use trigger-less mode\n"
|
||||
" -l <n> Set buffer length to n samples\n"
|
||||
" -n <name> Set device name (mandatory)\n"
|
||||
" -t <name> Set trigger name\n"
|
||||
" -w <n> Set delay between reads in us (event-less mode)\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned long num_loops = 2;
|
||||
@ -193,29 +206,19 @@ int main(int argc, char **argv)
|
||||
|
||||
struct iio_channel_info *channels;
|
||||
|
||||
while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
|
||||
while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
|
||||
switch (c) {
|
||||
case 'n':
|
||||
device_name = optarg;
|
||||
break;
|
||||
case 't':
|
||||
trigger_name = optarg;
|
||||
datardytrigger = 0;
|
||||
break;
|
||||
case 'e':
|
||||
noevents = 1;
|
||||
break;
|
||||
case 'c':
|
||||
errno = 0;
|
||||
num_loops = strtoul(optarg, &dummy, 10);
|
||||
if (errno)
|
||||
return -errno;
|
||||
break;
|
||||
case 'w':
|
||||
errno = 0;
|
||||
timedelay = strtoul(optarg, &dummy, 10);
|
||||
if (errno)
|
||||
return -errno;
|
||||
case 'e':
|
||||
noevents = 1;
|
||||
break;
|
||||
case 'g':
|
||||
notrigger = 1;
|
||||
break;
|
||||
case 'l':
|
||||
errno = 0;
|
||||
@ -223,16 +226,30 @@ int main(int argc, char **argv)
|
||||
if (errno)
|
||||
return -errno;
|
||||
break;
|
||||
case 'g':
|
||||
notrigger = 1;
|
||||
case 'n':
|
||||
device_name = optarg;
|
||||
break;
|
||||
case 't':
|
||||
trigger_name = optarg;
|
||||
datardytrigger = 0;
|
||||
break;
|
||||
case 'w':
|
||||
errno = 0;
|
||||
timedelay = strtoul(optarg, &dummy, 10);
|
||||
if (errno)
|
||||
return -errno;
|
||||
break;
|
||||
case '?':
|
||||
print_usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (device_name == NULL)
|
||||
if (device_name == NULL) {
|
||||
printf("Device name not set\n");
|
||||
print_usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Find the device requested */
|
||||
dev_num = find_type_by_name(device_name, "iio:device");
|
||||
|
@ -164,7 +164,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int c, err = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "d:D:v")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "v")) != EOF) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
verblevel++;
|
||||
@ -179,9 +179,7 @@ int main(int argc, char **argv)
|
||||
if (err || argc > optind) {
|
||||
fprintf(stderr, "Usage: lsiio [options]...\n"
|
||||
"List industrial I/O devices\n"
|
||||
" -v, --verbose\n"
|
||||
" Increase verbosity (may be given multiple times)\n"
|
||||
);
|
||||
" -v Increase verbosity (may be given multiple times)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user