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)
Searching for java directories please wait....
Searching for Directories
C:\Users\green\AppData\Roaming\Anywhere Software\Basic4android\
Using Extra Libs Folder : C:\b4aExtraLibs\
Using Compiler Path : D:\graalvm-comm-openjdk-22\bin\
Compiling sources in : C:\SuperSLC\felUsbSerial\src
Class output to : C:\SuperSLC\felUsbSerial\bin\classes
(B4A) Library Name : felUsbSearial
Error: Note: C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSerialDevice.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\SerialInputStream.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Compiled in : 1.6760588 Seconds
Created jar in : 0.7517523 Seconds
Loading source file .\com\felhr\deviceids\CH34xIds.java...
Loading source file .\com\felhr\deviceids\CP210xIds.java...
Loading source file .\com\felhr\deviceids\CP2130Ids.java...
Loading source file .\com\felhr\deviceids\FTDISioIds.java...
Loading source file .\com\felhr\deviceids\PL2303Ids.java...
Loading source file .\com\felhr\deviceids\XdcVcpIds.java...
Loading source file .\com\felhr\usbserial\BLED112SerialDevice.java...
Loading source file .\com\felhr\usbserial\CDCSerialDevice.java...
Loading source file .\com\felhr\usbserial\CH34xSerialDevice.java...
Loading source file .\com\felhr\usbserial\CP2102SerialDevice.java...
Loading source file .\com\felhr\usbserial\CP2130SpiDevice.java...
Loading source file .\com\felhr\usbserial\FTDISerialDevice.java...
Loading source file .\com\felhr\usbserial\PL2303SerialDevice.java...
Loading source file .\com\felhr\usbserial\SerialBuffer.java...
Loading source file .\com\felhr\usbserial\SerialInputStream.java...
Loading source file .\com\felhr\usbserial\SerialOutputStream.java...
Loading source file .\com\felhr\usbserial\UsbSerialDebugger.java...
Loading source file .\com\felhr\usbserial\UsbSerialDevice.java...
Loading source file .\com\felhr\usbserial\UsbSerialInterface.java...
Loading source file .\com\felhr\usbserial\UsbSpiDevice.java...
Loading source file .\com\felhr\usbserial\UsbSpiInterface.java...
Loading source file .\com\felhr\usbserial\XdcVcpSerialDevice.java...
Loading source file .\com\felhr\utils\HexData.java...
Loading source file .\anywheresoftware\b4a\objects\usb\felUsbSerial.java...
Constructing Javadoc information...
BADoclet2 version 2.00
starting...
Working with class: com.felhr.deviceids.CH34xIds
No ShortName annotation found for class: com.felhr.deviceids.CH34xIds
Working with class: com.felhr.deviceids.CP210xIds
No ShortName annotation found for class: com.felhr.deviceids.CP210xIds
Working with class: com.felhr.deviceids.CP2130Ids
No ShortName annotation found for class: com.felhr.deviceids.CP2130Ids
Working with class: com.felhr.deviceids.FTDISioIds
No ShortName annotation found for class: com.felhr.deviceids.FTDISioIds
Working with class: com.felhr.deviceids.PL2303Ids
No ShortName annotation found for class: com.felhr.deviceids.PL2303Ids
Working with class: com.felhr.deviceids.XdcVcpIds
No ShortName annotation found for class: com.felhr.deviceids.XdcVcpIds
Working with class: com.felhr.usbserial.BLED112SerialDevice
No ShortName annotation found for class: com.felhr.usbserial.BLED112SerialDevice
Working with class: com.felhr.usbserial.CDCSerialDevice
No ShortName annotation found for class: com.felhr.usbserial.CDCSerialDevice
Working with class: com.felhr.usbserial.CH34xSerialDevice
No ShortName annotation found for class: com.felhr.usbserial.CH34xSerialDevice
Working with class: com.felhr.usbserial.CP2102SerialDevice
No ShortName annotation found for class: com.felhr.usbserial.CP2102SerialDevice
Working with class: com.felhr.usbserial.CP2130SpiDevice
No ShortName annotation found for class: com.felhr.usbserial.CP2130SpiDevice
Working with class: com.felhr.usbserial.FTDISerialDevice
No ShortName annotation found for class: com.felhr.usbserial.FTDISerialDevice
Working with class: com.felhr.usbserial.FTDISerialDevice.FTDIUtilities
No ShortName annotation found for class: com.felhr.usbserial.FTDISerialDevice.FTDIUtilities
Working with class: com.felhr.usbserial.PL2303SerialDevice
No ShortName annotation found for class: com.felhr.usbserial.PL2303SerialDevice
Working with class: com.felhr.usbserial.SerialBuffer
No ShortName annotation found for class: com.felhr.usbserial.SerialBuffer
Working with class: com.felhr.usbserial.SerialInputStream
No ShortName annotation found for class: com.felhr.usbserial.SerialInputStream
Working with class: com.felhr.usbserial.SerialOutputStream
No ShortName annotation found for class: com.felhr.usbserial.SerialOutputStream
Working with class: com.felhr.usbserial.UsbSerialDebugger
No ShortName annotation found for class: com.felhr.usbserial.UsbSerialDebugger
Working with class: com.felhr.usbserial.UsbSerialDevice
No ShortName annotation found for class: com.felhr.usbserial.UsbSerialDevice
Working with class: com.felhr.usbserial.UsbSerialDevice.ReadThread
No ShortName annotation found for class: com.felhr.usbserial.UsbSerialDevice.ReadThread
Working with class: com.felhr.usbserial.UsbSerialDevice.WriteThread
No ShortName annotation found for class: com.felhr.usbserial.UsbSerialDevice.WriteThread
Working with class: com.felhr.usbserial.UsbSerialDevice.WorkerThread
No ShortName annotation found for class: com.felhr.usbserial.UsbSerialDevice.WorkerThread
Working with class: com.felhr.usbserial.UsbSpiDevice
No ShortName annotation found for class: com.felhr.usbserial.UsbSpiDevice
Working with class: com.felhr.usbserial.UsbSpiDevice.ReadThread
No ShortName annotation found for class: com.felhr.usbserial.UsbSpiDevice.ReadThread
Working with class: com.felhr.usbserial.UsbSpiDevice.WriteThread
No ShortName annotation found for class: com.felhr.usbserial.UsbSpiDevice.WriteThread
Working with class: com.felhr.usbserial.XdcVcpSerialDevice
No ShortName annotation found for class: com.felhr.usbserial.XdcVcpSerialDevice
Working with class: com.felhr.utils.HexData
No ShortName annotation found for class: com.felhr.utils.HexData
Working with class: anywheresoftware.b4a.objects.usb.felUsbSerial
finish: C:\b4aExtraLibs\felUsbSearial.xml
Created xml in : 1.4043976 Seconds
No it's a brand new SLC that I wrote. (does B4J and B4A in one app)Was this built with your SLC version from here?
The new SLC doesn't need a bat file for the xml creation.Did you have to do your bat file step from here?
let me know and I will try it.There is a chance it needs to pull in the entire file
java.lang.ArrayIndexOutOfBoundsException: src.length=65 srcPos=2 dst.length=61 dstPos=0 length=62
at java.lang.System.arraycopy(System.java:521)
at com.felhr.usbserial.FTDISerialDevice$FTDIUtilities.copyData(FTDISerialDevice.java:592)
at com.felhr.usbserial.FTDISerialDevice$FTDIUtilities.adaptArray(FTDISerialDevice.java:508)
at com.felhr.usbserial.UsbSerialDevice$WorkerThread.run(UsbSerialDevice.java:253)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
autoversion: 1.0
compilation time: 12/04/2020 19:45:50
2 devices
/dev/bus/usb/001/004
1004
3823 1
1
/dev/bus/usb/001/003
1003
1027 24592
2
Connecting to /dev/bus/usb/001/003
java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Buffer;
at com.felhr.usbserial.SerialBuffer$SynchronizedBuffer.<init>(SerialBuffer.java:97)
at com.felhr.usbserial.SerialBuffer.<init>(SerialBuffer.java:21)
at com.felhr.usbserial.UsbSerialDevice.<init>(UsbSerialDevice.java:58)
at com.felhr.usbserial.FTDISerialDevice.<init>(FTDISerialDevice.java:110)
at com.felhr.usbserial.UsbSerialDevice.createUsbSerialDevice(UsbSerialDevice.java:77)
at anywheresoftware.b4a.objects.usb.felUsbSerial.Initialize2(felUsbSerial.java:91)
at anywheresoftware.b4a.objects.usb.felUsbSerial.Initialize(felUsbSerial.java:79)
at com.tswa.indicator.wiredscalemanager._findandconnect(wiredscalemanager.java:264)
at com.tswa.indicator.main._reconnect(main.java:615)
at com.tswa.indicator.main$ResumableSub_Activity_Create.resume(main.java:553)
at com.tswa.indicator.main._activity_create(main.java:419)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at com.tswa.indicator.main.afterFirstLayout(main.java:108)
at com.tswa.indicator.main.access$000(main.java:20)
at com.tswa.indicator.main$WaitForLayout.run(main.java:86)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Buffer" on path: DexPathList[[zip file "/data/app/com.tswa.indicator-13PjMIZ5bYEwyOyCnsRRQQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.tswa.indicator-13PjMIZ5bYEwyOyCnsRRQQ==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
** Activity (main) Resume **
static byte[] adaptArray(byte[] ftdiData)
{
return Arrays.copyOfRange(ftdiData, 0, ftdiData.length);
}
public byte[] adaptArray(byte[] ftdiData)
{
int length = ftdiData.length;
if(length > 64)
{
int n = 1;
int p = 64;
// Precalculate length without FTDI headers
while(p < length)
{
n++;
p = n*64;
}
int realLength = length - n*2;
byte[] data = new byte[realLength];
copyData(ftdiData, data);
return data;
}else
{
return Arrays.copyOfRange(ftdiData, 2, length);
}
}
{
return Arrays.copyOfRange(ftdiData, 2, length);
}
// Special treatment needed to FTDI devices
/* public byte[] adaptArray(byte[] ftdiData)
{
int length = ftdiData.length;
if(length > 64)
{
int n = 1;
int p = 64;
// Precalculate length without FTDI headers
while(p < length)
{
n++;
p = n*64;
}
int realLength = length - n*2;
byte[] data = new byte[realLength];
copyData(ftdiData, data);
return data;
}else
{
return Arrays.copyOfRange(ftdiData, 2, length);
}
}
*/
public byte[] adaptArray(byte[] ftdiData)
{
return Arrays.copyOfRange(ftdiData, 0, ftdiData.length);
}
Reading settings file
Searching for IDE directory settings (Default values if not changed)
Scanning C:\Users\green\AppData\Roaming\Anywhere Software\Basic4android\ for defaults
Using Extra Libs Folder : C:\b4aExtraLibs\
Using Compiler Path : c:/jdk-11/bin
Compiling sources in : C:\SuperSLC\felUsbSerial\src
Class output to : C:\SuperSLC\felUsbSerial\bin\classes
(B4A) Library Name : felUsbSerial
Using arguments : -b4aignore com.felhr
args : -cp C:\android\platforms\android-34\Android.jar;C:\b4aExtraLibs\*;"C:\Program Files\Anywhere software\B4A\Libraries\*";C:\SuperSLC\felUsbSerial\libs\* -d C:\SuperSLC\felUsbSerial\bin\classes C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\CH34xIds.java C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\CP210xIds.java C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\CP2130Ids.java C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\FTDISioIds.java C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\PL2303Ids.java C:\SuperSLC\felUsbSerial\src\com\felhr\deviceids\XdcVcpIds.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\BLED112SerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\CDCSerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\CH34xSerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\CP2102SerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\CP2130SpiDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\FTDISerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\PL2303SerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\SerialBuffer.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\SerialInputStream.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\SerialOutputStream.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSerialDebugger.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSerialInterface.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSpiDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\UsbSpiInterface.java C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\XdcVcpSerialDevice.java C:\SuperSLC\felUsbSerial\src\com\felhr\utils\HexData.java C:\SuperSLC\felUsbSerial\src\com\felhr\utils\SafeUsbRequest.java C:\SuperSLC\felUsbSerial\src\anywheresoftware\b4a\objects\usb\felUsbSerial.java
Error: Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\SuperSLC\felUsbSerial\src\com\felhr\usbserial\SerialInputStream.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Compiled in : 1.962 Seconds
Created jar in : 0.945 Seconds
Ignoring: [com.felhr]
Loading source file .\com\felhr\deviceids\CH34xIds.java...
Loading source file .\com\felhr\deviceids\CP210xIds.java...
Loading source file .\com\felhr\deviceids\CP2130Ids.java...
Loading source file .\com\felhr\deviceids\FTDISioIds.java...
Loading source file .\com\felhr\deviceids\PL2303Ids.java...
Loading source file .\com\felhr\deviceids\XdcVcpIds.java...
Loading source file .\com\felhr\usbserial\BLED112SerialDevice.java...
Loading source file .\com\felhr\usbserial\CDCSerialDevice.java...
Loading source file .\com\felhr\usbserial\CH34xSerialDevice.java...
Loading source file .\com\felhr\usbserial\CP2102SerialDevice.java...
Loading source file .\com\felhr\usbserial\CP2130SpiDevice.java...
Loading source file .\com\felhr\usbserial\FTDISerialDevice.java...
Loading source file .\com\felhr\usbserial\PL2303SerialDevice.java...
Loading source file .\com\felhr\usbserial\SerialBuffer.java...
Loading source file .\com\felhr\usbserial\SerialInputStream.java...
Loading source file .\com\felhr\usbserial\SerialOutputStream.java...
Loading source file .\com\felhr\usbserial\UsbSerialDebugger.java...
Loading source file .\com\felhr\usbserial\UsbSerialDevice.java...
Loading source file .\com\felhr\usbserial\UsbSerialInterface.java...
Loading source file .\com\felhr\usbserial\UsbSpiDevice.java...
Loading source file .\com\felhr\usbserial\UsbSpiInterface.java...
Loading source file .\com\felhr\usbserial\XdcVcpSerialDevice.java...
Loading source file .\com\felhr\utils\HexData.java...
Loading source file .\com\felhr\utils\SafeUsbRequest.java...
Loading source file .\anywheresoftware\b4a\objects\usb\felUsbSerial.java...
Constructing Javadoc information...
BADoclet2 version 2.00
starting...
Working with class: anywheresoftware.b4a.objects.usb.felUsbSerial
finish: C:\b4aExtraLibs\felUsbSerial.xml
Created xml in : 1.618 Seconds
public byte[] adaptArray(byte[] ftdiData)
{
if (ftdiData.length <2)
{
return EMPTY_BYTE_ARRAY;
}
else {
return Arrays.copyOfRange(ftdiData, 2, ftdiData.length-2);
}
}
/dev/bus/usb/001/003
1003
1027 24592
2
Connecting to /dev/bus/usb/001/003
java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Buffer;
at com.felhr.usbserial.SerialBuffer$SynchronizedBuffer.<init>(SerialBuffer.java:97)
at com.felhr.usbserial.SerialBuffer.<init>(SerialBuffer.java:21)
at com.felhr.usbserial.UsbSerialDevice.<init>(UsbSerialDevice.java:55)
at com.felhr.usbserial.FTDISerialDevice.<init>(FTDISerialDevice.java:111)
at com.felhr.usbserial.UsbSerialDevice.createUsbSerialDevice(UsbSerialDevice.java:73)
at anywheresoftware.b4a.objects.usb.felUsbSerial.Initialize2(felUsbSerial.java:112)
at anywheresoftware.b4a.objects.usb.felUsbSerial.Initialize(felUsbSerial.java:98)
at com.tswa.indicator.wiredscalemanager._findandconnect(wiredscalemanager.java:265)
at com.tswa.indicator.main._reconnect(main.java:616)
at com.tswa.indicator.main$ResumableSub_Activity_Create.resume(main.java:554)
at com.tswa.indicator.main._activity_create(main.java:420)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at com.tswa.indicator.main.afterFirstLayout(main.java:108)
at com.tswa.indicator.main.access$000(main.java:20)
at com.tswa.indicator.main$WaitForLayout.run(main.java:86)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Buffer" on path: DexPathList[[zip file "/data/app/com.tswa.indicator-0NrUkJJ3Zj5ZYOZmCnF52g==/base.apk"],nativeLibraryDirectories=[/data/app/com.tswa.indicator-0NrUkJJ3Zj5ZYOZmCnF52g==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
** Activity (main) Resume **
--------- beginning of crash
java.lang.RuntimeException: java.net.SocketException: Connection reset
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:188)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
at java.io.BufferedInputStream.read(BufferedInputStream.java:267)
at java.io.DataInputStream.readByte(DataInputStream.java:268)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:344)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
... 8 more
Great find @agraham . FTDI is bad about not providing source code for drivers even in Linux and Android.This is ringing a very faint bell. When I wrote the original UsbSerial library I found an extra two bytes at the start of each packet which apparently the chip adds and looking back at the source I see that I just ignored the first two bytes of any packet. At the time I thought this was a bug but I just found this.
It states
"The first 2 bytes of every packet are used as status bytes for the driver. This status is sent every 16 milliseconds, even when no data is present in the device."
Used to be worse! When I was writing UsbSerial the chip datasheets were treated as proprietary and you had to reverse engineer somebody's driver to get an inkling about how to interface to the chip.FTDI is bad about not providing source code for drivers even in Linux and Android
Good question, its a import Kotlin library class loaded in the public class SerialBuffer.I wonder where this "okio.Buffer" class is located
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?