benjamin_t
2014-01-09 04:14:24 UTC
Hi,
I'm attempting to write to a bulk endpoint with libusb_bulk_transfer,
and got a strange problem. It returns with a TIMEOUT_ERROR, and the
transferred parameter was set to 0, which indicates no data was sent.
The interface descriptor info is as below:
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 220 Diagnostic
bInterfaceSubClass 160
bInterfaceProtocol 176
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 10
And here is my test code
int rv = 0;
rv = libusb_init(NULL);
if (rv < 0) {
std::cout << "*** initial USB lib failed!" << std::endl;
return -1;
}
libusb_set_debug(NULL, 4);
struct libusb_device_handle *usb_handle;
usb_handle = libusb_open_device_with_vid_pid(NULL, USB_VENDOR_ID,
USB_PRODUCT_ID);
int ret = libusb_claim_interface(usb_handle, 0);
unsigned char read_buf[64];
unsigned char send_buf[25] = {0};
int transferred;
ret = libusb_bulk_transfer(usb_handle, 0x2, send_buf, 64, &transferred,
1000);
std::cout << "tran " << transferred << std::endl; // output 0
std::cout << ret << std::endl; // output
-7
libusb_bulk_transfer(usb_handle, 0x82, read_buf, 64, &transferred,
1000);
PrintBuf(read_buf, 64);
The code above works fine when 0x2 and 0x82 was set to 0x1 and 0x81. It
seems like the 0x2 endpoint was not working. Any idea what would cause that?
Thanks in advance!
--
View this message in context: http://libusb.6.n5.nabble.com/libusb-bulk-transfer-return-timeout-error-and-transferred-set-to-0-tp5712761.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.
I'm attempting to write to a bulk endpoint with libusb_bulk_transfer,
and got a strange problem. It returns with a TIMEOUT_ERROR, and the
transferred parameter was set to 0, which indicates no data was sent.
The interface descriptor info is as below:
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 220 Diagnostic
bInterfaceSubClass 160
bInterfaceProtocol 176
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 10
And here is my test code
int rv = 0;
rv = libusb_init(NULL);
if (rv < 0) {
std::cout << "*** initial USB lib failed!" << std::endl;
return -1;
}
libusb_set_debug(NULL, 4);
struct libusb_device_handle *usb_handle;
usb_handle = libusb_open_device_with_vid_pid(NULL, USB_VENDOR_ID,
USB_PRODUCT_ID);
int ret = libusb_claim_interface(usb_handle, 0);
unsigned char read_buf[64];
unsigned char send_buf[25] = {0};
int transferred;
ret = libusb_bulk_transfer(usb_handle, 0x2, send_buf, 64, &transferred,
1000);
std::cout << "tran " << transferred << std::endl; // output 0
std::cout << ret << std::endl; // output
-7
libusb_bulk_transfer(usb_handle, 0x82, read_buf, 64, &transferred,
1000);
PrintBuf(read_buf, 64);
The code above works fine when 0x2 and 0x82 was set to 0x1 and 0x81. It
seems like the 0x2 endpoint was not working. Any idea what would cause that?
Thanks in advance!
--
View this message in context: http://libusb.6.n5.nabble.com/libusb-bulk-transfer-return-timeout-error-and-transferred-set-to-0-tp5712761.html
Sent from the LibUSB Dev mailing list archive at Nabble.com.