Connecting FTDI device to Android as VCP

757 views Asked by At

I'm trying to connect an FTDI FT2232H to an Android application using the Java class library that FTDI provides, which does not require root access.

Is there a way to use VCP through this package, rather than the old-style native driver route? Or, if not, is there a way to emulate a VCP interface through it (or is it possible at all to roll my own solution?) I'm finding the official docs a bit lacking, as they encourage using the Java lib over the native one, but don't explain whether or not it provides full feature parity.

1

There are 1 answers

0
Andrii Omelchenko On

Yes, you can use VCP through D2XX driver. Take a look at Java D2xx for Android API User Manual (also at C/C++ Software Application Development D2XX Programmer's Guide and FTD2XX Programmer’s Guide Version 2.01 documents), Official Android D2XX Example Source code especially at FT2232HTestFragment.java class from it:

public void SendMessage(View view) {
    // Do something in response to button
    FT_Device ftDev;
    if( uart_configured_0 == false ) {
          Toast.makeText(DeviceFT2232HTestContext, "UART Port 0 not configured yet...", Toast.LENGTH_SHORT).show();
          return;
      }
      ftDev = ft_device_0;

      if(ftDev.isOpen() == false) {
          Log.e(">>@@","SendMessage: ftDev not open!!!!!!  index: 0");
      } else {
          Log.e(">>@@","SendMessage: ftDev open, index: 0");

/*            Log.e(">>@@","port 0 isn:" + ftDev.deviceInfoNode.iSerialNumber
                  + " bcd:" + ftDev.deviceInfoNode.bcdDevice
                  + " id:" + ftDev.deviceInfoNode.id
                  + " loc:" + ftDev.deviceInfoNode.location
                  + " sn:" + ftDev.deviceInfoNode.serialNumber);
*/        
    }

  ftDev.setLatencyTimer((byte) 16);

  // ftDev.Purge(true, true);

  String writeData = writeText_0.getText().toString();
  byte[] OutData = writeData.getBytes();
  int iLen = ftDev.write(OutData, writeData.length());
  Log.e(">>@@", "Port 0 write Len:" + iLen + " s:" + writeData);
  Toast.makeText(DeviceFT2232HTestContext,
          "Port 0 write Len:" + iLen + " s:" + writeData,
          Toast.LENGTH_SHORT).show();
}

and examples like that (by Keisuke SUZUKI).