B4A Library felUsbSerial - Alternative Usb Serial library

Status
Not open for further replies.

marcbu

Member
Licensed User
Longtime User
I try to get FT312 (as host via AOA) running but I get runtime error

B4X:
Sub Connect_FT312D
    Dim usbserial As felUsbSerial
    Dim manager As UsbManager ' normally declared in Process_Globals
    Dim UsbAcc() As UsbAccessory
   
    manager.Initialize 'normally in Activity_Create(FirstTime)


    If manager.GetDevices.Length = 0 Then
        Log("No connected usb devices.")  'Does not find any device
    End If

    UsbAcc = manager.GetAccessories
    If UsbAcc(0).Model.EndsWith("FT312D") Then  ' for test only short version without iteration
        Log("Device found " & UsbAcc(0).Model)    ' Does find the device
    End If
    ' .... after manager.HasAccessoryPermission is True
    usbserial.Initialize("FTDI_data",UsbAcc(0),-1) ' is there any typecast possible for parameter 2
    'Error: java.lang.IllegalArgumentException: argument 2 should have type android.hardware.usb.UsbDevice, got anywheresoftware.b4a.objects.usb.UsbManagerWrapper$UsbAccessoryWrapper
End Sub

How is it possible to do a type cast for second parameter for usbserial.Initialize?
 
Last edited:

mast4rbug

Member
Licensed User
Longtime User
Hi. Thanks for this USB Serial implementation, it works really fine. Only one thing, about the real time, I notice some lag before the Data is sent, between 0 second to about 1 second randomly each time I click my button, is it normal? I need the Data to be sent immediately without Delay.
Thanks!
 

mast4rbug

Member
Licensed User
Longtime User
When I use the other lib with USBSERIAL instead of FELUSBSERIAL the communication is real time, but when I connect with usb.Open(9600) in the example, it connect or send data only 1 time on 10 try, it make Java IO error often when I send Data... I don't know why.
 

carycai

Member
Licensed User
Longtime User
please see the attach picture.

I add a timer into the demo code,send string "test" every 1 second.And receive string was splited into two lines:"t" and "est". (ps: I link the serial pin 2 & 3 with wire,so it can write and read by itself.)
Why? Is there anything wrong?
Please help me.
 

Attachments

  • test.png
    49.8 KB · Views: 309
Last edited:
D

Deleted member 103

Guest
I do not know if that can help, here's the output of " StartingIntent.ExtrasToString":

Here are also various Ini files of Windows drivers, maybe it is also helpful.
 

Attachments

  • Digistump Drivers.zip
    5.7 KB · Views: 320

rtek1000

Active Member
Licensed User
Longtime User
Hello,

I am very happy with this library, I am able to transfer a lot of data from an Arduino Nano with FTDI converter at a speed of 230400 bauds!
(Device: Smartphone Motorola Moto G2 and Android 6)

1- How can I detect if the port has already been opened?

I've put a control variable, but I think it would be useful if the library has some means of monitoring.

2- In case of bad contact, or if the user disconnects the USB cable, what would be the best way to detect this?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…