From: Frank Stettner Date: Sat, 7 Aug 2021 17:18:39 +0000 (+0200) Subject: hp-59306a: Add GET for config key SR_CONF_CONN X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0c678b26dd8644b57dc8b2b6666eb7f362975841;p=libsigrok.git hp-59306a: Add GET for config key SR_CONF_CONN --- diff --git a/src/hardware/hp-59306a/api.c b/src/hardware/hp-59306a/api.c index 0d90781c..76ea8d7e 100644 --- a/src/hardware/hp-59306a/api.c +++ b/src/hardware/hp-59306a/api.c @@ -30,6 +30,7 @@ static const uint32_t drvopts[] = { }; static const uint32_t devopts[] = { + SR_CONF_CONN | SR_CONF_GET, SR_CONF_ENABLED | SR_CONF_SET, }; @@ -61,6 +62,10 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) sdi->conn = scpi; sdi->driver = &hp_59306a_driver_info; sdi->inst_type = SR_INST_SCPI; + if (sr_scpi_connection_id(scpi, &sdi->connection_id) != SR_OK) { + g_free(sdi->connection_id); + sdi->connection_id = NULL; + } devc = g_malloc0(sizeof(*devc)); sdi->priv = devc; @@ -105,6 +110,25 @@ static int dev_close(struct sr_dev_inst *sdi) return sr_scpi_close(sdi->conn); } +static int config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) +{ + (void)cg; + + if (!sdi || !data) + return SR_ERR_ARG; + + switch (key) { + case SR_CONF_CONN: + *data = g_variant_new_string(sdi->connection_id); + break; + default: + return SR_ERR_NA; + } + + return SR_OK; +} + static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -166,7 +190,7 @@ static struct sr_dev_driver hp_59306a_driver_info = { .scan = scan, .dev_list = std_dev_list, .dev_clear = std_dev_clear, - .config_get = NULL, + .config_get = config_get, .config_set = config_set, .config_list = config_list, .dev_open = dev_open,