Commit 96df9799 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio: buffer example - add lots more runtime parameters

Add ability to control delay for event free buffers
Add ability to control length of buffer
Add ability to control how many read cycles occur
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Tested-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 30268a3d
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include <string.h> #include <string.h>
#include "iio_utils.h" #include "iio_utils.h"
const int buf_len = 128;
const int num_loops = 2;
/** /**
* size_from_channelarray() - calculate the storage size of a scan * size_from_channelarray() - calculate the storage size of a scan
* @channels: the channel info array * @channels: the channel info array
...@@ -119,6 +116,11 @@ void process_scan(char *data, ...@@ -119,6 +116,11 @@ void process_scan(char *data,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned long num_loops = 2;
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;
int ret, c, i, j, toread; int ret, c, i, j, toread;
FILE *fp_ev; FILE *fp_ev;
...@@ -136,10 +138,11 @@ int main(int argc, char **argv) ...@@ -136,10 +138,11 @@ int main(int argc, char **argv)
char *buffer_access, *buffer_event; char *buffer_access, *buffer_event;
int scan_size; int scan_size;
int noevents = 0; int noevents = 0;
char *dummy;
struct iio_channel_info *infoarray; struct iio_channel_info *infoarray;
while ((c = getopt(argc, argv, "et:n:")) != -1) { while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) {
switch (c) { switch (c) {
case 'n': case 'n':
device_name = optarg; device_name = optarg;
...@@ -151,6 +154,15 @@ int main(int argc, char **argv) ...@@ -151,6 +154,15 @@ int main(int argc, char **argv)
case 'e': case 'e':
noevents = 1; noevents = 1;
break; break;
case 'c':
num_loops = strtoul(optarg, &dummy, 10);
break;
case 'w':
timedelay = strtoul(optarg, &dummy, 10);
break;
case 'l':
buf_len = strtoul(optarg, &dummy, 10);
break;
case '?': case '?':
return -1; return -1;
} }
...@@ -285,7 +297,7 @@ int main(int argc, char **argv) ...@@ -285,7 +297,7 @@ int main(int argc, char **argv)
continue; continue;
} }
} else { } else {
usleep(1000); usleep(timedelay);
toread = 64; toread = 64;
} }
......
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