[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1461683745-1006-1-git-send-email-doru.gucea@intel.com>
Date: Tue, 26 Apr 2016 18:15:45 +0300
From: Doru Gucea <doru.gucea@...el.com>
To: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Doru Gucea <doru.gucea@...el.com>
Subject: [PATCH] iio: generic_buffer: add watermark logic
Some IIO devices with FIFO buffers accept setting the watermark
value from /sys/bus/iio/devices/iio:deviceX/buffer/watermark.
This patch adds the '-m' command line parameter for easily setting
the watermark.
Signed-off-by: Doru Gucea <doru.gucea@...el.com>
---
tools/iio/generic_buffer.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index 01c4f67..f806b52 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -199,6 +199,7 @@ void print_usage(void)
" -e Disable wait for event (new data)\n"
" -g Use trigger-less mode\n"
" -l <n> Set buffer length to n samples\n"
+ " -m <n> Set watermark 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");
@@ -225,11 +226,12 @@ int main(int argc, char **argv)
int scan_size;
int noevents = 0;
int notrigger = 0;
+ int watermark = 0;
char *dummy;
struct iio_channel_info *channels;
- while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
+ while ((c = getopt(argc, argv, "c:egl:n:t:w:m:")) != -1) {
switch (c) {
case 'c':
errno = 0;
@@ -251,6 +253,12 @@ int main(int argc, char **argv)
return -errno;
break;
+ case 'm':
+ errno = 0;
+ watermark = strtoul(optarg, &dummy, 10);
+ if (errno)
+ return -errno;
+ break;
case 'n':
device_name = optarg;
break;
@@ -371,6 +379,15 @@ int main(int argc, char **argv)
if (ret < 0)
goto error_free_buf_dir_name;
+ if (watermark) {
+ ret = write_sysfs_int("watermark", buf_dir_name,
+ watermark);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to write watermark\n");
+ goto error_free_buf_dir_name;
+ }
+ }
+
/* Enable the buffer */
ret = write_sysfs_int("enable", buf_dir_name, 1);
if (ret < 0) {
--
1.9.1
Powered by blists - more mailing lists