ComPort for Android Prolific

Delphi and C++ Builder serial communication library for Prolific devices for Android.
  • uses Prolific PL2303 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


JPL2303Driver_BaudRateClass = interface(JObjectClass)
  function valueOf(Param0: JString): JPL2303Driver_BaudRate;
  function values: TJavaObjectArray<JPL2303Driver_BaudRate>;
  property B0: JPL2303Driver_BaudRate read write;
  property B115200: JPL2303Driver_BaudRate read write;
  property B1200: JPL2303Driver_BaudRate read write;
  property B12000000: JPL2303Driver_BaudRate read write;
  property B1228800: JPL2303Driver_BaudRate read write;
  property B14400: JPL2303Driver_BaudRate read write;
  property B150: JPL2303Driver_BaudRate read write;
  property B1800: JPL2303Driver_BaudRate read write;
  property B19200: JPL2303Driver_BaudRate read write;
  property B230400: JPL2303Driver_BaudRate read write;
  property B2400: JPL2303Driver_BaudRate read write;
  property B2457600: JPL2303Driver_BaudRate read write;
  property B300: JPL2303Driver_BaudRate read write;
  property B3000000: JPL2303Driver_BaudRate read write;
  property B38400: JPL2303Driver_BaudRate read write;
  property B460800: JPL2303Driver_BaudRate read write;
  property B4800: JPL2303Driver_BaudRate read write;
  property B57600: JPL2303Driver_BaudRate read write;
  property B600: JPL2303Driver_BaudRate read write;
  property B6000000: JPL2303Driver_BaudRate read write;
  property B614400: JPL2303Driver_BaudRate read write;
  property B75: JPL2303Driver_BaudRate read write;
  property B921600: JPL2303Driver_BaudRate read write;
  property B9600: JPL2303Driver_BaudRate read write;

JPL2303Driver_DataBitsClass = interface(JObjectClass)
  function valueOf(Param0: JString): JPL2303Driver_DataBits;
  function values: TJavaObjectArray<JPL2303Driver_DataBits>;
  property D5: JPL2303Driver_DataBits read write;
  property D6: JPL2303Driver_DataBits read write;
  property D7: JPL2303Driver_DataBits read write;
  property D8: JPL2303Driver_DataBits read write;

JPL2303Driver_FlowControlClass = interface(JObjectClass)
  function valueOf(Param0: JString): JPL2303Driver_FlowControl;
  function values: TJavaObjectArray<JPL2303Driver_FlowControl>;
  property DTRDSR: JPL2303Driver_FlowControl read write;
  property OFF: JPL2303Driver_FlowControl read write;
  property RFRCTS: JPL2303Driver_FlowControl read write;
  property RTSCTS: JPL2303Driver_FlowControl read write;
  property RTSCTSDTRDSR: JPL2303Driver_FlowControl read write;
  property XONXOFF: JPL2303Driver_FlowControl read write;

JPL2303Driver_ParityClass = interface(JObjectClass)
  function valueOf(Param0: JString): JPL2303Driver_Parity;
  function values: TJavaObjectArray<JPL2303Driver_Parity>;
  property EVEN: JPL2303Driver_Parity read write;
  property NONE: JPL2303Driver_Parity read write;
  property ODD: JPL2303Driver_Parity read write;

JPL2303Driver_StopBitsClass = interface(JObjectClass)
  function valueOf(Param0: JString): JPL2303Driver_StopBits;
  function values: TJavaObjectArray<JPL2303Driver_StopBits>;
  property S1: JPL2303Driver_StopBits read write;
  property S2: JPL2303Driver_StopBits read write;

JPL2303DriverClass = interface(JObjectClass)
  function init(manager: JUsbManager; mContext: JContext; sAppName: JString): JPL2303Driver;
  function init(manager: JUsbManager; mContext: JContext; sAppName: JString; bWithQueue: Boolean): JPL2303Driver;
  property BAUD0: Integer read;
  property BAUD115200: Integer read;
  property BAUD1200: Integer read;
  property BAUD12000000: Integer read;
  property BAUD1228800: Integer read;
  property BAUD14400: Integer read;
  property BAUD150: Integer read;
  property BAUD1800: Integer read;
  property BAUD19200: Integer read;
  property BAUD230400: Integer read;
  property BAUD2400: Integer read;
  property BAUD2457600: Integer read;
  property BAUD300: Integer read;
  property BAUD3000000: Integer read;
  property BAUD38400: Integer read;
  property BAUD460800: Integer read
  property BAUD4800: Integer read
  property BAUD57600: Integer read;
  property BAUD600: Integer read;
  property BAUD6000000: Integer read;
  property BAUD614400: Integer read;
  property BAUD75: Integer read;
  property BAUD921600: Integer read;
  property BAUD9600: Integer read;
  property PL2303HXD_CTS_ON: Integer read;
  property PL2303HXD_DCD_ON: Integer read;
  property PL2303HXD_DSR_ON: Integer read;
  property PL2303HXD_RI_ON: Integer read;
  property PL_MAX_INTERFACE_NUM: Integer read;
  property READBUF_SIZE: Integer read;
  property ReadQueueLock: JObject read write;
  property sDevice: JUsbDevice read write;
  property WRITEBUF_SIZE: Integer read;

JPL2303Driver = interface(JObject)
  procedure &end;
  function enumerate: Boolean;
  function InitByBaudRate(R: JPL2303Driver_BaudRate): Boolean;
  function InitByBaudRate(R: JPL2303Driver_BaudRate; TimeoutConstant: Integer): Boolean;
  function InitByDefualtValue: Boolean;
  function InitByPortSetting(R: JPL2303Driver_BaudRate; D: JPL2303Driver_DataBits; S: JPL2303Driver_StopBits;
      P: JPL2303Driver_Parity; F: JPL2303Driver_FlowControl): Boolean;
  function isConnected: Boolean;
  function PL2303Device_GetCommTimeouts(TimeoutConstant: Integer): Boolean;
  function PL2303Device_GetSerialNumber: JString;
  function PL2303Device_IsHasPermission: Boolean;
  function PL2303Device_IsSupportChip: Boolean;
  function PL2303Device_SetCommTimeouts(TimeoutConstant: Integer): Boolean;
  function PL2303HXD_Enable_GPIO(GPIO_Num: Integer; Enable: Boolean): Integer;
  function PL2303HXD_GetCommModemStatus: TJavaArray<Integer>;
  function PL2303HXD_Get_GPIO_Value(GPIO_Num: Integer): TJavaArray<Integer>;
  function PL2303HXD_Set_GPIO_Value(GPIO_Num: Integer; val: Integer): Integer;
  procedure PL2303LibGetVersion(byVersion: TJavaArray<Byte>);
  function PL2303TB_Enable_GPIO(GPIO_Num: Integer; Enable: Boolean): Integer;
  function PL2303TB_Get_GPIO_Value(GPIO_Num: Integer): TJavaArray<Integer>;
  function PL2303TB_Set_GPIO_Value(GPIO_Num: Integer; val: Integer): Integer;
  function PL2303TB_Set_PWM(PWM_IO_Num: Integer; Frequency_value: Byte; Duty_value: Byte): Integer;
  function PL2303USBFeatureSupported: Boolean;
  function &read(buf: TJavaArray<Byte>): Integer;
  function setDTR(state: Boolean): Integer;
  function setRTS(state: Boolean): Integer;
  function setup(R: JPL2303Driver_BaudRate; D: JPL2303Driver_DataBits; S: JPL2303Driver_StopBits;
     P: JPL2303Driver_Parity; F: JPL2303Driver_FlowControl): Integer;
  function &write(buf: TJavaArray<Byte>): Integer;
  function &write(buf: TJavaArray<Byte>; wlength: Integer): Integer;
  property PLDETACHED_VALUE: Integer read;
  property PLUART_DETACHED: JString read;
  property PLUART_MESSAGE: JString read;

Download and order


What files should be deployed to Android device?
Add these files in Delphi Deployment window:
Local NameRemote Path  Note
pl2303driver.dexassets\internal\  Delphi 10 and higher: add pl2303driver.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