Android Question felUsbSerial and debug mode

adrian_eb

Member
Licensed User
Longtime User
Hi there,

Im working on a Android TV box and arduino connected by USB (USB device number 9025), Im using the felUsbSerial 1.12, I made the program find the correct device, open it and it works perfect, but only in Debug mode, if I switch to Release, I get a java error (using BridgeLogger: true )
I feel the code is OK, and something is working on another way by switching Debug/Release, it is some permission missing? any clue?

Thanks in advance

B4X:
Dim UsbDevices() As UsbDevice
    UsbDevices = manager.GetDevices
    If UsbDevices.Length = 0 Then
        ToastMessageShow("ERROR no hay dispositivos USB conectados", True)
    Else
        For z = 0 To UsbDevices.Length - 1
            Dim UsbDvc As UsbDevice
            UsbDvc = UsbDevices(z)
            Log("USBDeviceNr. " & z & " - UsbPid = " & UsbDvc.ProductId & " Devicename:" & UsbDvc.DeviceName)
            Log("USBDeviceNr. " & z & " - Vendor id = " & UsbDvc.VendorId & " Device ID: " & UsbDvc.DeviceId )
            Log("listado de dispositivos")
            Log("Vendor ID")
            Log(UsbDvc.VendorId)
            If UsbDvc.VendorId == 9025 Then   
                dispositivo = z
                Log( "Este = " & dispositivo)
            End If
        Next
    End If

    If manager.GetDevices.Length = 0 Then
        Log("No connected usb devices.")
        ToastMessageShow("ERROR no hay dispositivos USB conectados", True)
    Else
        Dim device As UsbDevice = manager.GetDevices(dispositivo)
        If manager.HasPermission(device) = False Then
            ToastMessageShow("Please allow connection and click again.", True)
            manager.RequestPermission(device)
        Else
            Log("Conectando " )
            enchufado = True
            usbserial.Initialize("serial", device, -1)
            usbserial.BaudRate = 9600
            usbserial.DataBits = usbserial.DATA_BITS_8
            usbserial.StartReading
            Log("Conectado! ")
            ToastMessageShow("Connection OK", True)           
        End If
    End If

B4X:
java.lang.Exception: Sub serial_dataavailable was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:219)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5422)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 

DonManfred

Expert
Licensed User
Longtime User
java.lang.Exception: Sub serial_dataavailable was not found.
The error seems clear.

Do you HAVE an eventsub with the name serial_dataavailable?
 
Upvote 0

adrian_eb

Member
Licensed User
Longtime User
I suggest to go over the example code from the felusbseriel library again.
And, hopefully, copy the code you did not copy the first time.

Thanks!!! yes, I just copy/paste "all" the code Im using, but forgot to cut/paste the Sub on the example to my code!

B4X:
Private Sub serial_DataAvailable (Buffer() As Byte)

That part was missing! Thanks!

Its working now, but... why on debug mode worked and on release dont? weird
 
Upvote 0
Top