Skip to content

【HELP!!!】libusb_control_transfer returns -1 #580

@Sleepingbug

Description

@Sleepingbug

1,test environment:
windows 10 x64, libusb win32, visual studio 2017
lib-1.0.23

2,issue:
libusb_control_transfer returns -1.
I use a tool named Bus Hound to send the same data to my usb device, my device can receive the data and the data can be captured by Bus Hound.

3, my source code:

#pragma once

#include "libusb.h"
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <windows.h>
#include <errno.h>

#define VID 0x0E8D
#define PID 0x2005

int main()
{
	libusb_device_handle *devh = NULL;
 
	int ret = libusb_init(NULL);
	if (ret < 0) {
		perror("libusb_init");
		return ret;
	}

	libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG );

	devh = libusb_open_device_with_vid_pid(NULL, VID, PID);

	if (!devh) {
		printf("libusb_open_device_with_pid_vid Error: %d,\n", ret);
		Sleep(1000);
		libusb_exit(NULL);
	}
	
	Sleep(1000);
	// claim interface
	int interface_number = 4;
	ret = libusb_claim_interface(devh, interface_number);

	if (ret < 0) {
		printf("libusb_claim_interface Error: %d,\n", ret);
		Sleep(2000);
		if (devh) {
			libusb_close(devh);
			devh = NULL;
		}
		return ret;
	}

	unsigned char type = 0x21;
	unsigned char req = 0x09;//HID_SET_REPORT
	uint16_t wValue = 0x0201;
	uint16_t wIndex = 0x01;
	uint16_t length16 = 0x0010;// data length
	unsigned char data[16] = {  0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 };

	printf("---before---%d\n",GetTickCount());
	//FAILED, -1, libusb_error; 
	// both 3 and 0x83 are failed, i want to find the correct one.
	for (wIndex = 0; wIndex < 10; ++wIndex) {
		ret = libusb_control_transfer(devh, type, req, wValue, wIndex, data, length16, 10000);
		printf("libusb_control_transfer,wIndex=%d, ret=%d\n", wIndex,ret );
	}
	
	printf("actual_len=%d\n", actual_len);
	printf("---after ---ret=%d,lastErr=%d,%d\n",ret,GetLastError(), GetTickCount());
	if ( ret < 0) {
		printf("libusb_control_transfer usbError=%d, winError=%d\n", ret, GetLastError());
	}

	Sleep(2000);

	libusb_release_interface(devh, interface_number );
	libusb_close(devh);

	printf("press Enter to ext..\n");
	getchar();

	return 0;
}

4, my logs:

[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.041376] [000013b0] libusb: debug [libusb_get_device_list]
[ 0.072960] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [7E]
[ 0.073635] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [7F]
[ 0.074223] [000013b0] libusb: debug [get_api_type] driver(s): BTHUSB
[ 0.074559] [000013b0] libusb: debug [get_api_type] lower filter driver(s): ibtusb
[ 0.074667] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [10]
[ 0.075585] [000013b0] libusb: debug [get_api_type] driver(s): CH341SER_A64
[ 0.075750] [000013b0] libusb: debug [get_api_type] upper filter driver(s): serenum
[ 0.075959] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [39]
[ 0.076910] [000013b0] libusb: debug [get_api_type] driver(s): HidUsb
[ 0.077082] [000013b0] libusb: debug [get_api_type] matched driver name against HID API
[ 0.077176] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [64]
[ 0.077527] [000013b0] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.077712] [000013b0] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.078254] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [65]
[ 0.079497] [000013b0] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.079844] [000013b0] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.080084] [000013b0] libusb: debug [winusb_get_device_list] allocating new device for session [66]
[ 0.081315] [000013b0] libusb: debug [enumerate_hcd_root_hub] assigning HCD 'PCI\VEN_8086&DEV_9D2F&SUBSYS_11341025&REV_21\3&11583659&0&A0' bus number 1
[ 0.085927] [000013b0] libusb: info [winusb_get_device_list] The following device has no driver: 'USB\VID_0E8D&PID_2005&MI_05\7&246317CB&0&0005'
[ 0.086147] [000013b0] libusb: info [winusb_get_device_list] libusb will not be able to access it
[ 0.087903] [000013b0] libusb: debug [init_device] (bus: 1, addr: 0, depth: 0, port: 0): 'USB\ROOT_HUB30\4&AD5D9F5&0&0'
[ 0.104884] [000013b0] libusb: debug [winusb_get_device_list] extra GUID: {F72FE0D4-CBCB-407D-8814-9ED673D0DD6B}
[ 0.105282] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [66]
[ 0.105561] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.105797] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 288 bytes)
[ 0.106658] [000013b0] libusb: debug [init_device] (bus: 1, addr: 8, depth: 2, port: 4): 'USB\VID_0E8D&PID_2005\6&71AD65D&1&4'
[ 0.107915] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [39]
[ 0.108270] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.110010] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 39 bytes)
[ 0.110970] [000013b0] libusb: debug [init_device] (bus: 1, addr: 6, depth: 1, port: 1): 'USB\VID_1A86&PID_7523\5&8B9F473&0&1'
[ 0.121820] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [10]
[ 0.139873] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.140535] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 177 bytes)
[ 0.141209] [000013b0] libusb: debug [init_device] (bus: 1, addr: 3, depth: 1, port: 5): 'USB\VID_8087&PID_0A2A\5&8B9F473&0&5'
[ 0.142347] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [64]
[ 0.142979] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.156270] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 34 bytes)
[ 0.158275] [000013b0] libusb: debug [init_device] (bus: 1, addr: 1, depth: 1, port: 2): 'USB\VID_046D&PID_C05A\5&8B9F473&0&2'
[ 0.159375] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [65]
[ 0.159951] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.160583] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 578 bytes)
[ 0.161500] [000013b0] libusb: debug [init_device] (bus: 1, addr: 4, depth: 1, port: 7): 'USB\VID_0BDA&PID_57F3\200901010001'
[ 0.162725] [000013b0] libusb: debug [winusb_get_device_list] found existing device for session [7F]
[ 0.163090] [000013b0] libusb: debug [init_device] found 1 configurations (active conf: 1)
[ 0.163770] [000013b0] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.164449] [000013b0] libusb: debug [init_device] (bus: 1, addr: 7, depth: 1, port: 4): 'USB\VID_1A40&PID_0101\5&8B9F473&0&4'
[ 0.173797] [000013b0] libusb: debug [winusb_get_device_list] unlisted ancestor for 'HID\ELAN0501&COL01\5&1D53633D&0&0000' (non USB HID, newly connected, etc.) - ignoring
[ 0.174379] [000013b0] libusb: debug [winusb_get_device_list] setting HID interface for [64]:
[ 0.174778] [000013b0] libusb: debug [set_hid_interface] interface[0] = \\.\HID#VID_046D&PID_C05A#6&D4389D9&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.176144] [000013b0] libusb: debug [winusb_get_device_list] unlisted ancestor for 'HID\ELAN0501&COL02\5&1D53633D&0&0001' (non USB HID, newly connected, etc.) - ignoring
[ 0.177587] [000013b0] libusb: debug [winusb_get_device_list] unlisted ancestor for 'HID\ELAN0501&COL03\5&1D53633D&0&0002' (non USB HID, newly connected, etc.) - ignoring
[ 0.178474] [000013b0] libusb: debug [winusb_get_device_list] setting composite interface for [66]:
[ 0.179051] [000013b0] libusb: debug [set_composite_interface] interface[4] = \\.\HID#VID_0E8D&PID_2005&MI_04&COL01#8&12B87DEE&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.179761] [000013b0] libusb: debug [winusb_get_device_list] setting composite interface for [66]:
[ 0.180237] [000013b0] libusb: debug [set_composite_interface] interface[4] already set - ignoring HID collection: HID\VID_0E8D&PID_2005&MI_04&COL02\8&12B87DEE&0&0001
[ 0.181151] [000013b0] libusb: debug [winusb_get_device_list] setting composite interface for [66]:
[ 0.181542] [000013b0] libusb: debug [set_composite_interface] interface[4] already set - ignoring HID collection: HID\VID_0E8D&PID_2005&MI_04&COL03\8&12B87DEE&0&0002
[ 0.182180] [000013b0] libusb: debug [winusb_get_device_list] setting composite interface for [66]:
[ 0.182586] [000013b0] libusb: debug [set_composite_interface] interface[4] already set - ignoring HID collection: HID\VID_0E8D&PID_2005&MI_04&COL04\8&12B87DEE&0&0003
[ 0.186388] [000013b0] libusb: debug [get_api_type] driver(s): WINUSB
[ 0.188742] [000013b0] libusb: debug [get_api_type] matched driver name against WinUSB
[ 0.189432] [000013b0] libusb: debug [winusb_get_device_list] setting composite interface for [66]:
[ 0.189774] [000013b0] libusb: debug [set_composite_interface] interface[6] = \\.\USB#VID_0E8D&PID_2005&MI_06#7&246317CB&0&0006#{F72FE0D4-CBCB-407D-8814-9ED673D0DD6B}
[ 0.193842] [000013b0] libusb: debug [libusb_get_device_descriptor]
[ 0.194958] [000013b0] libusb: debug [libusb_get_device_descriptor]
[ 0.195497] [000013b0] libusb: debug [libusb_open] open 1.8
[ 0.196199] [000013b0] libusb: debug [hid_open] set maximum input buffer size to 512
[ 0.196515] [000013b0] libusb: debug [hid_open] 0 HID input report value(s) found
[ 0.198009] [000013b0] libusb: debug [hid_open] 0 HID output report value(s) found
[ 0.198583] [000013b0] libusb: debug [hid_open] 0 HID feature report value(s) found
[ 0.208932] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.6
[ 0.213299] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.3
[ 0.214778] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.1
[ 0.219094] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.4
[ 1.221470] [000013b0] libusb: debug [libusb_claim_interface] interface 4
[ 1.221902] [000013b0] libusb: debug [hid_claim_interface] claimed interface 4
[ 1.246517] [000013b0] libusb: debug [parse_endpoint] skipping descriptor 25
[ 1.254673] [000013b0] libusb: debug [parse_endpoint] skipping descriptor 25
[ 1.264558] [000013b0] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 83 to interface 4
[ 1.269054] [000013b0] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 03 to interface 4
---before---3783375
[ 1.276081] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.280957] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.282728] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.282876] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 0
[ 1.283578] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.284175] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.284874] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.288033] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.288317] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.290076] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=0, ret=-1
[ 1.293730] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.294413] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.294861] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.295413] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 1
[ 1.297055] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.297710] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.298282] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.299109] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.299485] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.300056] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=1, ret=-1
[ 1.309022] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.310629] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.312036] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.312152] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 2
[ 1.313422] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.319536] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.321338] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.322242] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.324163] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.325445] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=2, ret=-1
[ 1.326564] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.327994] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.328308] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.329652] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 3
[ 1.329795] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.330537] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.331088] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.331942] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.332361] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.332928] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=3, ret=-1
[ 1.334050] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.335858] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.337597] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.337826] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 4
[ 1.339005] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.339539] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.341169] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.341601] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.342181] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.342737] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.343369] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.343791] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.344352] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=4, ret=-1
[ 1.346943] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.347446] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.348037] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.348622] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 5
[ 1.349091] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 1.349510] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 1.349979] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 1.350471] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 1.350954] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 1.351497] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=5, ret=-1
[ 1.352373] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 1.352848] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 1.355062] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 1.356566] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 6
[ 1.358511] [000013b0] libusb: debug [libusb_claim_interface] interface 6
[ 1.360395] [000013b0] libusb: debug [winusbx_claim_interface] claimed interface 6
[ 1.361702] [000013b0] libusb: debug [parse_endpoint] skipping descriptor 25
[ 1.362605] [000013b0] libusb: debug [parse_endpoint] skipping descriptor 25
[ 1.363157] [000013b0] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 04 to interface 6
[ 1.364050] [000013b0] libusb: debug [windows_assign_endpoints] (re)assigned endpoint 84 to interface 6
[ 1.364486] [000013b0] libusb: debug [auto_claim] auto-claimed interface 6 for control request
[ 1.365465] [000013b0] libusb: debug [winusbx_submit_control_transfer] will use interface 6
[ 1.367368] [000013b0] libusb: debug [libusb_get_next_timeout] next timeout in 9.987626s
[ 1.367972] [000013b0] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 1.368781] [000013b0] libusb: debug [handle_events] poll fds modified, reallocating
[ 1.371890] [000013b0] libusb: debug [handle_events] poll() 2 fds with timeout in 9988ms
[ 6.370160] [000013b0] libusb: debug [handle_events] poll() returned 1
[ 6.370310] [000013b0] libusb: debug [windows_handle_events] checking fd 2 with revents = 0004
[ 6.371517] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 6.372243] [000013b0] libusb: debug [windows_transfer_callback] handling I/O completion with errcode 121, size 0
[ 6.372907] [000013b0] libusb: debug [windows_transfer_callback] detected semaphore timeout
[ 6.373662] [000013b0] libusb: debug [libusb_release_interface] interface 6
[ 6.374309] [000013b0] libusb: debug [auto_release] auto-released interface 6
[ 6.374770] [000013b0] libusb: debug [usbi_handle_transfer_completion] transfer 015BD590 has callback 013EACD0
[ 6.375285] [000013b0] libusb: debug [sync_transfer_cb] actual_length=0
[ 6.375964] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=6, ret=-7
[ 6.377067] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 6.377509] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 6.379707] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 6.381046] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 7
[ 6.381744] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 6.382278] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 6.382880] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 6.383469] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 6.384033] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 6.384613] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=7, ret=-1
[ 6.385733] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 6.386596] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 6.387246] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 6.387918] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 8
[ 6.388490] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 6.388995] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 6.390933] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 6.392555] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 6.393107] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 6.393713] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=8, ret=-1
[ 6.394905] [000013b0] libusb: debug [libusb_alloc_transfer] transfer 015BD590
[ 6.395447] [000013b0] libusb: debug [libusb_submit_transfer] transfer 015BD590
[ 6.396297] [000013b0] libusb: debug [usbi_add_pollfd] add fd 2 events 4
[ 6.396810] [000013b0] libusb: debug [composite_submit_control_transfer] attempting control transfer targeted to interface 9
[ 6.397427] [000013b0] libusb: debug [composite_submit_control_transfer] using interface 4
[ 6.397913] [000013b0] libusb: debug [hid_submit_control_transfer] will use interface 4
[ 6.398451] [000013b0] libusb: debug [_hid_set_report] report ID: 0x01
[ 6.399058] [000013b0] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] Incorrect function。
[ 6.399498] [000013b0] libusb: debug [usbi_remove_pollfd] remove fd 2
[ 6.402661] [000013b0] libusb: debug [libusb_free_transfer] transfer 015BD590
libusb_control_transfer,wIndex=9, ret=-1
actual_len=0
---after ---ret=-1,lastErr=1,3788500
libusb_control_transfer usbError=-1, winError=1
[ 8.406078] [000013b0] libusb: debug [libusb_release_interface] interface 4
[ 8.406406] [000013b0] libusb: debug [libusb_close]
[ 8.408180] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.8
[ 8.408717] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.7
[ 8.409151] [000013b0] libusb: debug [libusb_unref_device] destroy device 1.0
press Enter to ext..

5, my usb device info:

Current Configuration	1
Speed	Full (12 Mbit/s)
Device Address	5
Number Of Open Pipes	6
Device Descriptor Note N1 
Offset	Field	Size	Value	Description
0	bLength	1	12h	
1	bDescriptorType	1	01h	Device
2	bcdUSB	2	0100h	USB Spec 1.0
4	bDeviceClass	1	00h	Class info in Ifc Descriptors
5	bDeviceSubClass	1	00h	
6	bDeviceProtocol	1	00h	
7	bMaxPacketSize0	1	40h	64 bytes
8	idVendor	2	0E8Dh	MediaTek Inc.
10	idProduct	2	2005h	
12	bcdDevice	2	0306h	3.06
14	iManufacturer	1	03h	"TEST."
15	iProduct	1	04h	"Note N1."
16	iSerialNumber	1	05h	
17	bNumConfigurations	1	01h	
Configuration Descriptor 1 
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	02h	Configuration
2	wTotalLength	2	0120h	
4	bNumInterfaces	1	07h	
5	bConfigurationValue	1	01h	
6	iConfiguration	1	00h	
7	bmAttributes	1	C0h	Self Powered
	4..0: Reserved		...00000 	
	5: Remote Wakeup		..0..... 	No
	6: Self Powered		.1...... 	Yes
	7: Reserved (set to one)
(bus-powered for 1.0)		1....... 	
8	bMaxPower	1	FAh	500 mA
Interface Descriptor 0/0 Audio, 0 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	00h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	00h	
5	bInterfaceClass	1	01h	Audio
6	bInterfaceSubClass	1	01h	Audio Control
7	bInterfaceProtocol	1	00h	
8	iInterface	1	43h	"TEST Note N1"
Audio Control Interface Header Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Ah	
1	bDescriptorType	1	24h	Audio Control Interface Header
2		8	01 00 01 4F 00 02 01 02 	
Audio Control Input Terminal Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Ch	
1	bDescriptorType	1	24h	Audio Control Input Terminal
2		10	02 01 01 01 00 01 01 00 
00 00 	
Audio Control Input Terminal Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Ch	
1	bDescriptorType	1	24h	Audio Control Input Terminal
2		10	02 04 05 04 00 01 01 00 
00 00 	
Audio Control Output Terminal Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	24h	Audio Control Output Terminal
2		7	03 06 05 04 00 09 00 	
Audio Control Output Terminal Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	24h	Audio Control Output Terminal
2		7	03 07 01 01 00 08 00 	
Audio Control Selector Unit Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	24h	Audio Control Selector Unit
2		5	05 08 01 0A 00 	
Audio Control Feature Unit Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	24h	Audio Control Feature Unit
2		7	06 09 01 02 03 00 00 	
Audio Control Feature Unit Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Bh	
1	bDescriptorType	1	24h	Audio Control Feature Unit
2		9	06 0A 04 02 03 00 00 00 
00 	
Interface Descriptor 1/0 Audio, 0 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	01h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	00h	
5	bInterfaceClass	1	01h	Audio
6	bInterfaceSubClass	1	02h	Audio Streaming
7	bInterfaceProtocol	1	00h	
8	iInterface	1	44h	"Playback Inactive"
Interface Descriptor 1/1 Audio, 1 Endpoint
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	01h	
3	bAlternateSetting	1	01h	
4	bNumEndpoints	1	01h	
5	bInterfaceClass	1	01h	Audio
6	bInterfaceSubClass	1	02h	Audio Streaming
7	bInterfaceProtocol	1	00h	
8	iInterface	1	45h	"Playback Active"
Audio Streaming Interface Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	24h	Audio Streaming Interface
2		5	01 01 01 01 00 	
Audio Streaming Format Type Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Bh	
1	bDescriptorType	1	24h	Audio Streaming Format Type
2		9	02 01 01 02 10 01 80 BB 
00 	
Endpoint Descriptor 01 1 Out, Isochronous, 1 ms
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	01h	1 Out
3	bmAttributes	1	09h	Isochronous, Adaptive, Data
	1..0: Transfer Type		......01 	Isochronous
	7..2: Reserved		000010.. 	Reserved, should be zero
4	wMaxPacketSize	2	0200h	512 bytes
6	bInterval	1	01h	1 ms
7	bRefresh	1	00h	
8	bSynchAddress	1	00h	
Audio Streaming Isochronous Audio Data Endpoint Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	25h	Audio Streaming Isochronous Audio Data Endpoint
2		5	01 01 01 01 00 	
Interface Descriptor 2/0 Audio, 0 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	02h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	00h	
5	bInterfaceClass	1	01h	Audio
6	bInterfaceSubClass	1	02h	Audio Streaming
7	bInterfaceProtocol	1	00h	
8	iInterface	1	46h	"Capture Inactive"
Interface Descriptor 2/1 Audio, 1 Endpoint
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	02h	
3	bAlternateSetting	1	01h	
4	bNumEndpoints	1	01h	
5	bInterfaceClass	1	01h	Audio
6	bInterfaceSubClass	1	02h	Audio Streaming
7	bInterfaceProtocol	1	00h	
8	iInterface	1	47h	"Capture Active"
Audio Streaming Interface Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	24h	Audio Streaming Interface
2		5	01 07 01 01 00 	
Audio Streaming Format Type Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	0Bh	
1	bDescriptorType	1	24h	Audio Streaming Format Type
2		9	02 01 01 02 10 01 80 BB 
00 	
Endpoint Descriptor 81 1 In, Isochronous, 1 ms
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	81h	1 In
3	bmAttributes	1	09h	Isochronous, Adaptive, Data
	1..0: Transfer Type		......01 	Isochronous
	7..2: Reserved		000010.. 	Reserved, should be zero
4	wMaxPacketSize	2	0064h	100 bytes
6	bInterval	1	01h	1 ms
7	bRefresh	1	00h	
8	bSynchAddress	1	00h	
Audio Streaming Isochronous Audio Data Endpoint Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	25h	Audio Streaming Isochronous Audio Data Endpoint
2		5	01 01 00 00 00 	
Interface Descriptor 3/0 Mass Storage, 2 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	03h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	02h	
5	bInterfaceClass	1	08h	Mass Storage
6	bInterfaceSubClass	1	06h	SCSI Transparent Command Set
7	bInterfaceProtocol	1	50h	Bulk-Only Transport
8	iInterface	1	01h	"Mass Storage"
Endpoint Descriptor 82 2 In, Bulk, 64 bytes
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	82h	2 In
3	bmAttributes	1	02h	Bulk
	1..0: Transfer Type		......10 	Bulk
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	00h	
Endpoint Descriptor 02 2 Out, Bulk, 64 bytes
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	02h	2 Out
3	bmAttributes	1	02h	Bulk
	1..0: Transfer Type		......10 	Bulk
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	00h	
Interface Descriptor 4/0 HID, 2 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	04h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	02h	
5	bInterfaceClass	1	03h	HID
6	bInterfaceSubClass	1	00h	
7	bInterfaceProtocol	1	00h	
8	iInterface	1	49h	"HID Interface"
HID Descriptor 
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	21h	HID
2	bcdHID	2	0101h	1.01
4	bCountryCode	1	00h	
5	bNumDescriptors	1	01h	
6	bDescriptorType	1	22h	Report
7	wDescriptorLength	2	0162h	354 bytes
Endpoint Descriptor 83 3 In, Interrupt, 10 ms
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	83h	3 In
3	bmAttributes	1	03h	Interrupt
	1..0: Transfer Type		......11 	Interrupt
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	0Ah	10 ms
Endpoint Descriptor 03 3 Out, Interrupt, 10 ms
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	03h	3 Out
3	bmAttributes	1	03h	Interrupt
	1..0: Transfer Type		......11 	Interrupt
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	0Ah	10 ms
Interface Descriptor 5/0 Vendor-Specific, 0 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	05h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	00h	
5	bInterfaceClass	1	FFh	Vendor-Specific
6	bInterfaceSubClass	1	FFh	
7	bInterfaceProtocol	1	FFh	
8	iInterface	1	4Ah	"TEST Control"
Interface Descriptor 6/0 Vendor-Specific, 2 Endpoints
Offset	Field	Size	Value	Description
0	bLength	1	09h	
1	bDescriptorType	1	04h	Interface
2	bInterfaceNumber	1	06h	
3	bAlternateSetting	1	00h	
4	bNumEndpoints	1	02h	
5	bInterfaceClass	1	FFh	Vendor-Specific
6	bInterfaceSubClass	1	42h	
7	bInterfaceProtocol	1	01h	
8	iInterface	1	4Ch	"My Interface"
Endpoint Descriptor 04 4 Out, Bulk, 64 bytes
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	04h	4 Out
3	bmAttributes	1	02h	Bulk
	1..0: Transfer Type		......10 	Bulk
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	00h	
Endpoint Descriptor 84 4 In, Bulk, 64 bytes
Offset	Field	Size	Value	Description
0	bLength	1	07h	
1	bDescriptorType	1	05h	Endpoint
2	bEndpointAddress	1	84h	4 In
3	bmAttributes	1	02h	Bulk
	1..0: Transfer Type		......10 	Bulk
	7..2: Reserved		000000.. 	
4	wMaxPacketSize	2	0040h	64 bytes
6	bInterval	1	00h	

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionTechnical support, will be closed if deemed not a libusb issue. Please use mailing list.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions