1
0
mirror of https://github.com/mik3y/usb-serial-for-android synced 2025-06-10 09:26:23 +00:00

Updated Troubleshooting (markdown)

kai-morich 2020-08-12 08:06:07 +02:00
parent a9c2e024a3
commit be32e54927

@ -45,6 +45,17 @@ For example, to receive a 100 byte string, you might read 64 bytes, then 36 byte
* Length-prefixed messages: Prefix every message with a fixed-length `size` value; your message is complete after you've read `size` more bytes.
* Newline-terminated messages: Read until you see a `\n` (or any other "terminal" character).
## I observed read _data loss_ with continuous transfer at high baud rates
Android is not a real time OS. The thread responsible for receiving data might not be scheduled by the OS or garbage collection might be ongoing or …
Therefore data loss can happen for continues read at high baud rates. If data is lost, typically some smaller fragments in the middle of the data are missing.
This effect is more likely for slower Android device and USB devices with smaller buffer size and typically starts with higher baud rates like 115k2 baud, but is hardly predictable. For low baud rates or non-continuous transfers this issue was not observed as the USB device will not run into a read buffer overflow before the next USB read transfer.
Using a higher thread priority for `SerialInputOutputManager` (as used [here](https://github.com/mik3y/usb-serial-for-android/blob/73d669c4dc9af4bccdfdd35b1ff4d8e6c9c16ce9/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/util/UsbWrapper.java#L164)) and offloading work from `onNewData` to other threads sometimes mitigates the issue.
## Is `write` synchronous?
It's typically not.