From 91deafbcb355adafcc4d22098b938d637367fcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Tue, 8 Feb 2011 09:02:40 +0000 Subject: [PATCH] Allow USB device's VID/PID/Vendor/Product to be explicitly specified git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@3041 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- src/usb_port.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/usb_port.c b/src/usb_port.c index 79aa19c27..16d3ba7fd 100644 --- a/src/usb_port.c +++ b/src/usb_port.c @@ -168,6 +168,7 @@ static struct usb_dev_handle *find_and_open_device(const hamlib_port_t *port) int usb_port_open(hamlib_port_t *port) { struct usb_dev_handle *udh; + char *p, *q; usb_init (); /* usb library init */ if (usb_find_busses () < 0) @@ -177,6 +178,31 @@ int usb_port_open(hamlib_port_t *port) rig_debug(RIG_DEBUG_ERR, "%s: usb_find_devices failed %s\n", __func__, usb_strerror()); + p = port->pathname; + q = strchr(p, ':'); + if (q) { + if (q != p+1) + port->parm.usb.vid = strtol(q, NULL, 16); + p = q+1; + q = strchr(p, ':'); + if (q) { + if (q != p+1) + port->parm.usb.pid = strtol(q, NULL, 16); + p = q+1; + q = strchr(p, ':'); + if (q) { + if (q != p+1) + port->parm.usb.vendor_name = q; + p = q+1; + q = strchr(p, ':'); + if (q) { + if (q != p+1) + port->parm.usb.product = q; + } + } + } + } + udh = find_and_open_device(port); if (udh == 0) return -RIG_EIO;