Android Question Cypress USB Serial Driver

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hello,

is there an Library wich supports the Cypress USB Chip?
with B4J it was easy to read the USB Device, but i dont get it work with b4a

eoixq3r8.png
 

Blueforcer

Well-Known Member
Licensed User
Longtime User
Thanks!
Opening the Port seems to work.
But after i initialize the AsyncStreams it throw me following error:

Error: (NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.usb.UsbEndpoint.getAddress()' on a null object reference

my code:

B4X:
Sub btn_con_Click
    If usb1.UsbPresent(1) = usb1.USB_NONE Then    ' Ver_2.4
        Log("Msgbox - no device")
        Msgbox("Kein USB Gerät erkannt!", "Fehler")
        Log("Msgbox - returned")
        Return
    End If
    Log("Checking permission 1")
    If (usb1.HasPermission(1)) Then    ' Ver_2.4
        Msgbox(usb1.DeviceInfo(1), "GeräteInfo")    ' Ver_2.4
        usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x547, 0x1004)
        Dim dev As Int
        dev = usb1.Open(9600, 1)
        If dev <> usb1.USB_NONE Then
            Log("Connected successfully! ")

            lbl_status.Text="Vero verbunden"
            astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "AStreams")
            usb1.SetParameters(9600,usb1.DATABITS_8,usb1.STOPBITS_1,usb1.PARITY_NONE)
        Else
            Log("Error opening USB port ")
        End If
    Else
        usb1.RequestPermission(1)  ' Ver_2.4
    End If
End Sub


B4X:
Sub AStreams_Error
    Log("Error: " & LastException)
    astreams1.Close
End Sub
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
"Play" with parameter :
B4X:
 usb1.SetParameters(9600,usb1.DATABITS_8,usb1.STOPBITS_1,usb1.PARITY_NONE)
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
done this already. I use these settings with B4J and it works great.
The original Windows Software also use these Settings (Monitored with a Serial-Sniffer)
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Yes, and in B4J i dont have to customize the device with

B4X:
usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x547, 0x1004)
 
Upvote 0
Top