Skip to content

Commit

Permalink
tools:iio:iio_event_monitor: refactor events output
Browse files Browse the repository at this point in the history
Refactor the code in print_event() to reduce code duplication and better
reflect that the type is output unconditionally, as well as cascade the
dependency of the diff-channel. Saves a few lines of code, as well.

Signed-off-by: Hartmut Knaack <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
Hartmut Knaack authored and jic23 committed Jun 1, 2015
1 parent 0e79987 commit 916e89e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions tools/iio/iio_event_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,19 @@ static void print_event(struct iio_event_data *event)
return;
}

printf("Event: time: %lld, ", event->timestamp);
printf("Event: time: %lld, type: %s", event->timestamp,
iio_chan_type_name_spec[type]);

if (mod != IIO_NO_MOD) {
printf("type: %s(%s), ",
iio_chan_type_name_spec[type],
iio_modifier_names[mod]);
} else {
printf("type: %s, ",
iio_chan_type_name_spec[type]);
}
if (mod != IIO_NO_MOD)
printf("(%s)", iio_modifier_names[mod]);

if (diff && chan >= 0 && chan2 >= 0)
printf("channel: %d-%d, ", chan, chan2);
else if (chan >= 0)
printf("channel: %d, ", chan);
if (chan >= 0) {
printf(", channel: %d", chan);
if (diff && chan2 >= 0)
printf("-%d", chan2);
}

printf("evtype: %s", iio_ev_type_text[ev_type]);
printf(", evtype: %s", iio_ev_type_text[ev_type]);

if (dir != IIO_EV_DIR_NONE)
printf(", direction: %s", iio_ev_dir_text[dir]);
Expand Down

0 comments on commit 916e89e

Please sign in to comment.