B4A Library felUsbSerial - Alternative Usb Serial library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jan 10, 2016.

Thread Status:
Not open for further replies.
  1. Beja

    Beja Expert Licensed User

    Thanks Erel.. This one.

    UT-885
    UT-885.jpg
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. marcbu

    marcbu Member Licensed User

    I try to get FT312 (as host via AOA) running but I get runtime error

    Code:
    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: Jan 30, 2017
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this in the questions forum.
     
  5. mast4rbug

    mast4rbug Member Licensed 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!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    1 second sounds a bit too much. However there are no delays in the library code. The delay might come from the USB transfer API.
     
  7. mast4rbug

    mast4rbug Member Licensed 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.
     
  8. carycai

    carycai Member Licensed 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.
     

    Attached Files:

    Last edited: May 23, 2017
  9. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  10. Filippo

    Filippo Expert Licensed User

    Hi Erel,

    can this Digispark be implemented in the library?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    It is not clear which type of USB to serial converter is included with this board.
     
  12. Filippo

    Filippo Expert Licensed User

    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.
     

    Attached Files:

  13. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  14. Filippo

    Filippo Expert Licensed User

    Here is my new thread.
     
    f0raster0 likes this.
  15. rtek1000

    rtek1000 Active Member Licensed 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?
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    V1.12 - BUFFER_READ_SIZE / BUFFER_WRITE_SIZE fields. Default value is 16 * 1024. You can change these values before initializing the object to change the internal buffers sizes.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice