};
static const uint32_t devopts[] = {
- /*
- * TODO Enable/disable multiple channel groups at once.
- * SR_CONF_ENABLED | SR_CONF_SET,
- */
+ SR_CONF_ENABLED | SR_CONF_SET,
};
static const uint32_t devopts_cg[] = {
if (!cg) {
switch (key) {
- /* TODO: Enable/disbale multiple channel groups at once. */
case SR_CONF_ENABLED:
+ /* Enable/disable all channels at the same time. */
+ on = g_variant_get_boolean(data);
+ return hp_59306a_switch_cg(sdi, cg, on);
default:
return SR_ERR_NA;
}
SR_PRIV int hp_59306a_switch_cg(const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg, gboolean enabled)
{
- int ret;
- struct sr_scpi_dev_inst *scpi;
+ char *cmd;
struct channel_group_context *cgc;
+ struct sr_scpi_dev_inst *scpi;
+ int ret;
- scpi = sdi->conn;
- cgc = cg->priv;
+ if (!cg) {
+ if (enabled)
+ cmd = g_strdup("A123456");
+ else
+ cmd = g_strdup("B123456");
+ } else {
+ cgc = cg->priv;
+ if (enabled)
+ cmd = g_strdup_printf("A%zu", cgc->number);
+ else
+ cmd = g_strdup_printf("B%zu", cgc->number);
+ }
- if (enabled)
- ret = sr_scpi_send(scpi, "A%zu", cgc->number);
- else
- ret = sr_scpi_send(scpi, "B%zu", cgc->number);
+ scpi = sdi->conn;
+ ret = sr_scpi_send(scpi, cmd);
+ g_free(cmd);
return ret;
}