Make sr_next_enabled_channel() from scpi-pps available library-wide.
This commit is contained in:
parent
91ef511db2
commit
9c24d16a1d
19
src/device.c
19
src/device.c
|
@ -133,6 +133,25 @@ SR_API int sr_dev_channel_enable(struct sr_channel *channel,
|
||||||
return SR_OK;
|
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
|
* Determine whether the specified device instance has the specified
|
||||||
* capability.
|
* capability.
|
||||||
|
|
|
@ -597,7 +597,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
std_session_send_df_header(sdi, LOG_PREFIX);
|
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||||
|
|
||||||
/* Prime the pipe with the first channel's fetch. */
|
/* Prime the pipe with the first channel's fetch. */
|
||||||
ch = next_enabled_channel(sdi, NULL);
|
ch = sr_next_enabled_channel(sdi, NULL);
|
||||||
pch = ch->priv;
|
pch = ch->priv;
|
||||||
if ((ret = select_channel(sdi, ch)) < 0)
|
if ((ret = select_channel(sdi, ch)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -53,24 +53,6 @@ SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SR_PRIV struct sr_channel *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;
|
|
||||||
}
|
|
||||||
|
|
||||||
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
|
@ -115,7 +97,7 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_slist_length(sdi->channels) > 1) {
|
if (g_slist_length(sdi->channels) > 1) {
|
||||||
next_channel = next_enabled_channel(sdi, devc->cur_channel);
|
next_channel = sr_next_enabled_channel(sdi, devc->cur_channel);
|
||||||
if (select_channel(sdi, next_channel) != SR_OK) {
|
if (select_channel(sdi, next_channel) != SR_OK) {
|
||||||
sr_err("Failed to select channel %s", next_channel->name);
|
sr_err("Failed to select channel %s", next_channel->name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -156,8 +156,6 @@ SR_PRIV extern const struct scpi_pps pps_profiles[];
|
||||||
|
|
||||||
SR_PRIV const char *get_vendor(const char *raw_vendor);
|
SR_PRIV const char *get_vendor(const char *raw_vendor);
|
||||||
SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch);
|
SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch);
|
||||||
SR_PRIV struct sr_channel *next_enabled_channel(const struct sr_dev_inst *sdi,
|
|
||||||
struct sr_channel *cur_channel);
|
|
||||||
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -632,6 +632,8 @@ enum {
|
||||||
|
|
||||||
SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
|
SR_PRIV struct sr_channel *sr_channel_new(struct sr_dev_inst *sdi,
|
||||||
int index, int type, gboolean enabled, const char *name);
|
int index, int type, gboolean enabled, const char *name);
|
||||||
|
SR_PRIV struct sr_channel *sr_next_enabled_channel(const struct sr_dev_inst *sdi,
|
||||||
|
struct sr_channel *cur_channel);
|
||||||
|
|
||||||
/** Device instance data */
|
/** Device instance data */
|
||||||
struct sr_dev_inst {
|
struct sr_dev_inst {
|
||||||
|
|
Loading…
Reference in New Issue