|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MxUPort
The MxUPort class includes all Host mode APIs for UPort devices. An MxUPort object is an abstraction of a UPort serial port. Although some MxUPorts are distributed from one USB port, the user can process each MxUPort, even without any knowledge of USB programming.
The MxUPort is created by MxUPortService.getDevieInfoList
.
Users should not create an MxUPort by themselves due to lack of internal initialization.
The MxUPort offers these categories for serial communication.
Port control |
open |
close |
setIoctlMode |
setFlowCtrl |
setBaud |
setRTS |
setDTR |
flush |
Input/Output |
read |
write |
Port status inquiry |
getBaud |
getFlowCtrl |
getIoctlMode |
getLineStatus |
getModemStatus |
getOQueue |
Miscellaneous |
setBreak |
getInterface |
setInterface |
getPortName |
setPortName |
getUsbDevice |
getUsbDeviceName |
getUsbReadTimeout |
setUsbReadTimeout |
getUsbWriteTimeout |
setUsbWriteTimeout |
hasUsbPermission |
Nested Class Summary | |
---|---|
static class |
MxUPort.FlowCtrl
This class represents serial flow control settings. |
static class |
MxUPort.IoctlMode
This class represents serial parameters such as baud rate, data bits, parity, and stop bits. |
static class |
MxUPort.LineError
This class represents errors on line. |
static class |
MxUPort.ModemStatus
This class represents modem status, such as CTS, DSR, DCD, and RI. |
Field Summary | |
---|---|
static int |
CTS_FLOW_ENABLE
Defines CTS hardware flow control |
static int |
CTS_OFF
Defines CTS state OFF |
static int |
CTS_ON
Defines CTS state ON |
static int |
DATA_BITS_5
Defines serial communication with 5 data bits |
static int |
DATA_BITS_6
Defines serial communication with 6 data bits |
static int |
DATA_BITS_7
Defines serial communication with 7 data bits |
static int |
DATA_BITS_8
Defines serial communication with 8 data bits |
static int |
DCD_OFF
Defines DCD state OFF |
static int |
DCD_ON
Defines DCD state ON |
static int |
DSR_FLOW_ENABLE
Defines DSR hardware flow control |
static int |
DSR_OFF
Defines DSR state OFF |
static int |
DSR_ON
Defines DSR state ON |
static int |
DTR_FLOW_ENABLE
Defines DTR hardware flow control |
static int |
DTR_OFF
Defines DTS state OFF |
static int |
DTR_ON
Defines DTS state ON |
static int |
DTRDSR_FLOW_ENABLE
Defines DTR/DSR software flow control |
static int |
DTRDSR_FLOW_MASK
Defines the bit mask of DTR/DSR hardware flow control |
static int |
FLUSH_INPUT
Defines the flush to read buffer |
static int |
FLUSH_OUTPUT
Defines the flush to write buffer |
static int |
LINE_ERROR
Defines the error state for each field |
static int |
LINE_NO_ERROR
Defines the non-error state for each field |
static int |
MODE_RS232
Defines the RS232 interface |
static int |
MODE_RS422
Defines the RS422 interface |
static int |
MODE_RS485_2W
Defines the 2-wire RS485 interface |
static int |
MODE_RS485_4W
Defines the 4-wire RS485 interface |
static int |
PARITY_EVEN
Defines even parity checking |
static int |
PARITY_MARK
Defines mark parity checking |
static int |
PARITY_NONE
Defines no parity checking |
static int |
PARITY_ODD
Defines odd parity checking |
static int |
PARITY_SPACE
Defines space parity checking |
static int |
RI_OFF
Defines RI state OFF |
static int |
RI_ON
Defines RI state ON |
static int |
RTS_FLOW_ENABLE
Defines RTS hardware flow control |
static int |
RTS_OFF
Defines RTS state OFF |
static int |
RTS_ON
Defines RTS state ON |
static int |
RTSCTS_FLOW_ENABLE
Defines RTS/CTS hardware flow control |
static int |
RTSCTS_FLOW_MASK
Defines bit mask of RTS/CTS hardware flow control |
static int |
STOP_BITS_1
Defines 1 stop bit on serial communication |
static int |
STOP_BITS_1_5
Defines 1.5 stop bits on serial communication |
static int |
STOP_BITS_2
Defines 2 stop bits on serial communication |
static int |
XOFF_FLOW_ENABLE
Defines software auto receive flow control |
static int |
XON_FLOW_ENABLE
Defines software auto transmit flow control |
static int |
XONXOFF_FLOW_ENABLE
Defines XON/XOFF software flow control |
static int |
XONXOFF_FLOW_MASK
Defines the bit mask of RTS/CTS hardware flow control |
Method Summary | |
---|---|
void |
close()
Closes the serial port. |
void |
flush(int mode)
Flushes any data in the driver's input/output buffer. |
int |
getBaud()
Get the serial port baud rate setting. |
MxUPort.FlowCtrl |
getFlowCtrl()
Get the serial port's hardware and software flow control settings. |
int |
getInterface()
Gets the interface for products that support multiple interface. |
MxUPort.IoctlMode |
getIoctlMode()
Gets the serial port's mode settings, such as data bits, parity, and stop bits. |
MxUPort.LineError |
getLineStatus()
Checks if errors occurred when receiving data; returns and cleans the error during the transaction. |
MxUPort.ModemStatus |
getModemStatus()
Gets the line status, such as CTS, DSR, DCD, or RI. |
int |
getOQueue()
Gets the length (in bytes) remaining in the output buffer. |
java.lang.String |
getPortName()
Gets the name of the serial port; returns customized friendly name if it is available. |
android.hardware.usb.UsbDevice |
getUsbDevice()
Gets the parent USB device handle of this MxUPort. |
java.lang.String |
getUsbDeviceName()
Gets the device name from the USB descriptor. |
int |
getUsbReadTimeout()
Gets the read timeout value for a USB read request. |
int |
getUsbWriteTimeout()
Gets the write timeout value for a USB write request. |
boolean |
hasUsbPermission()
Indicates whether the parent USB has permission to be accessed. |
void |
open()
Opens the serial port. |
int |
read(byte[] buffer)
Reads data from the port; returns the data if the buffer is full. |
int |
read(byte[] buffer,
int length)
Reads data from a port; returns the data if the given length of data has been received. |
int |
read(byte[] buffer,
int length,
int timeout)
Reads data from the port; returns the data if the given length of data has been received. |
void |
setBaud(int speed)
Sets the baud rate using the actual speed value. |
void |
setBreak(int time)
Sends out a break signal. |
void |
setDTR(int mode)
Sets the DTR state for a serial port. |
void |
setFlowCtrl(MxUPort.FlowCtrl flow)
Sets the hardware and/or software flow control. |
void |
setInterface(int intf)
Sets the interface for products that support multiple interface. |
void |
setIoctlMode(MxUPort.IoctlMode mode)
Configures communication parameters, such as baud rate, parity, data bits and stop bits. |
void |
setPortName(java.lang.String name)
Sets the port name on the device. |
void |
setRTS(int mode)
Sets the RTS state for a serial port. |
void |
setUsbReadTimeout(int time)
Sets the read timeout value for a USB read request. |
void |
setUsbWriteTimeout(int time)
Sets the write timeout value for a USB write request. |
int |
write(byte[] buffer)
Puts a block of data to the driver's output buffer. |
int |
write(byte[] buffer,
int length)
Puts a block of data to the driver's output buffer. |
int |
write(byte[] buffer,
int length,
int timeout)
Puts a block of data to the driver's output buffer. |
Field Detail |
---|
static final int CTS_FLOW_ENABLE
static final int CTS_OFF
static final int CTS_ON
static final int DATA_BITS_5
static final int DATA_BITS_6
static final int DATA_BITS_7
static final int DATA_BITS_8
static final int DCD_OFF
static final int DCD_ON
static final int DSR_FLOW_ENABLE
static final int DSR_OFF
static final int DSR_ON
static final int DTR_FLOW_ENABLE
static final int DTR_OFF
static final int DTR_ON
static final int DTRDSR_FLOW_ENABLE
static final int DTRDSR_FLOW_MASK
static final int FLUSH_INPUT
static final int FLUSH_OUTPUT
static final int LINE_ERROR
static final int LINE_NO_ERROR
static final int MODE_RS232
static final int MODE_RS422
static final int MODE_RS485_2W
static final int MODE_RS485_4W
static final int PARITY_EVEN
static final int PARITY_MARK
static final int PARITY_NONE
static final int PARITY_ODD
static final int PARITY_SPACE
static final int RI_OFF
static final int RI_ON
static final int RTS_FLOW_ENABLE
static final int RTS_OFF
static final int RTS_ON
static final int RTSCTS_FLOW_ENABLE
static final int RTSCTS_FLOW_MASK
static final int STOP_BITS_1
static final int STOP_BITS_1_5
static final int STOP_BITS_2
static final int XOFF_FLOW_ENABLE
static final int XON_FLOW_ENABLE
static final int XONXOFF_FLOW_ENABLE
static final int XONXOFF_FLOW_MASK
Method Detail |
---|
void close() throws MxException
MxException
- If an error occurs.void flush(int mode) throws MxException
mode
- [in] is one or both of FLUSH_INPUT
and FLUSH_OUTPUT
.
MxException
- If an error occurs.int getBaud() throws MxException
MxException
- If an error occurs.MxUPort.FlowCtrl getFlowCtrl() throws MxException
FlowCtrl
MxException
- If an error occurs.int getInterface() throws MxException
MODE_RS232
, MODE_RS485_2W
, MODE_RS485_4W
, or MODE_RS422
.
MxException
- If an error occurs.MxUPort.IoctlMode getIoctlMode() throws MxException
IoctlMode
MxException
- If an error occurs.MxUPort.LineError getLineStatus() throws MxException
LineError
MxException
- If an error occurs.MxUPort.ModemStatus getModemStatus() throws MxException
ModemStatus
MxException
- If an error occurs.int getOQueue() throws MxException
MxException
- If an error occurs.java.lang.String getPortName() throws MxException
MxException
- If an error occurs.android.hardware.usb.UsbDevice getUsbDevice()
UsbDevice
object.java.lang.String getUsbDeviceName() throws MxException
MxException
- If an error occurs.int getUsbReadTimeout() throws MxException
MxException
- If an error occurs.setUsbReadTimeout(int)
int getUsbWriteTimeout() throws MxException
MxException
- If an error occurs.setUsbWriteTimeout(int)
boolean hasUsbPermission() throws MxException
MxUPortService.getPortInfoList
for more information.
Tips: The UPort 1100 series has a 2-step boot up process. The UPort 1100 series will be
discovered again after it is reset. Checking the return value can help to
determine whether the UPort need to request permission again.
MxException
com.moxa.mxuportapi.MxUPortService.requestPermission
void open() throws MxException
MxException
- If an error occurs.int read(byte[] buffer) throws MxException
buffer
- [in][out] The repository for the incoming data.
MxException
- If an error occurs.int read(byte[] buffer, int length) throws MxException
buffer
- [in][out] The repository for the incoming data.length
- [in] The required data length. It must not exceed the size of the buffer.
MxException
- If an error occurs.int read(byte[] buffer, int length, int timeout) throws MxException
buffer
- [in][out] The repository for the incoming data.length
- [in] The required data length. It must not exceed the size of the buffer.timeout
- [in] The timeout value for receiving data.
MxException
- If an error occurs.void setBaud(int speed) throws MxException
speed
- [in] The true baud rate, e.g. 200, 1200, 9600, 19200, etc.
MxException
- If an error occurs.void setBreak(int time) throws MxException
time
- [in] Break time in milliseconds.
MxException
- If an error occurs.void setDTR(int mode) throws MxException
mode
- [in] for the DTR setting, which is either DTR_ON
or DTR_OFF
.
MxException
- If an error occurs.void setFlowCtrl(MxUPort.FlowCtrl flow) throws MxException
RTSCTS_FLOW_ENABLE
and XONXOFF_FLOW_ENABLE
flow control settings. The UPort 1200/1400/1600 series support RTSCTS_FLOW_ENABLE
, XONXOFF_FLOW_ENABLE
, and DTRDSR_FLOW_ENABLE
.
mode
- [in] FlowCtrl
contains flow control settings.
MxException
- If an error occurs.void setInterface(int intf) throws MxException
intf
- [in] for interface setting. Is one of MODE_RS232
, MODE_RS485_2W
, MODE_RS485_4W
, and MODE_RS422
.
MxException
- If an error occurs.void setIoctlMode(MxUPort.IoctlMode mode) throws MxException
mode
- [in] IoctlMode
contains serial settings.
MxException
- If an error occurs.void setPortName(java.lang.String name) throws MxException
string
- [in] Specifies the name of this port. The maximum length is 20 bytes. Give an empty string to erase it. A null string will cause an exception.
MxException
- If an error occurs.void setRTS(int mode) throws MxException
mode
- [in] for RTS settings; is either RTS_ON
or RTS_OFF
.
MxException
- If an error occurs.void setUsbReadTimeout(int time) throws MxException
time
- [in] The timeout value in milliseconds.
MxException
- If an error occurs.void setUsbWriteTimeout(int time) throws MxException
time
- [in] The timeout value in milliseconds.
MxException
- If an error occurs.int write(byte[] buffer) throws MxException
buffer
- [in] The buffer contains all data to send.
MxException
- If an error occurs.int write(byte[] buffer, int length) throws MxException
buffer
- [in] The buffer that contains data to send.length
- [in] The length of data to send.
MxException
- If an error occurs.int write(byte[] buffer, int length, int timeout) throws MxException
buffer
- [in] The buffer that contains data to send.length
- [in] The length of data to send.timeout
- [in] The timeout value to receive data.
-
MxException
- If an error occurs.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |