Skip to content

Commit e333a40

Browse files
committed
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.
1 parent 59f6765 commit e333a40

File tree

1 file changed

+4
-3
lines changed
  • src/hardware/dcttech-usbrelay

1 file changed

+4
-3
lines changed

src/hardware/dcttech-usbrelay/api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ static struct sr_dev_inst *probe_device(const char *path, size_t relay_count)
9898
* caller fills in vendor, model, conn from USB enum details.
9999
*/
100100
sdi = g_malloc0(sizeof(*sdi));
101+
sdi->serial_num = g_strdup(serno);
102+
sdi->connection_id = g_strdup(path);
101103
devc = g_malloc0(sizeof(*devc));
102104
sdi->priv = devc;
103105
devc->hid_path = g_strdup(path);
@@ -202,7 +204,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
202204
/* Amend driver instance from USB enumeration details. */
203205
sdi->vendor = g_strdup_printf("%ls", curdev->manufacturer_string);
204206
sdi->model = g_strdup_printf("%ls", curdev->product_string);
205-
sdi->conn = g_strdup(curdev->path);
206207
sdi->driver = &dcttech_usbrelay_driver_info;
207208
sdi->inst_type = SR_INST_USB;
208209

@@ -256,9 +257,9 @@ static int config_get(uint32_t key, GVariant **data,
256257
if (!cg) {
257258
switch (key) {
258259
case SR_CONF_CONN:
259-
if (!sdi->conn)
260+
if (!sdi->connection_id)
260261
return SR_ERR_NA;
261-
*data = g_variant_new_string(sdi->conn);
262+
*data = g_variant_new_string(sdi->connection_id);
262263
return SR_OK;
263264
default:
264265
return SR_ERR_NA;

0 commit comments

Comments
 (0)