Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #303 and #302 #304

Merged
merged 2 commits into from
Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions examples/dummy-iiostream.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>

#ifdef __APPLE__
#include <iio/iio.h>
Expand Down Expand Up @@ -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;
Expand All @@ -156,7 +157,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");
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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]);
}
}
}
Expand Down Expand Up @@ -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]);
}
}

Expand Down