From dc3684c3295a2ff2f1e956a35d6270a1cf2c5096 Mon Sep 17 00:00:00 2001 From: Dimas Abreu Archanjo Dutra Date: Mon, 19 Aug 2019 19:04:27 -0300 Subject: [PATCH 1/2] Fixing dummy-iiostream read method help message. Signed-off-by: Dimas Abreu Archanjo Dutra --- examples/dummy-iiostream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dummy-iiostream.c b/examples/dummy-iiostream.c index 0f7480820..7f1905508 100644 --- a/examples/dummy-iiostream.c +++ b/examples/dummy-iiostream.c @@ -156,7 +156,7 @@ static void usage(int argc, char *argv[]) printf(" -d\tdevice name (default \"iio_dummy_part_no\")\n"); printf(" -t\ttrigger name (default \"instance1\")\n"); printf(" -b\tbuffer length (default 1)\n"); - printf(" -r\tread method (default 0 pointer, 1 callback, 2 read, 3 read raw)\n"); + printf(" -r\tread method (default 0 pointer, 1 callback, 2 read raw, 3 read)\n"); printf(" -c\tread count (default no limit)\n"); } From 447059382c37b1a177d567ede398b3c3f1df54f6 Mon Sep 17 00:00:00 2001 From: Dimas Abreu Archanjo Dutra Date: Fri, 29 Nov 2019 19:33:50 -0300 Subject: [PATCH 2/2] Making the printfs in dummy-iiostream portable. Signed-off-by: Dimas Abreu Archanjo Dutra --- examples/dummy-iiostream.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/dummy-iiostream.c b/examples/dummy-iiostream.c index 7f1905508..5318e2bc2 100644 --- a/examples/dummy-iiostream.c +++ b/examples/dummy-iiostream.c @@ -76,6 +76,7 @@ #include #include #include +#include #ifdef __APPLE__ #include @@ -142,9 +143,9 @@ static ssize_t sample_cb(const struct iio_channel *chn, void *src, size_t bytes, printf("%s ", iio_channel_get_id(chn)); for (int j = 0; j < repeat; ++j) { if (bytes == sizeof(int16_t)) - printf("%i ", ((int16_t *)src)[j]); + printf("%" PRIi16 " ", ((int16_t *)src)[j]); else if (bytes == sizeof(int64_t)) - printf("%ld ", ((int64_t *)src)[j]); + printf("%" PRId64 " ", ((int64_t *)src)[j]); } return bytes * repeat; @@ -301,7 +302,7 @@ int main (int argc, char **argv) if (has_ts) for (p_dat = iio_buffer_first(rxbuf, channels[channel_count-1]); p_dat < p_end; p_dat += p_inc) { now_ts = (((int64_t *)p_dat)[0]); - printf("[%04ld] ", last_ts > 0 ? (now_ts - last_ts)/1000/1000 : 0); + printf("[%04" PRId64 "] ", last_ts > 0 ? (now_ts - last_ts)/1000/1000 : 0); last_ts = now_ts; } @@ -317,9 +318,9 @@ int main (int argc, char **argv) for (p_dat = iio_buffer_first(rxbuf, channels[i]); p_dat < p_end; p_dat += p_inc) { for (int j = 0; j < repeat; ++j) { if (fmt->length/8 == sizeof(int16_t)) - printf("%i ", ((int16_t *)p_dat)[j]); + printf("%" PRIi16 " ", ((int16_t *)p_dat)[j]); else if (fmt->length/8 == sizeof(int64_t)) - printf("%ld ", ((int64_t *)p_dat)[j]); + printf("%" PRId64 " ", ((int64_t *)p_dat)[j]); } } } @@ -351,9 +352,9 @@ int main (int argc, char **argv) for (int sample = 0; sample < bytes / sample_size; ++sample) { for (int j = 0; j < repeat; ++j) { if (fmt->length / 8 == sizeof(int16_t)) - printf("%i ", ((int16_t *)buf)[sample+j]); + printf("%" PRIi16 " ", ((int16_t *)buf)[sample+j]); else if (fmt->length / 8 == sizeof(int64_t)) - printf("%li ", ((int64_t *)buf)[sample+j]); + printf("%" PRId64 " ", ((int64_t *)buf)[sample+j]); } }