Android Question UsbSerial library 2.0 problem

mrossen

Active Member
Licensed User
Longtime User
Hi

When I set the baudrate to 115200 the "LastException.Message" in "AStreams_Error" gives me a "java.io.IOException: Expected at least 2 bytes".

With ex. a baudrate 57600 the is no error but of course the data is garbage.

Anyone tried the library with a baudrate of 115200.

I use a profilic 2303 usb to serial cable

my code :

B4X:
If usb.UsbPresent(1) = usb.USB_NONE Then
                Log("Msgbox - no device")
                Msgbox("No USB device or accessory detected!", "Error")
                Log("Msgbox - returned")
                Return
            End If
            
            Log("Checking permission")
            
            If (usb.HasPermission(1)) Then
                'Msgbox(usb.DeviceInfo(1), "Device Information")
                Dim dev As Int
                dev = usb.Open(115200, 1)
                If dev <> usb.USB_NONE Then
                    Log("Connected successfully!")
                    AStreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "Astreams")
                Else
                    Log("Error opening USB port")
                End If
            Else
                usb.RequestPermission(1)
            End If

Mogens
 

mrossen

Active Member
Licensed User
Longtime User
Last edited:
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
The problem is that I receive chunks of 15872k byte. I need the receive event raised much faster. When I receive data from Wifi I receive data with 8 to 40 bytes.

If I can set the buffer to ex. 1500 byte that will be fine.

Mogens
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi Erel,

This works perfect. Now I recieve 1426 byte. Is it possible to add this to the library so it can be changed?

Mogens
 
Upvote 0
Top