Android Question UMFT311EV (FTDI Chip)

Fabian Alberto Moriconi

Member
Licensed User
Longtime User
Android device: Sony Xperia Tipo ST21a
Platform: Android 4.0.4
Interface (Android <=> UART): UMFT311EV de FTDI Chip
USB Library: USB Serial 2.30
Protocol: 9600, 8, N, 2

I need to control an "electronic device" with RS232 communication using smartphone. The "electronic device" is successfully communicating with a PC using an RS232 serial port.

Question 1:

The Android phone transmitting properly to the "electronic device", but the string that receives the phone arrives incorrect response, apparently some bits are lost, only the first character arrives correctly.
The "electronic device" transmits one character after another without delays between characters.

If between each character transmitted from the "electronic device" expect about 2 ms before transmitting the next, the string comes right to your phone.

Someone can suggest me a solution to avoid adding delays in the response from the "electronic device"?

Question 2:

Every time I connect the phone to the UMFT311EV board a message indicates that there is no application that works with this accessory usb (Vinculum Accessory Test). I can avoid this message board and only associate with my application? Someone can suggest me a solution?

Part Code:

--------------------------------------------------------------------------------------------------

Sub Process_Globals

DimusbAsUsbSerial
DimastreamsAsAsyncStreams

End Sub

--------------------------------------------------------------------------------------------------

Sub OpenPort

If (usb.HasPermission) Then
dev = usb.Open(9600)
If dev <> usb.USB_NONE Then
' Se pudo conectar
astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams")
'usb.SetParameters(9600, 8, 2, 0)
‘usb.UsbTimeout = 2000
Else
Log("Error opening USB port")
ChkUsb.Checked = False
EndIf
Else
usb.RequestPermission
EndIf

End Sub

-------------------------------------------------------------------------------------------------

Sub Astreams_NewData (Buffer() AsByte)

Dim EnteroHex AsString
Dim bb(1) AsByte

For i = 0To Buffer.Length - 1
bb(0) = Buffer(i)
EnteroHex = BC.HexFromBytes(bb)

If (EnteroHex.Length < 2) Then EnteroHex = "0" & EnteroHex
StrRta = StrRta & " " & EnteroHex
Next

LblTitulo.Text = StrRta

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Fabian Alberto Moriconi

Member
Licensed User
Longtime User
Dear Erel,
Thank you very much for responding!

-------------------------------------------------------------------------------------------------
I could solve the Question 2:
Add to Manifest Editor:

AddActivityText(Main,
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />)

And add: "accessory_filter.xml" in to ..\Objects\res\xml directory

-------------------------------------------------------------------------------------------------

I could not solve Question 1, the receive data is not correct without the delays discussed.

-------------------------------------------------------------------------------------------------

Question 3:

Established communication using the USB accessory FT311D, if the application is closed, when running again no communication is established again, even adding "usb.Close", "astreams.Close" and "ExitApplication" to close the application.
There will be an example of using the device for B4A FT311D?

Thank !
 

Attachments

  • accessory_filter.zip
    311 bytes · Views: 316
  • accessory_filter.zip
    311 bytes · Views: 357
Upvote 0

Fabian Alberto Moriconi

Member
Licensed User
Longtime User
Dear Erel,

Could you suggest me the usb-rs232 converter tested with the libraries available and works without problems?

Moreover, I am evaluating the use of a tablet pc with rs232 genuine serial port (not USB-RS232). It could be supported by libraries B4A without problems?

Thank, best regards
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the library documentation page: http://www.b4x.com/android/help/usbserial.html

It could be supported by libraries B4A without problems?
It depends on the implementation. Does the manufacturer provide any special library for this port?

In many cases the serial port is mapped to a virtual file (under tty0 folder). In these cases you can work with the serial port with the standard file methods.
 
Upvote 0

Fabian Alberto Moriconi

Member
Licensed User
Longtime User
I am awaiting a response from the tablet provider to see if use a special library for genuine RS232 serial port or accessed as a file.

I connected a USB-RS232 converter FT232RL model, powered with external 5V (Xperia does not provide power), the phone starts charging the battery but can not find the FT232RL device. Is it necessary to install a driver?

I also tried with other MCP2200 (Microchip) and Prolific PL-2303HX (FTDI Chip) converters and neither worked.

I'm stuck here, for my project is essential to control the serial port with certainty.

Thank and best regards
 
Upvote 0
Top