mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 18:49:48 +02:00
fix(libusb): claim an interface for bulk transfers
This commit is contained in:
1 parent
489c6651f9
commit
6e7923a958
1 file changed
+11
-2
@@ -11,6 +11,7 @@
|
||||
#include "../../utils.h"
|
||||
|
||||
void close_usb_handle(usb_handle_t *handle) {
|
||||
libusb_release_interface(handle->device, 0);
|
||||
libusb_close(handle->device);
|
||||
libusb_exit(NULL);
|
||||
}
|
||||
@@ -23,9 +24,17 @@ bool wait_usb_handle(usb_handle_t *handle) {
|
||||
if(libusb_init(NULL) == LIBUSB_SUCCESS) {
|
||||
for(;;) {
|
||||
if((handle->device = libusb_open_device_with_vid_pid(NULL, handle->vid, handle->pid)) != NULL) {
|
||||
if(libusb_set_configuration(handle->device, 1) == LIBUSB_SUCCESS) {
|
||||
return true;
|
||||
|
||||
libusb_set_auto_detach_kernel_driver(handle->device, 1);
|
||||
|
||||
if(libusb_set_configuration(handle->device, 1) == LIBUSB_SUCCESS ||
|
||||
libusb_set_configuration(handle->device, 1) == LIBUSB_ERROR_BUSY)
|
||||
{
|
||||
if(libusb_claim_interface(handle->device, 0) == LIBUSB_SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
libusb_close(handle->device);
|
||||
}
|
||||
sleep_ms(USB_TIMEOUT);
|
||||
|
||||
Reference in new issue
Block a user