- if (devc->state == STATE_VOLTAGE) {
- /* Just got voltage, request current for this channel. */
- devc->state = STATE_CURRENT;
- scpi_cmd(sdi, SCPI_CMD_GET_MEAS_CURRENT, devc->cur_channel->name);
- } else if (devc->state == STATE_CURRENT) {
- /*
- * Done with voltage and current for this channel, switch to
- * the next enabled channel.
- */
- do {
- l = g_slist_find(sdi->channels, devc->cur_channel);
- if (l->next)
- devc->cur_channel = l->next->data;
- else
- devc->cur_channel = sdi->channels->data;
- } while (!devc->cur_channel->enabled);
-
- /* Request voltage. */
- devc->state = STATE_VOLTAGE;
- scpi_cmd(sdi, SCPI_CMD_GET_MEAS_VOLTAGE, devc->cur_channel->name);
+ if (g_slist_length(sdi->channels) > 1) {
+ next_channel = sr_next_enabled_channel(sdi, devc->cur_channel);
+ if (select_channel(sdi, next_channel) != SR_OK) {
+ sr_err("Failed to select channel %s", next_channel->name);
+ return FALSE;
+ }