public class UsbSerialPortImpl_qcom extends java.lang.Object implements UsbSerialPort_qcom
DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2
Constructor and Description |
---|
UsbSerialPortImpl_qcom(UsbDeviceConnection mConnection) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the port.
|
boolean |
getCD()
Gets the CD (Carrier Detect) bit from the underlying UART.
|
boolean |
getCTS()
Gets the CTS (Clear To Send) bit from the underlying UART.
|
boolean |
getDSR()
Gets the DSR (Data Set Ready) bit from the underlying UART.
|
boolean |
getDTR()
Gets the DTR (Data Terminal Ready) bit from the underlying UART.
|
int |
getPortNumber()
Port number within driver.
|
boolean |
getRI()
Gets the RI (Ring Indicator) bit from the underlying UART.
|
boolean |
getRTS()
Gets the RTS (Request To Send) bit from the underlying UART.
|
java.lang.String |
getSerial()
The serial number of the underlying UsbDeviceConnection, or
null . |
void |
open(UsbDeviceConnection connection)
Opens and initializes the port.
|
boolean |
purgeHwBuffers(boolean flushRX,
boolean flushTX)
Flush non-transmitted output data and / or non-read input data
|
int |
read(byte[] dest,
int timeoutMillis)
Reads as many bytes as possible into the destination buffer.
|
void |
setDTR(boolean value)
Sets the DTR (Data Terminal Ready) bit on the underlying UART, if
supported.
|
boolean |
setParameters() |
void |
setParameters(int baudRate,
int dataBits,
int stopBits,
int parity)
Sets various serial port parameters.
|
void |
setRTS(boolean value)
Sets the RTS (Request To Send) bit on the underlying UART, if
supported.
|
int |
write(byte[] src,
int timeoutMillis)
Writes as many bytes as possible from the source buffer.
|
public UsbSerialPortImpl_qcom(UsbDeviceConnection mConnection)
public int getPortNumber()
UsbSerialPort_qcom
getPortNumber
in interface UsbSerialPort_qcom
public java.lang.String getSerial()
UsbSerialPort_qcom
null
.getSerial
in interface UsbSerialPort_qcom
public void open(UsbDeviceConnection connection) throws java.io.IOException
UsbSerialPort_qcom
open
in interface UsbSerialPort_qcom
connection
- an open device connection, acquired with
UsbManager#openDevice
java.io.IOException
- on error opening or initializing the port.public void close() throws java.io.IOException
UsbSerialPort_qcom
close
in interface UsbSerialPort_qcom
java.io.IOException
- on error closing the port.public int read(byte[] dest, int timeoutMillis) throws java.io.IOException
UsbSerialPort_qcom
read
in interface UsbSerialPort_qcom
dest
- the destination byte buffertimeoutMillis
- the timeout for readingjava.io.IOException
- if an error occurred during readingpublic int write(byte[] src, int timeoutMillis) throws java.io.IOException
UsbSerialPort_qcom
write
in interface UsbSerialPort_qcom
src
- the source byte buffertimeoutMillis
- the timeout for writingjava.io.IOException
- if an error occurred during writingpublic boolean setParameters()
setParameters
in interface UsbSerialPort_qcom
public void setParameters(int baudRate, int dataBits, int stopBits, int parity) throws java.io.IOException
UsbSerialPort_qcom
setParameters
in interface UsbSerialPort_qcom
baudRate
- baud rate as an integer, for example 115200
.dataBits
- one of UsbSerialPort_qcom.DATABITS_5
, UsbSerialPort_qcom.DATABITS_6
,
UsbSerialPort_qcom.DATABITS_7
, or UsbSerialPort_qcom.DATABITS_8
.stopBits
- one of UsbSerialPort_qcom.STOPBITS_1
, UsbSerialPort_qcom.STOPBITS_1_5
, or
UsbSerialPort_qcom.STOPBITS_2
.parity
- one of UsbSerialPort_qcom.PARITY_NONE
, UsbSerialPort_qcom.PARITY_ODD
,
UsbSerialPort_qcom.PARITY_EVEN
, UsbSerialPort_qcom.PARITY_MARK
, or
UsbSerialPort_qcom.PARITY_SPACE
.java.io.IOException
- on error setting the port parameterspublic boolean getCD() throws java.io.IOException
UsbSerialPort_qcom
getCD
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic boolean getCTS() throws java.io.IOException
UsbSerialPort_qcom
getCTS
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic boolean getDSR() throws java.io.IOException
UsbSerialPort_qcom
getDSR
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic boolean getDTR() throws java.io.IOException
UsbSerialPort_qcom
getDTR
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic void setDTR(boolean value) throws java.io.IOException
UsbSerialPort_qcom
setDTR
in interface UsbSerialPort_qcom
value
- the value to setjava.io.IOException
- if an error occurred during writingpublic boolean getRI() throws java.io.IOException
UsbSerialPort_qcom
getRI
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic boolean getRTS() throws java.io.IOException
UsbSerialPort_qcom
getRTS
in interface UsbSerialPort_qcom
false
if not supported.java.io.IOException
- if an error occurred during readingpublic void setRTS(boolean value) throws java.io.IOException
UsbSerialPort_qcom
setRTS
in interface UsbSerialPort_qcom
value
- the value to setjava.io.IOException
- if an error occurred during writingpublic boolean purgeHwBuffers(boolean flushRX, boolean flushTX) throws java.io.IOException
UsbSerialPort_qcom
purgeHwBuffers
in interface UsbSerialPort_qcom
flushRX
- true
to flush non-transmitted output dataflushTX
- true
to flush non-read input datatrue
if the operation was successful, or
false
if the operation is not supported by the driver or devicejava.io.IOException
- if an error occurred during flush