From be32e549272bf586c93954385738a46c7b589553 Mon Sep 17 00:00:00 2001 From: kai-morich Date: Wed, 12 Aug 2020 08:06:07 +0200 Subject: [PATCH] Updated Troubleshooting (markdown) --- Troubleshooting.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Troubleshooting.md b/Troubleshooting.md index cd607f8..f3e0f69 100644 --- a/Troubleshooting.md +++ b/Troubleshooting.md @@ -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.