Android Question ftdi chip - rts

mterveen

Member
Licensed User
Longtime User
i desperately need to use the ftdi rts signal in my application. however, the usbserial library appears not to support the enabling/disabling of the rts signal for the ftdi chip. has anybody wrapped the native ftdi java driver for use with b4a? it appears the ftdi android driver does support it. or is there another way (reflection?) to toggle the rts signal in the usbserial library? unfortunately, i am not versed on wrapping java libraries or i would do it, unless someone can point to a step by step tutorial on incorporating/wrapping other existing java libraries.
 

Wintermoon

New Member
I am considering buying B4A, but I have been waiting for support of basic serial support. What not now is offered is to early, you are not ready yet. I am waiting for FTDI D2XX driver with break detection and break generation and control of the RTS and DTS pins. FTDI have a full open source app for this compiled into an APK. With RTS and DTS pin control. Somewhere in a thread it was said by someone at B4A that you just need to wrap it!!! In what? Christmas wrapping? I thought this was BASIC??!! Have no clue what wrapping is?? Can of course Google it, but why you say wrap it and have no explanatiin of it? Seriousy, according to the forum many wants this, RTS and DTS control on the FTDI chip. And control of the FT 2232 and the FT4232 chips, 4 serial ports over USB.
The software for this is supplied by FTDI in Java, can't you cloued up guys convert this into some kind of B4A library? If not, it makes me worried to invest in an unknown learning curve for this software.
One guy, very impressive guy, just managed to get more serial ports open than just the first one found. Amazingly well done.
Why have one! One library covering all USB chips on earth, why not split them up and have one library for example the FTDI chips, or even one library for each chip. Does that not make more sense?
Like having a library for all CPU's in the world..obviously it is impossible.
If this can be done, I mean doing what the FTDI sample software in java with their Android drivers can be done in the same way, lets say a copy of the FTDI sample but in B4A code. Can you show that you can do that?
Serial communication is of major importance and I am surprised so little focus has been paid on this.

As I mentioned, when the FTDI driver is fully supported in B4A, I will buy it. Others will be very happy too, I'm sure if it.

I have other qustions too, but this is the decision if I am going to buy B4A or not.

My very best regards,
Jack Wintermoon
 
Upvote 0

robotop

Member
Licensed User
Longtime User
I remember that the FTDI chips can be programmed for different behaviour of the RTS. There is a free tool, working under Windows, that you can use to modify the chip behaviour. If you need the RTS signal to drive an RS485 (half duplex) connection, the FTDI has a mode for automatize the data flow simply writing to the serial port. The RTS is asserted one bit before and released one bit after the data stream, without any software intervention.
 
Last edited:
Upvote 0

Wintermoon

New Member
Hi Erel,
Thanks for quick reply. Erel must be a common name in your country... :) or you are extremely good at multitasking....

The FTDI Android driver is not open source, but the USB Terminal application using the driver is and is available at Google Play. The source code in Java for the terminal application example is available for download at their website.

http://www.ftdichip.com/Android.htm

They had an old Beta driver in 2011, a new driver for non rooted devices is available at:

http://www.ftdichip.com/Drivers/D2XX.htm

LIN for cars need break generation and break detection. The RTS and DTS pins are needed to control the LIN chip.

Practically all never cars in the world are usin LIN for many controls, and not only in cars. A massive application market.

Hi Robotop,
I know about the configuration via for example MPROG to configure the FTDI, chip, what you say is perfect for RS485 comms. But not for 1 wire comm or other apps where break is needed and when full control of the spare pins are needed.

Can B4A have support to fully support the FTDI chips or some of them, as they have become an industry standard now? One library per chip?

Best regards,
Wintermoon
 
Upvote 0

robotop

Member
Licensed User
Longtime User
I think that the driver needed to indepently use (not in standard serial protocol) the I/O lines is the D2XX, that's able to modify I/O in bit-banging mode. About the single line serials, a couple of transistors can be used for creating one (half duplex) using the same configuration as for RS485. Some "dirty" and not professional trick may be used to detect a break (framing-error condition) and for sending a break (slow down the baud rate to 300bps, then transmit a zero byte), but this is just for brain-storming. I think that, if it's impossible to have a full D2XX + VCP driver, the best solution is to add a 2$ microcontroller to the ftdi (or prolific, or siliconlabs, or microchip) chip and create some internal (serial) command to activate / deactivate / read status of selected I/O. I did it creating a MIDI OUT interface and some home automation devices for my old chinese tablets.
 
Upvote 0

Wintermoon

New Member
Neat trick to generate a break!
For new designs it would be easy to add a small MCU. But there are so many devices already out there using the FTDI chips, it would be very lucrative if we could connect to them.
 
Upvote 0

Wintermoon

New Member
According to Google they have made it possible to use the USB port on Android 2.3.4 by a backported add-on API. Anyone who know how to set this up to do it on B4A?

http://developer.android.com/guide/topics/connectivity/usb/accessory.html

Although the USB accessory APIs were introduced to the platform in Android 3.1, they are also available in Android 2.3.4 using the Google APIs add-on library. Because these APIs were backported using an external library, there are two packages that you can import to support USB accessory mode. Depending on what Android-powered devices you want to support, you might have to use one over the other:

com.android.future.usb: To support USB accessory mode in Android 2.3.4, the Google APIs add-on library includes the backported USB accessory APIs and they are contained in this namespace. Android 3.1 also supports importing and calling the classes within this namespace to support applications written with the add-on library. This add-on library is a thin wrapper around the android.hardware.usb accessory APIs and does not support USB host mode. If you want to support the widest range of devices that support USB accessory mode, use the add-on library and import this package. It is important to note that not all Android 2.3.4 devices are required to support the USB accessory feature. Each individual device manufacturer decides whether or not to support this capability, which is why you must declare it in your manifest file.
android.hardware.usb: This namespace contains the classes that support USB accessory mode in Android 3.1. This package is included as part of the framework APIs, so Android 3.1 supports USB accessory mode without the use of an add-on library. Use this package if you only care about Android 3.1 or newer devices that have hardware support for USB accessory mode, which you can declare in your manifest file.
Installing the Google APIs add-on library

If you want to install the add-on, you can do so by installing the Google APIs Android API 10 package with the SDK Manager. See Installing the Google APIs Add-on for more information on installing the add-on library.
More on the site....
 
Upvote 0
Top