libusb1.0 库 函数libusb_control_transfer 调用失败
在调用libusb库时候 ,打开设备是成功的状态下,函数 libusb_control_transfer 往USB设备写入数据时候失败,下面是libusb_set_debug输出的部分信息。
unsigned char tmp[3] = {0xa0, 0x81, 0x01};
int ret = libusb_control_transfer(dev_handle, (uint8_t)0x21,
(uint8_t)0x09, /* set/get test */
(uint16_t)0x02ba, /* test type */
(uint16_t)0, /* interface id */
tmp, (uint16_t)3, (unsigned int)1000);
ret 返回-1 写入失败
USB设备数据传输协议 部分如下,
Set Report
Setup packet[0] = 0x21;
Setup packet[1] = 0x09;
Setup packet[2] = 0xba;
Setup packet[3] = 0x02;
Setup packet[4] = 0x00;
Setup packet[5] = 0x00;
Setup packet[6] = DATA LEN;
Setup packet[7] = 0x00;
libusb_set_debug 调试信息:
[ 0.523030] [00000ba4] libusb: debug [_hid_set_report] report ID: 0xBA
[ 0.523030] [00000ba4] libusb: warning [_hid_set_report] mismatched report ID (data is A0, parameter is BA)
[ 0.523030] [00000ba4] libusb: debug [_hid_set_report] Failed to Write HID Output Report: [1] 函数不正确。
[ 0.523030] [00000ba4] libusb: debug [composite_submit_control_transfer] trying to skip restricted interface #0 (HID keyboard or mouse?)
[ 0.523030] [00000ba4] libusb: debug [composite_submit_control_transfer] trying to skip restricted interface #1 (HID keyboard or mouse?)
win32的部分 也是相同参数 写入是OK的 求大牛指教 libusb_control_transfer的参数 是否填写有误?
char tmp[3] = {0xa0, 0x81, 0x01};
int ret = usb_control_msg(dev, 0x21,
0x09, /* set/get test */
0x02ba, /* test type */
0, /* interface id */
tmp, 3, 1000);