Android Question read usb rs232 buffer

fgh3966

Active Member
Licensed User
Good evening everybody
I established usb connection with an ftdi component (felusbserial library)
The initialization seems to be going very well, and I send 5 characters string to ftdi chip.
A B4A log confirms that the 5 characters have been sent.
But I find only the first character :(
Is it possible to make a mistake, or error in the B4A code at this level ?
Should the component must be initialized with the vid, pid ?

B4X:
Sub Bbegin_Click
    If usbserial.IsInitialized Then
        Dim s As String = "begin"
        Dim msg() As Byte = s.GetBytes("ascii")
        usbserial.Write(msg)
        
        Log("New data: " & bc.HexFromBytes(msg))
    End If
    
End Sub

Regards.
 

fgh3966

Active Member
Licensed User
Thank you for your reply.
I see the characters transmitted via 4byte registers.
For this example I prepared 4 bytes supposed to receive the data one after the other.
The first data is OK but it replicated on the other registers.
I think the problem does not come from B4A, perhaps should the FTDI components be configured in a special way ?

Regard.
 
Upvote 0

emexes

Expert
Licensed User
But I find only the first character :(

Is that that received first character correct? ie for your example string "begin", is the received character "b"?

What is the receiving device? Can it run a terminal program to confirm what it is receiving on its RS232 port?
 
Upvote 0

fgh3966

Active Member
Licensed User
Thank you for your answers.
I use ft245, the bytes are direct ;)

I would like to use buffer because I think buffer transfer uses less resources than byte by byte transfer and hardware would heat up less.
Also I have to use a high bitrate about 480,000 baud to time precise events. (That's why I asked if generic android devices had precise hardware timers with 1µs resolution)
Otherwise thank you, I will try the good idea to install a terminal.
 
Upvote 0

emexes

Expert
Licensed User
Also I have to use a high bitrate about 480,000 baud to time precise events. (That's why I asked if generic android devices had precise hardware timers with 1µs resolution)

Sounds like you'd be better off using a Arduino(ish) microcontroller or board that has timer inputs you can use, so that you can unlink the event timing from the communication timing.

Using a high baud rate as a proxy timer is a brilliant backup plan... but if there is USB anywhere in the communication chain then the packetizing is probably going to introduce too much jitter, especially if the link is being run at less than 100.0% utilization.

Then again, depends on what these top-secret events are that you're timing.
 
Upvote 0

fgh3966

Active Member
Licensed User
Hello thank you.
Yes the connected usb card will be equipped with precise timers, maybe a pll, a very small bit of memory (ko).
Depending on the choice of this one, the configuration will vary.
FTDI constructor offers a terminal that I installed and the results have improved.
Maybe a similar B4A project would exist ?
Just write a few characters at high speed, nothing more.

Regards
 
Upvote 0

emexes

Expert
Licensed User
FTDI constructor offers a terminal that I installed and the results have improved.
Maybe a similar B4A project would exist ?
There are Android terminal apps too, although I've only used them via Bluetooth serial adapters, but... surely those apps (or similar) would also work with USB serial adapters.
 
Upvote 0
Top