X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdevice.c;h=dd34f79600dd4fe81797fad4b4b9a8cc3db46196;hb=1e7659609bddd40471faf9a8e81ee7554d77dce9;hp=01f413486357d546817c05c7bffc27974c031d13;hpb=41812aca436805b0614f2a8f31cf2f8ce494aea0;p=libsigrok.git diff --git a/src/device.c b/src/device.c index 01f41348..dd34f796 100644 --- a/src/device.c +++ b/src/device.c @@ -20,7 +20,7 @@ #include #include #include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ -#include "libsigrok.h" +#include #include "libsigrok-internal.h" /** @cond PRIVATE */ @@ -133,6 +133,25 @@ SR_API int sr_dev_channel_enable(struct sr_channel *channel, return SR_OK; } +/* Returns the next enabled channel, wrapping around if necessary. */ +SR_PRIV struct sr_channel *sr_next_enabled_channel(const struct sr_dev_inst *sdi, + struct sr_channel *cur_channel) +{ + struct sr_channel *next_channel; + GSList *l; + + next_channel = cur_channel; + do { + l = g_slist_find(sdi->channels, next_channel); + if (l && l->next) + next_channel = l->next->data; + else + next_channel = sdi->channels->data; + } while (!next_channel->enabled); + + return next_channel; +} + /** * Determine whether the specified device instance has the specified * capability.