Android Question Touch screen disables when useing usb_serial_2.4

Hi
sorry for poor English
I installed android on ASUS Tinker board S with 4 usb ports.
I have connected HDMI LCD with USB touch.
In my application I have to send and recive data via USB serial in service but but i got this error and my touch disables :(
In my code i read all usb ports and check that is FTDI or not (I use FT232) but gives error when getting device information.
B4X:
    Dim num As Int
    For num=1 To 4
    If( usb.UsbPresent(num) = usb.USB_DEVICE )Then
            Log( "usb number" &num &" is present" )
            If (usb.HasPermission(num) = False) Then
                Log(" request" )
                usb.RequestPermission(num)  ' Ver_2.4
            End If
            'usb.SetCustomDevice(usb.DRIVER_FTDI, 1027, 24577)
            If ( usb.DeviceInfo(num).Contains("FTD") )Then 'Checks that the recognizeddevice is FTDI ?!
                Log( "usb number" &num &"is FTDI" )
            dev = usb.Open( 9600, num )        ' Ver_2.4
                If dev <> usb.USB_NONE Then
                    Log("Connected successfully! " &num)
                    astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams")
                Else
                Log("Error opening USB port "&num)
                usb.Close
            End If
            Return
        Else
            usb.Close
        End If
    End If
    Next

errors:
B4X:
starter_usbserial_recognize (java line: 851)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
    at anywheresoftware.b4a.objects.UsbSerial.DeviceInfo(UsbSerial.java:428)
    at b4a.example.starter._usbserial_recognize(starter.java:851)
    at b4a.example.starter._service_create(starter.java:672)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at b4a.example.starter.onCreate(starter.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
    at android.app.ActivityThread.-wrap4(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:772)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
java.lang.RuntimeException: Unable to create service b4a.example.starter: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2887)
    at android.app.ActivityThread.-wrap4(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:772)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:250)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at b4a.example.starter.onCreate(starter.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
    ... 8 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.usb.UsbDeviceConnection.claimInterface(android.hardware.usb.UsbInterface, boolean)' on a null object reference
    at anywheresoftware.b4a.objects.UsbSerial.DeviceInfo(UsbSerial.java:428)
    at b4a.example.starter._usbserial_recognize(starter.java:851)
    at b4a.example.starter._service_create(starter.java:672)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    ... 11 more
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top