From: Frank Stettner Date: Sun, 25 Jul 2021 09:54:58 +0000 (+0200) Subject: hp-59306a: Enable/disable all outputs at once. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=97c3c869702ccc8fa3aa0ff05a1b53fd9882a5d3;p=libsigrok.git hp-59306a: Enable/disable all outputs at once. --- diff --git a/src/hardware/hp-59306a/api.c b/src/hardware/hp-59306a/api.c index 28927432..0d90781c 100644 --- a/src/hardware/hp-59306a/api.c +++ b/src/hardware/hp-59306a/api.c @@ -30,10 +30,7 @@ static const uint32_t drvopts[] = { }; 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[] = { @@ -115,8 +112,10 @@ static int config_set(uint32_t key, GVariant *data, 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; } diff --git a/src/hardware/hp-59306a/protocol.c b/src/hardware/hp-59306a/protocol.c index 3628f98d..69af3610 100644 --- a/src/hardware/hp-59306a/protocol.c +++ b/src/hardware/hp-59306a/protocol.c @@ -24,17 +24,27 @@ 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; }