Using felUsbSerial - v1.12 on Android 8.1 with FTDI PID 0x6010
The serial communication works for a variable length of time before an exception in the library.
Connecting to a serial device, requesting data from it every half second or so, data out is 10 or so characters, data in is usually 10 or so characters, occasionally 100 characters in a burst.
Randomly, anywhere from within 10 seconds of connection, to as long as 5 minutes later I get a Array index out of bounds error shown below. For the input buffer size, I see the "Default value is 16 * 1024", and this app has no where near enough data to overflow the buffer. (I doubled it to 32*1024 and still had the error) Is the buffer argument sent to the event only 60 bytes? In observation I never see it have more than 20 characters at a time sent to the event in normal operation of the app.
What is the best way to trap this exception and prevent it from taking down the app? Ideally I'd like to detect the error and recover.
Also, regularly losing 2 or three characters from messages. Occurs on a similar random interval. May or may not be related.
Is source code for this library available to help solve it?
Public usbserial As felUsbSerial
java.lang.ArrayIndexOutOfBoundsException: length=61; index=61
at com.felhr.usbserial.FTDISerialDevice$FTDIUtilities.copyData(FTDISerialDevice.java:594)
at com.felhr.usbserial.FTDISerialDevice$FTDIUtilities.adaptArray(FTDISerialDevice.java:502)
at com.felhr.usbserial.UsbSerialDevice$WorkerThread.run(UsbSerialDevice.java:248)