28 #include <sys/ioctl.h>
32 static const char *
const iio_chan_type_name_spec[] = {
51 static const char *
const iio_ev_type_text[] = {
59 static const char *
const iio_ev_dir_text[] = {
65 static const char *
const iio_modifier_names[] = {
159 if (!event_is_known(event)) {
160 printf(
"Unknown event: time: %lld, id: %llx\n",
169 iio_chan_type_name_spec[type],
170 iio_modifier_names[mod]);
173 iio_chan_type_name_spec[type]);
176 if (diff && chan >= 0 && chan2 >= 0)
177 printf(
"channel: %d-%d, ", chan, chan2);
179 printf(
"channel: %d, ", chan);
181 printf(
"evtype: %s, direction: %s\n",
182 iio_ev_type_text[ev_type],
183 iio_ev_dir_text[dir]);
196 printf(
"Usage: %s <device_name>\n", argv[0]);
200 device_name = argv[1];
204 printf(
"Found IIO device with name %s with device number %d\n",
205 device_name, dev_num);
206 ret = asprintf(&chrdev_name,
"/dev/iio:device%d", dev_num);
214 chrdev_name = strdup(device_name);
217 fd =
open(chrdev_name, 0);
219 fprintf(stdout,
"Failed to open %s\n", chrdev_name);
221 goto error_free_chrdev_name;
228 if (ret == -1 || event_fd == -1) {
229 fprintf(stdout,
"Failed to retrieve event fd\n");
231 goto error_free_chrdev_name;
235 ret =
read(event_fd, &event,
sizeof(event));
238 printf(
"nothing available\n");
241 perror(
"Failed to read event from device");
251 error_free_chrdev_name: