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?
see change 0d48ed04e7cf3ff83c8089d4dedf61f1ba7277be:
Always use async read, as bulkTransfer can cause data loss. Increase API version to 17 because async read only works reliably since Android 4.2 (http://b.android.com/28023)
did you use an older version of the library or changed minSdkVersion to 16?
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?