tw.com.prolific.pl25x3Lib

## Class PL25x3Lib

- java.lang.Object
- - tw.com.prolific.pl25x3Lib.PL25x3Lib

-     public class PL25x3Lib
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PL25x3Lib.DataBits`
    `static class` | `PL25x3Lib.FlowControl`
    `static class` | `PL25x3Lib.Parity`
    `static class` | `PL25x3Lib.StopBits`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BAUD12000000`
    `static int` | `BAUD24000000`
    `static int` | `BAUD2457600`
    `static int` | `BAUD3000000`
    `static int` | `BAUD6000000`
    `static int` | `PL25x3_CTS_ON`
    `static int` | `PL25x3_DCD_ON`
    `static int` | `PL25x3_DSR_ON`
    `static int` | `PL25x3_RI_ON`
    `java.lang.String` | `PLUART_DETACHED`
    `java.lang.String` | `PLUART_MESSAGE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PL25x3Lib(UsbManager manager, Context context, java.lang.String sAppName)` Initialize a PL25x3 driver, the software 4K Queue buffer is enable.
    `PL25x3Lib(UsbManager manager, Context context, java.lang.String sAppName, boolean bWithQueue)` Initialize a PL25x3 driver

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `convertIntToHex(int i)`
    `int` | `PL2303G_GPIO_B_CNT_ENABLE(int index, boolean Enable)` PL25x3 has 8 software controllable ¡§General Purpose Input Output¡¨ control signal pin, you can use this API to Init GPIO_B
    `void` | `PL25x3_Close()` Close an PL25x3 USB Device
    `void` | `PL25x3_CloseDeviceByIndex(int index)` Close an PL-UART USB Device by index
    `int` | `PL25x3_Enumerate()` Found a PL25x3 device number
    `int` | `PL25x3_GetBcdByIndex(int index)`
    `int[]` | `PL25x3_GetCommModemStatus(int index)` The PL25x3_GetCommModemStatus function retrieves modem control-register values.
    `boolean` | `PL25x3_GetCommTimeouts(int TimeoutConstant)` The PL25x3_GetCommTimeouts function retrieves the time-out parameters for all read and write operations on a specified communications device.
    `java.lang.String` | `PL25x3_GetDevicePathByIndex(int index)` Get the Device Path..
    `int` | `PL25x3_GetProlificUSBDeviceCount()` Returns the active device number of PL25x3.
    `java.lang.String` | `PL25x3_GetSdkVersion()`
    `java.lang.String` | `PL25x3_GetSerialByIndex(int index)` Returns the serial number for the device.
    `java.lang.String` | `PL25x3_GetSerialNumber(int index)`
    `int` | `PL25x3_GPIO_ENABLE(int Port_Index, int GPIO_Index, int GPIOmode)` Can use this API to Init GPIO
    `int[]` | `PL25x3_GPIO_Read(int Port_Index, int GPIO_Index)` Can use this API to get the status of these pin when the direction is input mode
    `int` | `PL25x3_GPIO_Write(int Port_Index, int GPIO_Index, int GPIO_Val)` Can use this API to control the status of these pin when the direction is output mode
    `boolean` | `PL25x3_IsDeviceConnectedByIndex(int index)` Get the connection status of this PL25x3, ie, whether there is an active connection with PL25x3 device.
    `boolean` | `PL25x3_IsSupportChip(int index)` Detecting whether this PL25x3 supports this Android OS, only PL2543 / PL2303EA / RL2303RA are supported.
    `boolean` | `PL25x3_OpenDevByBaudRate(int index, int nBaudRate)` Open an PL-UART USB Device by baudrate
    `boolean` | `PL25x3_OpenDevByDefualtSetting(int index)` Open an PL-UART USB Device by default UART setting
    `boolean` | `PL25x3_OpenDevByUARTSetting(int index, int nBaudRate, PL25x3Lib.DataBits dataBits, PL25x3Lib.StopBits stopBits, PL25x3Lib.Parity parity, PL25x3Lib.FlowControl flowControl)` Open an PL-UART USB Device by UART setting
    `int` | `PL25x3_Read(int index, byte[] buf)` Read Binary Data from PL25x3 chip
    `void` | `PL25x3_ReSetStatus()` ReSet Port Status
    `boolean` | `PL25x3_SetCommTimeouts(int TimeoutConstant)` The PL25x3_SetCommTimeouts function sets the time-out parameters for all read and write operations on a specified communications device.
    `int` | `PL25x3_SetDTR(int index, boolean state)` Switch PL25x3 DTR on or off
    `int` | `PL25x3_SetRTS(int index, boolean state)` Switch PL25x3 RTS on or off
    `int` | `PL25x3_SetupCOMPort(int index, int nBaudRate, PL25x3Lib.DataBits dataBits, PL25x3Lib.StopBits stopBits, PL25x3Lib.Parity parity, PL25x3Lib.FlowControl flowControl)` Setup basic communication parameters on PL25x3 chip
    `boolean` | `PL25x3_USBFeatureSupported()` Detecting whether this Android OS supports USB host API feature
    `int` | `PL25x3_Write(int index, byte[] buf)` Writes n bytes Data to PL-UART chipset

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BAUD2457600

          public static final int BAUD2457600

      See Also:
        Constant Field Values

    - #### BAUD3000000

          public static final int BAUD3000000

      See Also:
        Constant Field Values

    - #### BAUD6000000

          public static final int BAUD6000000

      See Also:
        Constant Field Values

    - #### BAUD12000000

          public static final int BAUD12000000

      See Also:
        Constant Field Values

    - #### BAUD24000000

          public static final int BAUD24000000

      See Also:
        Constant Field Values

    - #### PL25x3_DCD_ON

          public static final int PL25x3_DCD_ON

      See Also:
        Constant Field Values

    - #### PL25x3_DSR_ON

          public static final int PL25x3_DSR_ON

      See Also:
        Constant Field Values

    - #### PL25x3_RI_ON

          public static final int PL25x3_RI_ON

      See Also:
        Constant Field Values

    - #### PL25x3_CTS_ON

          public static final int PL25x3_CTS_ON

      See Also:
        Constant Field Values

    - #### PLUART_MESSAGE

          public java.lang.String PLUART_MESSAGE

    - #### PLUART_DETACHED

          public java.lang.String PLUART_DETACHED

  - ### Constructor Detail

    - #### PL25x3Lib

          public PL25x3Lib(UsbManager manager,
                           Context context,
                           java.lang.String sAppName)

      Initialize a PL25x3 driver, the software 4K Queue buffer is enable.
      Parameters:
        `manager` - [in] Initialize a PL25x3 driver.
        `context` - [in] Initialize a PL25x3 driver.
        `sAppName` - [in] , ACTION_USB_PERMISSION string, for example: "tw.com.prolific.pl2303hxdgpio.USB_PERMISSION" "com.prolific.pl2303hxdsimpletest.USB_PERMISSION" "XXX.AAA.CCC.USB_PERMISSION"

    - #### PL25x3Lib

          public PL25x3Lib(UsbManager manager,
                           Context context,
                           java.lang.String sAppName,
                           boolean bWithQueue)

      Initialize a PL25x3 driver
      Parameters:
        `manager` - [in] Initialize a PL25x3 driver.
        `context` - [in] Initialize a PL25x3 driver.
        `sAppName` - [in] ACTION_USB_PERMISSION string, for example: "tw.com.prolific.pl2303hxdgpio.USB_PERMISSION" "com.prolific.pl2303hxdsimpletest.USB_PERMISSION" "XXX.AAA.CCC.USB_PERMISSION"
        `bWithQueue` - , Specifies the software 4K Queue buffer is enable or disable

  - ### Method Detail

    - #### convertIntToHex

          public static final java.lang.String convertIntToHex(int i)

    - #### PL25x3_Close

          public void PL25x3_Close()

      Close an PL25x3 USB Device

    - #### PL25x3_USBFeatureSupported

          public boolean PL25x3_USBFeatureSupported()

      Detecting whether this Android OS supports USB host API feature
      Returns:
        Zero indicates the devices supports the USB HOST API feature. else false.

    - #### PL25x3_ReSetStatus

          public void PL25x3_ReSetStatus()

      ReSet Port Status

    - #### PL25x3_Enumerate

          public int PL25x3_Enumerate()

      Found a PL25x3 device number
      Returns:
        Device count

    - #### PL25x3_GetBcdByIndex

          public int PL25x3_GetBcdByIndex(int index)

    - #### PL25x3_IsDeviceConnectedByIndex

          public boolean PL25x3_IsDeviceConnectedByIndex(int index)

      Get the connection status of this PL25x3, ie, whether there is an active connection with PL25x3 device.
      Parameters:
        `index` - usb-device index
      Returns:
        true if connected false if not connected

    - #### PL25x3_GetDevicePathByIndex

          public java.lang.String PL25x3_GetDevicePathByIndex(int index)

      Get the Device Path..
      Parameters:
        `index` - usb-device index
      Returns:
        String: Device Path

    - #### PL25x3_GetSerialByIndex

          public java.lang.String PL25x3_GetSerialByIndex(int index)

      Returns the serial number for the device. This will return null if the device has not been opened
      Parameters:
        `index` - usb-device index
      Returns:
        String: Device Path

    - #### PL25x3_GetProlificUSBDeviceCount

          public int PL25x3_GetProlificUSBDeviceCount()

      Returns the active device number of PL25x3.
      Returns:
        int : active device number

    - #### PL25x3_Write

          public int PL25x3_Write(int index,
                                  byte[] buf)

      Writes n bytes Data to PL-UART chipset
      Parameters:
        `index` - usb-device index
        `buf` - write buffer
      Returns:
        written length

    - #### PL25x3_Read

          public int PL25x3_Read(int index,
                                 byte[] buf)

      Read Binary Data from PL25x3 chip
      Parameters:
        `index` - usb-device index
        `buf` - read buffer
      Returns:
        buffer length

    - #### PL25x3_OpenDevByDefualtSetting

          public boolean PL25x3_OpenDevByDefualtSetting(int index)

      Open an PL-UART USB Device by default UART setting
      Parameters:
        `index` - usb-device index
      Returns:
        true if the PL25x3 USB Device was successfully opened

    - #### PL25x3_OpenDevByBaudRate

          public boolean PL25x3_OpenDevByBaudRate(int index,
                                                  int nBaudRate)

      Open an PL-UART USB Device by baudrate
      Parameters:
        `index` - usb-device index
        `nBaudRate` - BaudRate
      Returns:
        true if the PL25x3 USB Device was successfully opened

    - #### PL25x3_OpenDevByUARTSetting

          public boolean PL25x3_OpenDevByUARTSetting(int index,
                                                     int nBaudRate,
                                                     PL25x3Lib.DataBits dataBits,
                                                     PL25x3Lib.StopBits stopBits,
                                                     PL25x3Lib.Parity parity,
                                                     PL25x3Lib.FlowControl flowControl)

      Open an PL-UART USB Device by UART setting
      Parameters:
        `index` - usb-device index
        `nBaudRate` - BaudRate
        `dataBits` - DataBits
        `stopBits` - StopBits
        `parity` - Parity
        `flowControl` - FlowControl
      Returns:
        true if the PL25x3 USB Device was successfully opened

    - #### PL25x3_CloseDeviceByIndex

          public void PL25x3_CloseDeviceByIndex(int index)

      Close an PL-UART USB Device by index
      Parameters:
        `index` - usb-device index

    - #### PL25x3_SetupCOMPort

          public int PL25x3_SetupCOMPort(int index,
                                         int nBaudRate,
                                         PL25x3Lib.DataBits dataBits,
                                         PL25x3Lib.StopBits stopBits,
                                         PL25x3Lib.Parity parity,
                                         PL25x3Lib.FlowControl flowControl)
                                  throws java.io.IOException

      Setup basic communication parameters on PL25x3 chip
      Parameters:
        `index` - usb-device index
        `nBaudRate` - BaudRate
        `dataBits` - DataBits
        `stopBits` - StopBits
        `parity` - Parity
        `flowControl` - FlowControl
      Throws:
        `java.io.IOException` - if settings not supported or connection is closed

    - #### PL25x3_IsSupportChip

          public boolean PL25x3_IsSupportChip(int index)

      Detecting whether this PL25x3 supports this Android OS, only PL2543 / PL2303EA / RL2303RA are supported.
      Parameters:
        `index` - usb-device index Returns true indicates this PL2303 chip is supported, else false.

    - #### PL25x3_SetCommTimeouts

          public boolean PL25x3_SetCommTimeouts(int TimeoutConstant)

      The PL25x3_SetCommTimeouts function sets the time-out parameters for all read and write operations on a specified communications device.
      Parameters:
        `TimeoutConstant` - Timeout Constant of read and write
      Returns:
        If the function succeeds, the return value is true. If the function fails, the return value is false.

    - #### PL25x3_GetCommTimeouts

          public boolean PL25x3_GetCommTimeouts(int TimeoutConstant)

      The PL25x3_GetCommTimeouts function retrieves the time-out parameters for all read and write operations on a specified communications device.
      Parameters:
        `TimeoutConstant` - Timeout Constant of read and write
      Returns:
        If the function succeeds, the return value is true. If the function fails, the return value is false.

    - #### PL25x3_GetSerialNumber

          public java.lang.String PL25x3_GetSerialNumber(int index)

    - #### PL25x3_SetDTR

          public int PL25x3_SetDTR(int index,
                                   boolean state)

      Switch PL25x3 DTR on or off
      Parameters:
        `state` - true: SET DTR, false: CLEAR DTR

    - #### PL25x3_SetRTS

          public int PL25x3_SetRTS(int index,
                                   boolean state)

      Switch PL25x3 RTS on or off
      Parameters:
        `state` - true: SET RTS, false: CLEAR RTS

    - #### PL2303G_GPIO_B_CNT_ENABLE

          public int PL2303G_GPIO_B_CNT_ENABLE(int index,
                                               boolean Enable)

      PL25x3 has 8 software controllable ¡§General Purpose Input Output¡¨ control signal pin, you can use this API to Init GPIO_B
      Parameters:
        `index` - [in] usb-device index
        `Enable` - [in] True is Output mode, false is input mode.
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### PL25x3_GetCommModemStatus

          public int[] PL25x3_GetCommModemStatus(int index)

      The PL25x3_GetCommModemStatus function retrieves modem control-register values.
      Returns:
        int[] [0]: Zero indicates success. Nonzero indicates failure. [1]: Return data for ModemStatus (DCD, RI, DSR, DCTS)

    - #### PL25x3_GPIO_ENABLE

          public int PL25x3_GPIO_ENABLE(int Port_Index,
                                        int GPIO_Index,
                                        int GPIOmode)

      Can use this API to Init GPIO
      Parameters:
        `Port_Index` - [in] Port number
        `GPIO_Index` - [in] GPIO number
        `GPIOmode` - mode [in] The range is 0 ~ 2, 2: Output mode, 1: input mode, 0: default mode.
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### PL25x3_GPIO_Write

          public int PL25x3_GPIO_Write(int Port_Index,
                                       int GPIO_Index,
                                       int GPIO_Val)

      Can use this API to control the status of these pin when the direction is output mode
      Parameters:
        `Port_Index` - [in] Port number
        `GPIO_Index` - [in] GPIO number
        `GPIO_Val` - [in] ¡§1¡¨ is High level, 0 is low level , the range is 0 ~ 1
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### PL25x3_GPIO_Read

          public int[] PL25x3_GPIO_Read(int Port_Index,
                                        int GPIO_Index)

      Can use this API to get the status of these pin when the direction is input mode
      Parameters:
        `Port_Index` - [in] The Port number
        `GPIO_Index` - [in] The GPIO number
      Returns:
        int[] [0]: Zero(or positive value) indicates success. Nonzero indicates failure. [1]: Return data for GPIO value.¡§1¡¨ is High level, 0 is low level.

    - #### PL25x3_GetSdkVersion

          public java.lang.String PL25x3_GetSdkVersion()