Skip to contentSkip to conversation

tools: iio: Add help option for generic_buffer

PATCH In review Alin Arhip 2 participants 2 messages Mar 27, 2015 – Mar 28, 2015 IIO

lore
Share & tools
lore

Alin Arhip

author
#0 lore raw

PATCH 1/1 tools: iio: Add help option for generic_buffer

From: Alin Gabriel Arhip <[email protected]>

This patch adds usage instructions and -h parameter to view available command line parameters.

---
 tools/iio/generic_buffer.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
tools/iio/generic_buffer.c +20 -2
index 8f8f058..8dd77ac 100644
@@ -166,7 +166,17 @@ int main(int argc, char **argv)
 
 	struct iio_channel_info *channels;
 
-	while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
+	if (argc <= 1) {
+		printf("Usage: %s -n <device_name> -t <trigger_name>\n"
+			"\tIf trigger name is not specified the program\n"
+			"\tassumes you want a dataready trigger associated\n"
+			"\twith the device and goes looking for it.\n"
+			"\tUse -h to see available command line parameters.\n",
+			argv[0]);
+		return -1;
+	}
+
+	while ((c = getopt(argc, argv, "l:w:c:et:n:gh")) != -1) {
 		switch (c) {
 		case 'n':
 			device_name = optarg;
@@ -190,7 +200,15 @@ int main(int argc, char **argv)
 		case 'g':
 			notrigger = 1;
 			break;
-		case '?':
+		case '?': case 'h':
+			printf("Usage: %s -n <device_name> to set device name\n"
+				"\t-t <trigger_name> to set trigger name\n"
+				"\t-e to set noevents to 1\n"
+				"\t-c <num_loops> to set number of loops\n"
+				"\t-w <timedelay> to set time delay\n"
+				"\t-l <buf_len> to set buffer length\n"
+				"\t-g to set notrigger to 1\n"
+				"\t-h to see this help\n", argv[0]);
 			return -1;
 		}
 	}
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 6 lines · Alin Arhip

From: Alin Gabriel Arhip <[email protected]>

This patch adds usage instructions and -h parameter to view available command line parameters.

Good in principal, but I wonder if we can't make it more informative. Some of the help is talking more about internals of the code rather than what the option means to the user!

Quoted 28 lines
---
 tools/iio/generic_buffer.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
tools/iio/generic_buffer.c +11 -1
index 8f8f058..8dd77ac 100644
@@ -166,7 +166,17 @@ int main(int argc, char **argv)
 
 	struct iio_channel_info *channels;
 
-	while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
+	if (argc <= 1) {
+		printf("Usage: %s -n <device_name> -t <trigger_name>\n"
+			"\tIf trigger name is not specified the program\n"
+			"\tassumes you want a dataready trigger associated\n"
+			"\twith the device and goes looking for it.\n"
+			"\tUse -h to see available command line parameters.\n",
+			argv[0]);
+		return -1;
+	}
+
+	while ((c = getopt(argc, argv, "l:w:c:et:n:gh")) != -1) {
 		switch (c) {
 		case 'n':
 			device_name = optarg;

tools/iio/generic_buffer.c int main(int argc, char **argv) · line 206

Quoted 8 lines
tools/iio/generic_buffer.c +4 -1
@@ -190,7 +200,15 @@ int main(int argc, char **argv)
 		case 'g':
 			notrigger = 1;
 			break;
-		case '?':
+		case '?': case 'h':
+			printf("Usage: %s -n <device_name> to set device name\n"
+				"\t-t <trigger_name> to set trigger name\n"
+				"\t-e to set noevents to 1\n"

This option was to allow reads of more than one sample (as that's what poll used to support). With the new poll support for watersheds (in the software buffer) we probably want to drop this option entirely and support those instead.

tools/iio/generic_buffer.c int main(int argc, char **argv) · line 207

Quoted 1 line
tools/iio/generic_buffer.c +1 -0
+				"\t-c <num_loops> to set number of loops\n"

loops of what? Again, the meaning of this will change with support for watershed based poll.

tools/iio/generic_buffer.c int main(int argc, char **argv) · line 208

Quoted 1 line
tools/iio/generic_buffer.c +1 -0
+				"\t-w <timedelay> to set time delay\n"

to set time delay between attempts to read from the buffer.

tools/iio/generic_buffer.c int main(int argc, char **argv) · line 210

Quoted 2 lines
tools/iio/generic_buffer.c +2 -0
+				"\t-l <buf_len> to set buffer length\n"
+				"\t-g to set notrigger to 1\n"

Make it explicit that some devices do not have a trigger as they push the data directly to the buffer (typically hardware buffer equipped devices).

Quoted 5 lines
tools/iio/generic_buffer.c +1 -0
+				"\t-h to see this help\n", argv[0]);
 			return -1;
 		}
 	}