Jmu5667 Well-Known Member Licensed User Longtime User Nov 18, 2020 #1 Hello I get the following error with this function: Code: Copy Error occurred on line: 217 (Main) java.io.IOException: Invalid argument at java.io.FileInputStream.available0(Native Method) at java.io.FileInputStream.available(FileInputStream.java:383) at anywheresoftware.b4a.objects.streams.File$InputStreamWrapper.BytesAvailable(File.java:490) 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:348) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262) at com.ies.ft311d.main._resetport(main.java:603) at com.ies.ft311d.main._btnreset_click(main.java:595) 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:144) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197) at anywheresoftware.b4a.BA.raiseEvent(BA.java:193) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:6669) at android.view.View.performClickInternal(View.java:6638) at android.view.View.access$3100(View.java:789) at android.view.View$PerformClick.run(View.java:26145) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6863) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) And the function is : Code: Copy Sub readPort As Int Dim res As Int Try If UsbAcc(0).InputStream.BytesAvailable > 0 Then res = UsbAcc(0).InputStream.ReadBytes(usbdata,0,usbdata.length) End If Catch Log($"readPort, error, ${LastException.Message}"$) End Try Return res End Sub I can read the input stream and get data, however when I put BytesAvailable in so I am not blocking the main thread I get the above error. The usb device is an FTDI311D GPIO eval board, so this is just a sample app to get this working before it goes in the min production app. I am using USB lib 0.98 Any suggestions ? Regards John. Last edited: Nov 18, 2020
Hello I get the following error with this function: Code: Copy Error occurred on line: 217 (Main) java.io.IOException: Invalid argument at java.io.FileInputStream.available0(Native Method) at java.io.FileInputStream.available(FileInputStream.java:383) at anywheresoftware.b4a.objects.streams.File$InputStreamWrapper.BytesAvailable(File.java:490) 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:348) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262) at com.ies.ft311d.main._resetport(main.java:603) at com.ies.ft311d.main._btnreset_click(main.java:595) 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:144) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197) at anywheresoftware.b4a.BA.raiseEvent(BA.java:193) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:6669) at android.view.View.performClickInternal(View.java:6638) at android.view.View.access$3100(View.java:789) at android.view.View$PerformClick.run(View.java:26145) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6863) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) And the function is : Code: Copy Sub readPort As Int Dim res As Int Try If UsbAcc(0).InputStream.BytesAvailable > 0 Then res = UsbAcc(0).InputStream.ReadBytes(usbdata,0,usbdata.length) End If Catch Log($"readPort, error, ${LastException.Message}"$) End Try Return res End Sub I can read the input stream and get data, however when I put BytesAvailable in so I am not blocking the main thread I get the above error. The usb device is an FTDI311D GPIO eval board, so this is just a sample app to get this working before it goes in the min production app. I am using USB lib 0.98 Any suggestions ? Regards John.
Erel B4X founder Staff member Licensed User Longtime User Nov 19, 2020 #2 Why aren't you using AsyncStreams? Upvote 0
Jmu5667 Well-Known Member Licensed User Longtime User Nov 19, 2020 #3 Erel said: Why aren't you using AsyncStreams? Click to expand... I fixed it yesterday, sorry I did not update the post, and yes I did implement AsyncStreams, works as expected. Upvote 0
Erel said: Why aren't you using AsyncStreams? Click to expand... I fixed it yesterday, sorry I did not update the post, and yes I did implement AsyncStreams, works as expected.