]> sigrok.org Git - libsigrok.git/commitdiff
korad-kaxxxxp: add config_get() support for SR_CONF_CONN
authorGerhard Sittig <redacted>
Sun, 2 Aug 2020 10:01:45 +0000 (12:01 +0200)
committerGerhard Sittig <redacted>
Sat, 22 Aug 2020 07:10:29 +0000 (09:10 +0200)
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
  ...

src/hardware/korad-kaxxxxp/api.c

index d5146261551d88a8ab8155452c1bed1119bf2239..d0920c9b0921d42a4066bf33470ad6b0b9409232 100644 (file)
@@ -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);