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
Hamlib-1.2.13
Stéphane Fillod, F8CFE 2011-02-08 09:02:40 +00:00
rodzic 0de9cc17d2
commit 91deafbcb3
1 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -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;