ComPort for Android FTDI

Delphi and C++ Builder serial communication library for FTDI devices for Android.
  • uses FTDI D2XX library
  • no special root access privileges needed
  • available for Delphi/C++ Builder XE6 - 10.3
  • source code included in registered version
  • royalty free distribution in applications


  TDataBits = (db7, db8);
  TFlag = (flOpened, flHiSpeed);
  TFlags = set of TFlag;
  TFlowControl = (fcNone, fcRtsCts, fcDtrDsr, fcXOnXOff);
  TLineErrorValue = (leOverrun, leParity, leFrame, leBreak);
  TLineError = set of TLineErrorValue;
  TModemStatusValue = (msCts, msDsr, msRing, msDcd);
  TModemStatus = set of TModemStatusValue;
  TParity = (paNone, paOdd, paEven, paMark, paSpace);
  TStopBits = (sb1, sb2);

  ESerialError = class(Exception)

  TSerialDeviceInfo = class
    property Description: string read;
    property DeviceInfo: JD2xxManager_FtDeviceInfoListNode read;
    property DeviceType: string read;
    property Flags: TFlags read;
    property LineStatus: Boolean read;
    property ModemStatus: Boolean read;
    property SerialNumber: string read;
    property &Type: Integer read;

  TSerialDevice = class
    constructor Create;
    destructor Destroy;

    procedure Open(DeviceIndex: Integer);
    procedure Close;
    procedure EnumDevices;
    procedure ResetDevice;

    procedure ClearBreak;
    procedure SetBreak;

    procedure ClearDTR;
    procedure SetDTR;

    procedure ClearRTS;
    procedure SetRTS;

    procedure Purge;
    procedure PurgeInput;
    procedure PurgeOutput;

    function InputCount: Integer;
    function InputFull: Boolean;

    function Read(Buffer: TJavaArray<Byte>; Timeout: Integer = 0): Integer;
    function Read(Buffer: TArray<Byte>; Timeout: Integer = 0): Integer;
    function Read(var Data: Byte; Timeout: Integer = 0): Integer;

    function Write(Buffer: TJavaArray<Byte>; Wait: Boolean = True): Integer;
    function Write(Buffer: TArray<Byte>; Wait: Boolean = True): Integer;
    function Write(Data: Byte; Wait: Boolean = True): Integer;

    property BaudRate: Integer read write;
    property DataBits: TDataBits read write;
    property Device: JFT_Device read;
    property DeviceCount: Integer read;
    property DeviceInfo[Index: Integer]: TSerialDeviceInfo read;
    property ErrorChar: Byte read write;
    property ErrorCharEnabled: Boolean read write;
    property EventChar: Byte read write;
    property EventCharEnabled: Boolean read write;
    property FlowControl: TFlowControl read write;
    property LibraryVersion: Integer read;
    property LineError: TLineError read;
    property Manager: JD2xxManager read;
    property ModemStatus: TModemStatus read;
    property Opened: Boolean read;
    property Parity: TParity read write;
    property StopBits: TStopBits read write;
    property XOff: Byte read write;
    property XOn: Byte read write;

function ToByteArray(JavaArray: TJavaArray<Byte>): TArray<Byte>;
function ToJavaByteArray(ByteArray: TArray<Byte>): TJavaArray<Byte>;

Download and order


What files should be deployed to Android device?
Add these files in Delphi Deployment window:
Local NameRemote Path  Note
d2xx.dexassets\internal\  Delphi 10 and higher: add d2xx.jar to Libraries list in Project Manager instead

Add these lines to AndroidManifest.template.xml file:
  <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />

<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
How can I determine chip used in USB/RS232 adapter?
Use HWiNFO on PC and USB Library for Android demo example on Android.

Related links