public class PL2303Driver<UsbConfiguration>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PL2303Driver.BaudRate |
static class |
PL2303Driver.DataBits |
static class |
PL2303Driver.FlowControl |
static class |
PL2303Driver.Parity |
static class |
PL2303Driver.StopBits |
Modifier and Type | Field and Description |
---|---|
static int |
BAUD0 |
static int |
BAUD115200 |
static int |
BAUD1200 |
static int |
BAUD12000000 |
static int |
BAUD1228800 |
static int |
BAUD14400 |
static int |
BAUD150 |
static int |
BAUD1800 |
static int |
BAUD19200 |
static int |
BAUD230400 |
static int |
BAUD2400 |
static int |
BAUD2457600 |
static int |
BAUD300 |
static int |
BAUD3000000 |
static int |
BAUD38400 |
static int |
BAUD460800 |
static int |
BAUD4800 |
static int |
BAUD57600 |
static int |
BAUD600 |
static int |
BAUD6000000 |
static int |
BAUD614400 |
static int |
BAUD75 |
static int |
BAUD921600 |
static int |
BAUD9600 |
static int |
PL_MAX_INTERFACE_NUM |
static int |
PL2303HXD_CTS_ON |
static int |
PL2303HXD_DCD_ON |
static int |
PL2303HXD_DSR_ON |
static int |
PL2303HXD_RI_ON |
int |
PLDETACHED_VALUE |
java.lang.String |
PLUART_DETACHED |
java.lang.String |
PLUART_MESSAGE |
static int |
READBUF_SIZE |
static java.lang.Object |
ReadQueueLock |
static UsbDevice |
sDevice |
static int |
WRITEBUF_SIZE |
Constructor and Description |
---|
PL2303Driver(UsbManager manager,
Context mContext,
java.lang.String sAppName)
Initialize a PL2303HXD driver, the software 4K Queue buffer is enable.
|
PL2303Driver(UsbManager manager,
Context mContext,
java.lang.String sAppName,
boolean bWithQueue)
Initialize a PL2303HXD driver
|
Modifier and Type | Method and Description |
---|---|
void |
end()
Close an PL2303HXD USB Device
|
boolean |
enumerate()
Found a PL2303HXD device , the default VID_PID is 067B_2303
|
boolean |
InitByBaudRate(PL2303Driver.BaudRate R)
Open an PL2303HXD USB Device by BaudRate (The stop bit is 1, The parity bit is none, The Flow Control is none), the Timeout Constant of read and write is 100ms
|
boolean |
InitByBaudRate(PL2303Driver.BaudRate R,
int TimeoutConstant)
Open an PL2303HXD USB Device by BaudRate (The stop bit is 1, The parity bit is none, The Flow Control is none)
|
boolean |
InitByDefualtValue()
Open an PL2303HXD USB Device by Default (The baud rate is 9600 bps,The stop bit is 1, The parity bit is none, The Flow Control is none),the Timeout Constant of read and write is 100ms
|
boolean |
InitByPortSetting(PL2303Driver.BaudRate R,
PL2303Driver.DataBits D,
PL2303Driver.StopBits S,
PL2303Driver.Parity P,
PL2303Driver.FlowControl F)
Open an PL2303HXD USB Device by BaudRate, Data bit, stop bit, parity bit and Flow Control
|
boolean |
isConnected()
Get the connection status of this PL2303HXD, ie, whether there is an active connection with PL2303HXD device.
|
boolean |
PL2303Device_GetCommTimeouts(int TimeoutConstant)
The PL2303Device_GetCommTimeouts function retrieves the time-out parameters for all read and write operations on a specified communications device.
|
java.lang.String |
PL2303Device_GetSerialNumber()
Get PL2303HXD serial number
|
boolean |
PL2303Device_IsHasPermission()
Detecting whether this PL2303 devices has permission
|
boolean |
PL2303Device_IsSupportChip()
Detecting whether this PL2303 supports this Android OS, only PL2303HXD / PL2303EA / RL2303RA are supported.
|
boolean |
PL2303Device_SetCommTimeouts(int TimeoutConstant)
The PL2303Device_SetCommTimeouts function sets the time-out parameters for all read and write operations on a specified communications device.
|
int |
PL2303HXD_Enable_GPIO(int GPIO_Num,
boolean Enable)
PL2303HXD has 8 software controllable ¡§General Purpose Input Output¡¨ control signal pin, you can use this API to control the direction of these pin
|
int[] |
PL2303HXD_Get_GPIO_Value(int GPIO_Num)
PL2303HXD has 8 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
|
int[] |
PL2303HXD_GetCommModemStatus()
The PL2303HXD_GetCommModemStatus function retrieves modem control-register values.
|
int |
PL2303HXD_Set_GPIO_Value(int GPIO_Num,
int val)
PL2303HXD has 8 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
|
void |
PL2303LibGetVersion(byte[] byVersion)
get the version of this library
|
int |
PL2303TB_Enable_GPIO(int GPIO_Num,
boolean Enable)
PL2303TB has 12 software controllable ¡§General Purpose Input Output¡¨ control signal pin, you can use this API to control the direction of these pin, you also can use "PL2303HXD Enable GPIO" API to control GPIO 0~7 of PL2303TB
|
int[] |
PL2303TB_Get_GPIO_Value(int GPIO_Num)
PL2303TB has 12 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,, you also can use "PL2303HXD_Get_GPIO_Value" API to control GPIO 0~7 of PL2303TB
|
int |
PL2303TB_Set_GPIO_Value(int GPIO_Num,
int val)
PL2303TB has 12 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, you also can use "PL2303HXD_Set_GPIO_Value" API to control GPIO 0~7 of PL2303TB
|
int |
PL2303TB_Set_PWM(int PWM_IO_Num,
byte Frequency_value,
byte Duty_value)
PL2303TB supports 4 PWM control output, the frequency range is from 366.3Hz to 46.5 KHz, and the pulse high duty can be set from 1/256 to 255/256 in each frequency.
|
boolean |
PL2303USBFeatureSupported()
Detecting whether this Android OS supports USB host API feature
|
int |
read(byte[] buf)
Read Binary Data from PL2303HXD chip
|
int |
setDTR(boolean state)
Switch PL2303HXD DTR on or off
|
int |
setRTS(boolean state)
Switch PL2303HXD RTS on or off
|
int |
setup(PL2303Driver.BaudRate R,
PL2303Driver.DataBits D,
PL2303Driver.StopBits S,
PL2303Driver.Parity P,
PL2303Driver.FlowControl F)
Setup basic communication parameters on PL2303HXD chip
|
int |
write(byte[] buf)
Writes 1byte Binary Data to PL2303HXD chip
|
int |
write(byte[] buf,
int wlength)
Writes n byte Binary Data to PL2303HXD chip
|
public static final int BAUD0
public static final int BAUD75
public static final int BAUD150
public static final int BAUD300
public static final int BAUD600
public static final int BAUD1200
public static final int BAUD1800
public static final int BAUD2400
public static final int BAUD4800
public static final int BAUD9600
public static final int BAUD14400
public static final int BAUD19200
public static final int BAUD38400
public static final int BAUD57600
public static final int BAUD115200
public static final int BAUD230400
public static final int BAUD460800
public static final int BAUD614400
public static final int BAUD921600
public static final int BAUD1228800
public static final int BAUD2457600
public static final int BAUD3000000
public static final int BAUD6000000
public static final int BAUD12000000
public static final int PL2303HXD_DCD_ON
public static final int PL2303HXD_DSR_ON
public static final int PL2303HXD_RI_ON
public static final int PL2303HXD_CTS_ON
public static final int PL_MAX_INTERFACE_NUM
public static final int READBUF_SIZE
public static final int WRITEBUF_SIZE
public static java.lang.Object ReadQueueLock
public final java.lang.String PLUART_MESSAGE
public final java.lang.String PLUART_DETACHED
public final int PLDETACHED_VALUE
public static UsbDevice sDevice
public PL2303Driver(UsbManager manager, Context mContext, java.lang.String sAppName)
manager
- [in] Initialize a PL2303HXD driver.mContext
- [in] Initialize a PL2303HXD 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"public PL2303Driver(UsbManager manager, Context mContext, java.lang.String sAppName, boolean bWithQueue)
manager
- [in] Initialize a PL2303HXD driver.mContext
- [in] Initialize a PL2303HXD 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 disablepublic boolean enumerate()
public boolean InitByDefualtValue()
public boolean InitByBaudRate(PL2303Driver.BaudRate R)
R
- [in] UART baud rate , the baud rate range of PL2303HXD / PL2303EA are 75~12M bps, PL2303RA is 75~1M bps.public boolean InitByBaudRate(PL2303Driver.BaudRate R, int TimeoutConstant)
R
- [in] UART baud rate , the baud rate range of PL2303HXD / PL2303EA are 75~12M bps, PL2303RA is 75~1M bps.TimeoutConstant
- [in] Timeout Constant of read and write, you also can use PL2303Device_SetCommTimeouts to set timeoutpublic boolean InitByPortSetting(PL2303Driver.BaudRate R, PL2303Driver.DataBits D, PL2303Driver.StopBits S, PL2303Driver.Parity P, PL2303Driver.FlowControl F)
R
- [in] UART baud rate , the baud rate range of PL2303HXD / PL2303EA are 75~12M bps, PL2303RA is 75~1M bps.D
- [in] UART Data bit, PL2303HXD supports 5, 6, 7 or 8 data bitsP
- [in] UART Parity bit, PL2303HXD supports Odd, Even, Mark, Space, or None parity modeF
- [in] UART Flow Control mode, PL2303HXD supports None, software or hardware Flow Control modepublic void end()
public boolean isConnected()
public int read(byte[] buf)
buf
- : read bufferpublic int write(byte[] buf)
buf
- : write bufferpublic int write(byte[] buf, int wlength)
buf
- : write bufferwlength
- : write lengthpublic int setup(PL2303Driver.BaudRate R, PL2303Driver.DataBits D, PL2303Driver.StopBits S, PL2303Driver.Parity P, PL2303Driver.FlowControl F) throws java.io.IOException
R
- BaudRateD
- DataBitsS
- StopBitsP
- ParityF
- FlowControljava.io.IOException
- if settings not supported or connection is closedpublic int setDTR(boolean state)
state
- true: SET DTR, false: CLEAR DTRpublic int setRTS(boolean state)
state
- true: SET RTS, false: CLEAR RTSpublic int PL2303TB_Set_PWM(int PWM_IO_Num, byte Frequency_value, byte Duty_value)
PWM_IO_Num
- [in] Pin mapping PWM[0:3] [DTR. DCD, DSR, CTS]Frequency_value
- [in] It would set the Frequency.Duty_value
- [in] It would set the Duty.public int PL2303TB_Enable_GPIO(int GPIO_Num, boolean Enable)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 12Enable
- [in] True is Output mode, false is input mode.public int PL2303HXD_Enable_GPIO(int GPIO_Num, boolean Enable)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 7Enable
- [in] True is Output mode, false is input mode.public int PL2303TB_Set_GPIO_Value(int GPIO_Num, int val)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 11val
- [in] ¡§1¡¨ is High level, 0 is low level.public int PL2303HXD_Set_GPIO_Value(int GPIO_Num, int val)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 7val
- [in] ¡§1¡¨ is High level, 0 is low level.public int[] PL2303TB_Get_GPIO_Value(int GPIO_Num)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 11public int[] PL2303HXD_Get_GPIO_Value(int GPIO_Num)
GPIO_Num
- [in] The GPIO number, the range is 0 ~ 7public int[] PL2303HXD_GetCommModemStatus()
public void PL2303LibGetVersion(byte[] byVersion)
public boolean PL2303USBFeatureSupported()
public java.lang.String PL2303Device_GetSerialNumber()
public boolean PL2303Device_IsHasPermission()
public boolean PL2303Device_IsSupportChip()
public boolean PL2303Device_SetCommTimeouts(int TimeoutConstant)
TimeoutConstant
- : Timeout Constant of read and writepublic boolean PL2303Device_GetCommTimeouts(int TimeoutConstant)
TimeoutConstant
- : Timeout Constant of read and write