Skip to content

Commit bbc7385

Browse files
authored
Fix libusb_bulk_transfer timeout on some Android devices (#19)
* Reduce buffer size * Reduce aggregation
1 parent 9aaf0e4 commit bbc7385

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/RtlUsbAdapter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ RtlUsbAdapter::RtlUsbAdapter(libusb_device_handle *dev_handle, Logger_t logger)
2121

2222
if (usbSpeed > LIBUSB_SPEED_HIGH) // USB 3.0
2323
{
24-
rxagg_usb_size = 0x7;
25-
rxagg_usb_timeout = 0x1a;
24+
rxagg_usb_size = 0x3; // 16KB
25+
rxagg_usb_timeout = 0x01;
2626
} else {
27-
/* the setting to reduce RX FIFO overflow on USB2.0 and increase rx
27+
/* the setting to reduce RX FIFO overflow on USB2.0 and increase rx
2828
* throughput */
29-
rxagg_usb_size = 0x5;
30-
rxagg_usb_timeout = 0x20;
29+
rxagg_usb_size = 0x1; // 8KB
30+
rxagg_usb_timeout = 0x01;
3131
}
3232

3333
GetChipOutEP8812();
@@ -56,7 +56,8 @@ RtlUsbAdapter::RtlUsbAdapter(libusb_device_handle *dev_handle, Logger_t logger)
5656
*/
5757

5858
std::vector<Packet> RtlUsbAdapter::infinite_read() {
59-
uint8_t buffer[65000] = {0};
59+
static constexpr int BUF_SIZE = 16 * 1024;
60+
uint8_t buffer[BUF_SIZE] = {};
6061
int actual_length = 0;
6162
int rc;
6263

0 commit comments

Comments
 (0)