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:
Hartmut Knaack 2015-05-31 14:40:22 +02:00 committed by Jonathan Cameron
parent 1e7c34788d
commit e06e3d7112
2 changed files with 38 additions and 23 deletions

View File

@ -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");

View File

@ -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);
}