Reputation: 389
I'm working on an old program, which uses libusb 0.1. In some cases we want to reset connection to an usb device. So we do something like:
ret = usb_release_interface(dev_handle, 0);
ret = usb_close(dev_handle);
And later we open it etc.
in the logs, I see that usb_release_interface always returns -9. I can't find any documentation for this function. Does someone know what this value means? What is this function supposed to do?
thanks.
Upvotes: 0
Views: 1486
Reputation: 16540
Per this web page: http://www.freebsd.org/cgi/man.cgi?query=libusb&sektion=3
there are several available functions, including:
const char * libusb_strerror(int code)
Gets the ASCII representation of the error given by the code argument. This function does not return NULL.
const char * libusb_error_name(int code)
Gets the ASCII representation of the error enum given by the code argument. This function does not return NULL.
Upvotes: 0
Reputation: 9422
see http://www.beyondlogic.org/usbnutshell/usb5.shtml for the basic logical structure of an usb device
when a connection to an usb device is established it is only possible to read or write (usb requests,...) to specific endpoints if the corresponding interface descriptor is claimed
usb_release_interface is the counterpart to usb_claim_interface
if usb_release_interface returns an error it maybe due to unfinished or pending operations in the endpoints that are attached to the interface
maybe you should try to finish all operations in the endpoints and then try usb_release_interface again ?
afaik you have to go through the entire usb tree structure accurately:
first get the device descriptor then the configuration descriptor then the interface descriptor then the endpoint and then the way back
here are the libusb error codes for libusb-1.0:
enum libusb_error {
LIBUSB_SUCCESS = 0, LIBUSB_ERROR_IO = -1, LIBUSB_ERROR_INVALID_PARAM
=-2, LIBUSB_ERROR_ACCESS = -3,
LIBUSB_ERROR_NO_DEVICE = -4, LIBUSB_ERROR_NOT_FOUND = -5,
LIBUSB_ERROR_BUSY = -6, LIBUSB_ERROR_TIMEOUT = -7,
LIBUSB_ERROR_OVERFLOW = -8, **LIBUSB_ERROR_PIPE = -9**,
LIBUSB_ERROR_INTERRUPTED = -10, LIBUSB_ERROR_NO_MEM = -11,
LIBUSB_ERROR_NOT_SUPPORTED = -12, LIBUSB_ERROR_OTHER = -99
}
http://libusb.sourceforge.net/api-1.0/group__misc.html
this really looks like there is still an open pipe to one of the endpoints associated with the interface
see also Why is my kernel module throwing "broken pipe" errors when I try to write to a device?
(http://howtounix.info/man/FreeBSD/man3/usb_release_interface.3)
Upvotes: 1