kopia lustrzana https://github.com/Hamlib/Hamlib
* call missing usb_find_devices()
* disable usb_set_configuration/usb_set_altinterface since they seem to interfere git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2219 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.7
rodzic
beeafc7ac1
commit
1b79a2a0ed
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Interface - USB communication low-level support
|
||||
* Copyright (c) 2000-2005 by Stephane Fillod
|
||||
*
|
||||
* $Id: usb_port.c,v 1.4 2006-10-15 00:27:52 aa6e Exp $
|
||||
* $Id: usb_port.c,v 1.5 2007-10-07 20:12:36 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -66,17 +66,25 @@ struct usb_device * find_device(const hamlib_port_t *port)
|
|||
struct usb_device *q;
|
||||
|
||||
p = usb_get_busses();
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: looking for device %04x:%04x...", __FUNCTION__,
|
||||
port->parm.usb.vid, port->parm.usb.pid);
|
||||
|
||||
while (p != NULL){
|
||||
q = p->devices;
|
||||
while (q != NULL){
|
||||
rig_debug(RIG_DEBUG_TRACE, " %04x:%04x,", q->descriptor.idVendor,
|
||||
q->descriptor.idProduct);
|
||||
if (q->descriptor.idVendor == port->parm.usb.vid &&
|
||||
q->descriptor.idProduct == port->parm.usb.pid) {
|
||||
rig_debug(RIG_DEBUG_TRACE, " -> found\n");
|
||||
return q;
|
||||
}
|
||||
q = q->next;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
rig_debug(RIG_DEBUG_TRACE, " -> not found\n");
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
|
@ -91,7 +99,12 @@ int usb_port_open(hamlib_port_t *port)
|
|||
return -RIG_EINVAL;
|
||||
|
||||
usb_init (); /* usb library init */
|
||||
usb_find_busses ();
|
||||
if (usb_find_busses () < 0)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: usb_find_busses failed %s\n",
|
||||
__FUNCTION__, usb_strerror());
|
||||
if (usb_find_devices() < 0)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: usb_find_devices failed %s\n",
|
||||
__FUNCTION__, usb_strerror());
|
||||
|
||||
dev = find_device(port);
|
||||
if (dev == 0)
|
||||
|
@ -101,17 +114,34 @@ int usb_port_open(hamlib_port_t *port)
|
|||
if (udh == 0)
|
||||
return -RIG_EIO;
|
||||
|
||||
#ifdef LIBUSB_HAS_GET_DRIVER_NP
|
||||
/* Try to detach ftdi_sio kernel module
|
||||
* Returns ENODATA if driver is not loaded
|
||||
*/
|
||||
if (usb_detach_kernel_driver_np(udh, port->parm.usb.iface) != 0 && errno != ENODATA) {
|
||||
if (errno == EPERM)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: inappropriate permissions\n", __FUNCTION__);
|
||||
usb_close(udh);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dev != usb_device (udh)){
|
||||
rig_debug(RIG_DEBUG_ERR, "%s:%d: internal error!\n", __FILE__, __LINE__);
|
||||
usb_close(udh);
|
||||
return -RIG_EINTERNAL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (usb_set_configuration (udh, port->parm.usb.conf) < 0){
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: usb_claim_interface: failed conf %d: %s\n",
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: usb_set_configuration: failed conf %d: %s\n",
|
||||
__FUNCTION__,port->parm.usb.conf, usb_strerror());
|
||||
usb_close (udh);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: %d\n", __FUNCTION__, port->parm.usb.iface);
|
||||
|
||||
if (usb_claim_interface (udh, port->parm.usb.iface) < 0){
|
||||
rig_debug(RIG_DEBUG_ERR, "%s:usb_claim_interface: failed interface %d: %s\n",
|
||||
|
@ -120,6 +150,7 @@ int usb_port_open(hamlib_port_t *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (usb_set_altinterface (udh, port->parm.usb.alt) < 0){
|
||||
fprintf (stderr, "%s:usb_set_alt_interface: failed: %s\n", __FUNCTION__,
|
||||
usb_strerror());
|
||||
|
@ -127,6 +158,7 @@ int usb_port_open(hamlib_port_t *port)
|
|||
usb_close (udh);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
port->handle = (void*) udh;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue