]> sigrok.org Git - libsigrok.git/commitdiff
dcttech-usbrelay: adjust serial number and connection string logic
authorGerhard Sittig <redacted>
Thu, 22 Jul 2021 05:09:48 +0000 (07:09 +0200)
committerGerhard Sittig <redacted>
Thu, 22 Jul 2021 05:09:48 +0000 (07:09 +0200)
Store the USB relay card's serial number such that users can tell apart
multiple connected cards. Hold the HIDAPI path in the 'connection_id'
member because 'conn' is something internal, not for display purposes.

src/hardware/dcttech-usbrelay/api.c

index 67de5d1e7dfac3ad6daf889ff6f67b2a96e31d4b..583a12c4117abe03d8dc82a230154cb2e8462789 100644 (file)
@@ -98,6 +98,8 @@ static struct sr_dev_inst *probe_device(const char *path, size_t relay_count)
         * caller fills in vendor, model, conn from USB enum details.
         */
        sdi = g_malloc0(sizeof(*sdi));
+       sdi->serial_num = g_strdup(serno);
+       sdi->connection_id = g_strdup(path);
        devc = g_malloc0(sizeof(*devc));
        sdi->priv = devc;
        devc->hid_path = g_strdup(path);
@@ -202,7 +204,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                /* Amend driver instance from USB enumeration details. */
                sdi->vendor = g_strdup_printf("%ls", curdev->manufacturer_string);
                sdi->model = g_strdup_printf("%ls", curdev->product_string);
-               sdi->conn = g_strdup(curdev->path);
                sdi->driver = &dcttech_usbrelay_driver_info;
                sdi->inst_type = SR_INST_USB;
 
@@ -256,9 +257,9 @@ static int config_get(uint32_t key, GVariant **data,
        if (!cg) {
                switch (key) {
                case SR_CONF_CONN:
-                       if (!sdi->conn)
+                       if (!sdi->connection_id)
                                return SR_ERR_NA;
-                       *data = g_variant_new_string(sdi->conn);
+                       *data = g_variant_new_string(sdi->connection_id);
                        return SR_OK;
                default:
                        return SR_ERR_NA;