From ce6aacf9c4e2625448d677db91c9eb28ad574aa5 Mon Sep 17 00:00:00 2001 From: faithwang Date: Fri, 1 Apr 2022 15:08:18 +0800 Subject: [PATCH 1/3] fixed 40fa02a from https://gitee.com/faithwang/developtools_hdc_standard/pulls/320 fix ret Signed-off-by: faithwang --- src/host/host_usb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index df4ea021..108cd0f9 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -264,6 +264,7 @@ int HdcHostUSB::CheckActiveConfig(libusb_device *device, HUSB hUSB) WRITE_LOG(LOG_WARN, "CheckActiveConfig failed descConfig ret:%d", ret); return -1; } + ret = -1; for (j = 0; j < descConfig->bNumInterfaces; ++j) { const struct libusb_interface *interface = &descConfig->interface[j]; if (interface->num_altsetting >= 1) { -- Gitee From 084e64a959744ead9e961d7d3b1a82b48d7015e4 Mon Sep 17 00:00:00 2001 From: faithwang Date: Thu, 31 Mar 2022 20:54:57 +0800 Subject: [PATCH 2/3] fixed 7dcf9b5 from https://gitee.com/faithwang/developtools_hdc_standard/pulls/320 add release device config Signed-off-by: faithwang --- src/host/host_usb.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index 108cd0f9..08e7cfa2 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -491,12 +491,16 @@ int HdcHostUSB::OpenDeviceMyNeed(HUSB hUSB) break; } // USB filter rules are set according to specific device pedding device - libusb_claim_interface(handle, hUSB->interfaceNumber); - ret = 0; + ret = libusb_claim_interface(handle, hUSB->interfaceNumber); break; } if (ret) { - // not my need device + // not my need device, release the device + int configuration = 0; + libusb_get_configuration(hUSB->devHandle, &configuration); + if (configuration == 1) { + libusb_set_configuration(hUSB->devHandle, 0); + } libusb_close(hUSB->devHandle); hUSB->devHandle = nullptr; } -- Gitee From adda7a52a2c4dadc3a96fca2a613cf9c3d29b931 Mon Sep 17 00:00:00 2001 From: faithwang Date: Thu, 31 Mar 2022 20:18:31 +0800 Subject: [PATCH 3/3] fixed 9911a20 from https://gitee.com/faithwang/developtools_hdc_standard/pulls/320 fix usb get config in darwin Signed-off-by: faithwang --- src/host/host_usb.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index 08e7cfa2..3d0fcd99 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -256,8 +256,16 @@ bool HdcHostUSB::IsDebuggableDev(const struct libusb_interface_descriptor *ifDes int HdcHostUSB::CheckActiveConfig(libusb_device *device, HUSB hUSB) { + int configuration = 0; + int ret = libusb_get_configuration(hUSB->devHandle, &configuration); + if (ret != 0) { + ret = libusb_set_configuration(hUSB->devHandle, 1); + if (ret != 0) { + WRITE_LOG(LOG_WARN, "set config failed ret:%d", ret); + return -1; + } + } unsigned int j = 0; - int ret = -1; struct libusb_config_descriptor *descConfig = nullptr; ret = libusb_get_active_config_descriptor(device, &descConfig); if (ret != 0) { -- Gitee