mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.83k stars 1.58k forks source link

Zero bytes read #368

Closed darkyp closed 3 years ago

darkyp commented 3 years ago

Hello,

This is not really an issue but I'm sharing my findings.

I used the code on a Xiaomi Redmi 9C (Android 10) connected to a CDC device and everything is working properly. The same code on an old Samsung Tab 7.7 (P6800) with Android 4.1.2 has the problem of the UsbSerialPort.read returning 0 bytes read, while still the CDC connected device is sending data. I did read the FAQ and the common problem of having the wrong baud rate, however this is not the issue. I use the UsbSerialPort.read in synchronous/blocking mode (timeout = 0). It turns out that using UsbConnection.bulkTransfer with a zero timeout instead of { UsbRequest.queue ; UsbConnection.requestWait } resolves my issue (CommonUsbSerialPort.java).

So I am wondering why not use UsbConnection.bulkTransfer with zero timeout instead of the UsbRequest?

kai-morich commented 3 years ago

see change 0d48ed04e7cf3ff83c8089d4dedf61f1ba7277be:

did you use an older version of the library or changed minSdkVersion to 16?