Commit 4e2cf0e2 authored by Eva Rachel Retuya's avatar Eva Rachel Retuya Committed by Jonathan Cameron

tools: iio: iio_generic_buffer: add -A to force-enable all channels

If attribute/s is/are already enabled (by default or via scripts or
manual interaction), issuing -a will fail to enable the channels thereby
one has to manually disable the said attribute/s before proceeding with
auto-enabling.

Add a command-line option -A to force-activate all channels regardless
of their current state.
Suggested-by: default avatarAlison Schofield <amsfield22@gmail.com>
Signed-off-by: default avatarEva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent b440f1d9
...@@ -247,6 +247,7 @@ void print_usage(void) ...@@ -247,6 +247,7 @@ void print_usage(void)
fprintf(stderr, "Usage: generic_buffer [options]...\n" fprintf(stderr, "Usage: generic_buffer [options]...\n"
"Capture, convert and output data from IIO device buffer\n" "Capture, convert and output data from IIO device buffer\n"
" -a Auto-activate all available channels\n" " -a Auto-activate all available channels\n"
" -A Force-activate ALL channels\n"
" -c <n> Do n conversions\n" " -c <n> Do n conversions\n"
" -e Disable wait for event (new data)\n" " -e Disable wait for event (new data)\n"
" -g Use trigger-less mode\n" " -g Use trigger-less mode\n"
...@@ -347,16 +348,22 @@ int main(int argc, char **argv) ...@@ -347,16 +348,22 @@ int main(int argc, char **argv)
int noevents = 0; int noevents = 0;
int notrigger = 0; int notrigger = 0;
char *dummy; char *dummy;
int force = 0;
struct iio_channel_info *channels = NULL; struct iio_channel_info *channels = NULL;
register_cleanup(); register_cleanup();
while ((c = getopt_long(argc, argv, "ac:egl:n:N:t:T:w:?", longopts, NULL)) != -1) { while ((c = getopt_long(argc, argv, "aAc:egl:n:N:t:T:w:?", longopts,
NULL)) != -1) {
switch (c) { switch (c) {
case 'a': case 'a':
autochannels = AUTOCHANNELS_ENABLED; autochannels = AUTOCHANNELS_ENABLED;
break; break;
case 'A':
autochannels = AUTOCHANNELS_ENABLED;
force = 1;
break;
case 'c': case 'c':
errno = 0; errno = 0;
num_loops = strtoul(optarg, &dummy, 10); num_loops = strtoul(optarg, &dummy, 10);
...@@ -519,15 +526,15 @@ int main(int argc, char **argv) ...@@ -519,15 +526,15 @@ int main(int argc, char **argv)
"diag %s\n", dev_dir_name); "diag %s\n", dev_dir_name);
goto error; goto error;
} }
if (num_channels && autochannels == AUTOCHANNELS_ENABLED) { if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) && !force) {
fprintf(stderr, "Auto-channels selected but some channels " fprintf(stderr, "Auto-channels selected but some channels "
"are already activated in sysfs\n"); "are already activated in sysfs\n");
fprintf(stderr, "Proceeding without activating any channels\n"); fprintf(stderr, "Proceeding without activating any channels\n");
} }
if (!num_channels && autochannels == AUTOCHANNELS_ENABLED) { if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
fprintf(stderr, ((autochannels == AUTOCHANNELS_ENABLED) && force)) {
"No channels are enabled, enabling all channels\n"); fprintf(stderr, "Enabling all channels\n");
ret = enable_disable_all_channels(dev_dir_name, 1); ret = enable_disable_all_channels(dev_dir_name, 1);
if (ret) { if (ret) {
......
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