From: Gerhard Sittig Date: Thu, 22 Jul 2021 05:09:48 +0000 (+0200) Subject: dcttech-usbrelay: adjust serial number and connection string logic X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e333a40c1c5a27806b8a6dd2611c54b23d11366b;p=libsigrok.git dcttech-usbrelay: adjust serial number and connection string logic 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. --- diff --git a/src/hardware/dcttech-usbrelay/api.c b/src/hardware/dcttech-usbrelay/api.c index 67de5d1e..583a12c4 100644 --- a/src/hardware/dcttech-usbrelay/api.c +++ b/src/hardware/dcttech-usbrelay/api.c @@ -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;