tw.com.prolific.pl2303ghidsdk

## Class HidToGpio

- java.lang.Object
- - tw.com.prolific.pl2303ghidsdk.HidToGpio

- Direct Known Subclasses:
    HidToI2c, HidToSpi, HidToUart

      public class HidToGpio
      extends java.lang.Object

  PL23B3, PL23C3, PL23D3 HID to GPIO Driver Class. Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 thanks to ....

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HidToGpio()` New a HidToGPIO driver object.
    `HidToGpio(android.content.Context context, java.lang.String strAppName)` New a HidToGPIO driver object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `askPermissionByDeviceIndex(int nDeviceIndex)` Obtain permission to communicate with a device by given device name
    `int` | `askPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)` Obtain permission to communicate with the given device.
    `int` | `closeDevice()` Close the PL23B3, PL23C3, or PL23D3 device.
    `int` | `closeDeviceByDeviceIndex(int nDeviceIndex)`
    `void` | `dumpMsg(java.lang.Object objMsg)` Dump log into sdk.
    `int` | `enumDevices(int nDeviceVid)` Found a PL23B3, PL23C3, or PL23D3 device , the default VID is 067B
    `int` | `enumDevices(int nDeviceVid, int nDevicePid)` Found a PL23B3, PL23C3, or PL23D3 device by given VID and PID
    `java.lang.String` | `getDeviceName(int nDeviceIndex)` Gets device name by given index.
    `int` | `getGpio(int nDeviceIndex, GpioSetting.GpioPin gpioPin, GpioObject gpioObject)` PL23B3, PL23C3, and PL23D3 has some software controllable "General Purpose Input Output" control signal pin, you can use this API to get the status of these pin when the direction is input mode
    `java.lang.String` | `getSdkVersion()` Gets SDK version.
    `java.lang.String` | `getSerialNumber(int nDeviceIndex)` Gets device serial number by given index.
    `android.hardware.usb.UsbDevice` | `getUsbDevice(int nDeviceIndex)` Gets UsbDevice object by given index
    `boolean` | `hasPermissionByDeviceIndex(int nDeviceIndex)` Detecting whether this device which decided by given index has permission
    `boolean` | `hasPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)` check if device has permission or not.
    `int` | `openDeviceByIndex(int nDeviceIndex)` Open device by given index.
    `int` | `openDeviceBySerialNumber(java.lang.String strSerialNumber)` Open device by given serial number.
    `void` | `setCommandTimeOut(int nMillSecond)` Sets device command time out value.
    `int` | `setGpio(int nDeviceIndex, GpioSetting.GpioPin gpioPin, GpioObject gpioObject)` PL23B3, PL23C3, and PL23D3 have some software controllable "General Purpose Input Output" control signal pin, you can use this API to control the status of these pin when the direction is output mode
    `int` | `setGpioDir(int nDeviceIndex, GpioSetting.GpioPin gpioPin, GpioSetting.GpioDir gpioDir)` PL23B3, PL23C3, and PL23D3 have some software controllable "General Purpose Input Output" control signal pin, you can use this API to control the direction of these pin

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

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

- - ### Constructor Detail

    - #### HidToGpio

          public HidToGpio()

      New a HidToGPIO driver object.

    - #### HidToGpio

          public HidToGpio(android.content.Context context,
                           java.lang.String strAppName)

      New a HidToGPIO driver object.
      Parameters:
        `context` - the context
        `strAppName` - , ACTION_USB_PERMISSION string, for example: "tw.com.prolific.HidToUartTest.USB_PERMISSION"

  - ### Method Detail

    - #### setGpioDir

          public int setGpioDir(int nDeviceIndex,
                                GpioSetting.GpioPin gpioPin,
                                GpioSetting.GpioDir gpioDir)

      PL23B3, PL23C3, and PL23D3 have some software controllable "General Purpose Input Output" control signal pin, you can use this API to control the direction of these pin
      Parameters:
        `nDeviceIndex` - the device index
        `gpioPin` - the gpio pin
        `gpioDir` - the gpio direction to setup
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### setGpio

          public int setGpio(int nDeviceIndex,
                             GpioSetting.GpioPin gpioPin,
                             GpioObject gpioObject)

      PL23B3, PL23C3, and PL23D3 have some software controllable "General Purpose Input Output" control signal pin, you can use this API to control the status of these pin when the direction is output mode
      Parameters:
        `nDeviceIndex` - the device index
        `gpioPin` - the gpio pin
        `gpioObject` - the gpio object to set value
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### getGpio

          public int getGpio(int nDeviceIndex,
                             GpioSetting.GpioPin gpioPin,
                             GpioObject gpioObject)

      PL23B3, PL23C3, and PL23D3 has some software controllable "General Purpose Input Output" control signal pin, you can use this API to get the status of these pin when the direction is input mode
      Parameters:
        `nDeviceIndex` - the device index
        `gpioPin` - the gpio pin
        `gpioObject` - the gpio object to get value
      Returns:
        Zero indicates the devices supports the USB HOST API feature. else false.

    - #### enumDevices

          public int enumDevices(int nDeviceVid)

      Found a PL23B3, PL23C3, or PL23D3 device , the default VID is 067B
      Parameters:
        `nDeviceVid` - the device vid
      Returns:
        Number of device

    - #### enumDevices

          public int enumDevices(int nDeviceVid,
                                 int nDevicePid)

      Found a PL23B3, PL23C3, or PL23D3 device by given VID and PID
      Parameters:
        `nDeviceVid` - the device vid
        `nDevicePid` - the device pid
      Returns:
        Number of device

    - #### getDeviceName

          public java.lang.String getDeviceName(int nDeviceIndex)

      Gets device name by given index.
      Parameters:
        `nDeviceIndex` - The index of device
      Returns:
        Device name, empty string indicates device not found.

    - #### getSerialNumber

          public java.lang.String getSerialNumber(int nDeviceIndex)

      Gets device serial number by given index. This function support Android version 5.0 or later,
      Parameters:
        `nDeviceIndex` - the index of device
      Returns:
        Device serial number, empty string indicates device not found.

    - #### openDeviceByIndex

          public int openDeviceByIndex(int nDeviceIndex)

      Open device by given index.
      Parameters:
        `nDeviceIndex` - the index of device
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### openDeviceBySerialNumber

          public int openDeviceBySerialNumber(java.lang.String strSerialNumber)

      Open device by given serial number.
      Parameters:
        `strSerialNumber` - the serial number of device
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### hasPermissionByDeviceIndex

          public boolean hasPermissionByDeviceIndex(int nDeviceIndex)

      Detecting whether this device which decided by given index has permission
      Parameters:
        `nDeviceIndex` - the index of device
      Returns:
        true indicates the device has permission to access usb device, else false.

    - #### askPermissionByDeviceIndex

          public int askPermissionByDeviceIndex(int nDeviceIndex)

      Obtain permission to communicate with a device by given device name
      Parameters:
        `nDeviceIndex` - the index of device
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### hasPermissionByUsbDevice

          public boolean hasPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)

      check if device has permission or not.
      Parameters:
        `usbDevice` - the usb device
      Returns:
        true indicates the given device has permission to access usb device, else false.

    - #### askPermissionByUsbDevice

          public int askPermissionByUsbDevice(android.hardware.usb.UsbDevice usbDevice)

      Obtain permission to communicate with the given device.
      Parameters:
        `usbDevice` - the usb device
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### closeDevice

          public int closeDevice()

      Close the PL23B3, PL23C3, or PL23D3 device.
      Returns:
        Zero indicates success. Nonzero indicates failure.

    - #### closeDeviceByDeviceIndex

          public int closeDeviceByDeviceIndex(int nDeviceIndex)

    - #### getSdkVersion

          public java.lang.String getSdkVersion()

      Gets SDK version.
      Returns:
        the current SDK version

    - #### setCommandTimeOut

          public void setCommandTimeOut(int nMillSecond)

      Sets device command time out value.
      Parameters:
        `nMillSecond` - the time value in millisecond.

    - #### dumpMsg

          public void dumpMsg(java.lang.Object objMsg)

      Dump log into sdk.
      Parameters:
        `objMsg` - The message content.

    - #### getUsbDevice

          public android.hardware.usb.UsbDevice getUsbDevice(int nDeviceIndex)

      Gets UsbDevice object by given index
      Parameters:
        `nDeviceIndex` - the index of device
      Returns:
        the usbDevice object, null indicates device not found.