From: Gerhard Sittig Date: Sun, 2 Aug 2020 10:01:45 +0000 (+0200) Subject: korad-kaxxxxp: add config_get() support for SR_CONF_CONN X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=048250d0e0a4cefdf192dbdb0e7f4dec3a881ed1;p=libsigrok.git korad-kaxxxxp: add config_get() support for SR_CONF_CONN Let applications query the device instance's conn= key. This lets users recognize individual devices if multiple of them are connected. $ sigrok-cli -d korad-kaxxxxp:conn=/dev/ttyACM0 --show ... korad-kaxxxxp:conn=/dev/ttyACM0 - Korad KA3005P with 2 channels: V I ... --- diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c index d5146261..d0920c9b 100644 --- a/src/hardware/korad-kaxxxxp/api.c +++ b/src/hardware/korad-kaxxxxp/api.c @@ -31,6 +31,7 @@ static const uint32_t drvopts[] = { }; static const uint32_t devopts[] = { + SR_CONF_CONN | SR_CONF_GET, SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, @@ -174,6 +175,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->model = g_strdup(models[model_id].name); sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; + sdi->connection_id = g_strdup(conn); sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "V"); sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "I"); @@ -222,6 +224,9 @@ static int config_get(uint32_t key, GVariant **data, case SR_CONF_LIMIT_SAMPLES: case SR_CONF_LIMIT_MSEC: return sr_sw_limits_config_get(&devc->limits, key, data); + case SR_CONF_CONN: + *data = g_variant_new_string(sdi->connection_id); + break; case SR_CONF_VOLTAGE: korad_kaxxxxp_get_value(sdi->conn, KAXXXXP_VOLTAGE, devc); *data = g_variant_new_double(devc->voltage);