Java Question USBSERIAL2 2.4 Error when opening AsynchStream

Ganiadi

Active Member
Licensed User
Longtime User
Dear All,

I tried to read a QR Code reader device into my Orange Pi device and use the USBSERIAL2 V 2.4.
It successfully Open, but there is an error like below log,

Program i used :
B4X:
Sub btnOpen_Click
    If usb1.UsbPresent(1) = usb1.USB_NONE Then    ' Ver_2.4
        Log("Msgbox - no device")
        Msgbox("No USB device or accessory detected!", "Error")
        Log("Msgbox - returned")
        Return
    End If
    Log("Checking permission 1")
    If (usb1.HasPermission(1)) Then    ' Ver_2.4
        Msgbox(usb1.DeviceInfo(1), "Device Information 1")    ' Ver_2.4
        Dim dev As Int
        Log(usb1.UsbPresent(1))
        Log(usb1.DRIVER_SILABS)
        usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x1A86,0xE026)
        
        dev = usb1.Open(9600, 1)        ' Ver_2.4
        
        Log(dev)
        
        If dev <> usb1.USB_NONE Then
            Log("Connected successfully! 1")
            btnOpen.Enabled = False
            btnClose.Enabled = True
            btnSend.Enabled = True           
            
            astreams1.Initialize( usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
        Else
            Log("Error opening USB port 1")
        End If
    Else
        usb1.RequestPermission(1)  ' Ver_2.4
    End If
End Sub

And Below is the error log :

Logger connected to: Allwinner molly
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Checking permission 1
1
2
Connected successfully! 1
Error: (NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbEndpoint.getAddress()' on a null object reference

Please help

Tks
 

Ganiadi

Active Member
Licensed User
Longtime User
Code with Msgbox = broken code.

The error is not coming from AsyncStreams. First step is to run in debug mode and fine the correct line.
Hi Erel,

Tks for your reply, i just tried to remove the msgbox, but the error still remain the same...
Hmm...


Tks
 
Top