public class NPortDriver extends CommonNPortDriver
Modifier and Type | Class and Description |
---|---|
class |
NPortDriver.BreakTask |
class |
NPortDriver.RecvThread |
MxNPort.FlowCtrl, MxNPort.IoctlMode, MxNPort.LineError, MxNPort.ModemStatus
CTS_FLOW_ENABLE, CTS_OFF, CTS_ON, DATA_BITS_5, DATA_BITS_6, DATA_BITS_7, DATA_BITS_8, DCD_OFF, DCD_ON, DSR_FLOW_ENABLE, DSR_OFF, DSR_ON, DTR_FLOW_ENABLE, DTR_OFF, DTR_ON, DTRDSR_FLOW_ENABLE, DTRDSR_FLOW_MASK, FLUSH_INPUT, FLUSH_OUTPUT, LINE_ERROR, LINE_NO_ERROR, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, RI_OFF, RI_ON, RTS_FLOW_ENABLE, RTS_OFF, RTS_ON, RTSCTS_FLOW_ENABLE, RTSCTS_FLOW_MASK, STOP_BITS_1, STOP_BITS_1_5, STOP_BITS_2, XOFF_FLOW_ENABLE, XON_FLOW_ENABLE, XONXOFF_FLOW_ENABLE, XONXOFF_FLOW_MASK
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the NPort's serial port through the real com mode.
|
void |
flush(int mode)
Flushes any data in the driver's input/output buffer.
|
int |
getBaud()
Get the serial port baud rate setting.
|
MxNPort.FlowCtrl |
getFlowCtrl()
Get the serial port's hardware and software flow control settings.
|
MxNPort.IoctlMode |
getIoctlMode()
Gets the serial port's mode settings, such as data bits, parity, and stop bits.
|
MxNPort.LineError |
getLineStatus()
Checks if errors occurred when receiving data; returns and cleans the
error during the transaction.
|
MxNPort.ModemStatus |
getModemStatus()
Gets the line status, such as CTS, DSR,or DCD.
|
java.net.InetAddress |
getNPortIPAddress(int interface_index)
Returns the IP address of a NPort devices.
|
byte[] |
getNPortMACAddress(int interface_number)
Returns the MAC address of a NPort devices.
|
int |
getNPortMaximumPort()
Returns the total serial port number of a NPort devices.
|
java.lang.String |
getNPortModelName()
Returns the model name of a NPort devices.
|
int |
getNPortPortIndex()
Returns the using port number of a NPort devices.
|
int |
getOQueue()
Gets the length (in bytes) remaining in the output buffer.
|
void |
open()
Open a COM port for data transmitting/receiving.
|
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(MxNPort.FlowCtrl flow)
Sets the hardware and/or software flow control.
|
void |
setIoctlMode(MxNPort.IoctlMode mode)
Configures communication parameters, such as baud rate, parity, data bits and stop bits.
|
void |
setRTS(int mode)
Sets the RTS state for a serial port.
|
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.
|
compare
public void close() throws MxException
MxException
- If an error occurs.public void flush(int mode) throws MxException
mode
- [in] is one or both of FLUSH_INPUT
and FLUSH_OUTPUT
.MxException
- If an error occurs.public int getBaud() throws MxException
MxException
- If an error occurs.public MxNPort.FlowCtrl getFlowCtrl() throws MxException
FlowCtrl
MxException
- If an error occurs.public MxNPort.IoctlMode getIoctlMode() throws MxException
IoctlMode
MxException
- If an error occurs.public MxNPort.LineError getLineStatus() throws MxException
LineError
MxException
- If an error occurs.public MxNPort.ModemStatus getModemStatus() throws MxException
ModemStatus
MxException
- If an error occurs.public java.net.InetAddress getNPortIPAddress(int interface_index) throws MxException
interface_index
- [in] The interface port index, only support first interface port now.MxException
- If an error occurs.public byte[] getNPortMACAddress(int interface_number) throws MxException
interface_number
- [in] The interface port index, only support first interface port now.MxException
- If an error occurs.public int getNPortMaximumPort() throws MxException
MxException
public java.lang.String getNPortModelName() throws MxException
MxException
public int getNPortPortIndex() throws MxException
MxException
public int getOQueue() throws MxException
MxException
- If an error occurs.public void open() throws MxException
Baud rate | Data bits | Stop bits | Parity | Flow control | DTR state | RTS state |
38400 bps | 8 | 1 | None | None | ON | ON |
MxException
- If an error occurs.public int read(byte[] buffer) throws MxException
buffer
- [in][out] The repository for the incoming data.MxException
- If an error occurs.public 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.public 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.public void setBaud(int speed) throws MxException
speed
- [in] The true baud rate, e.g. 200, 1200, 9600, 19200, etc.MxException
- If an error occurs.public void setBreak(int time) throws MxException
time
- [in] Break time in milliseconds.MxException
- If an error occurs.public 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.public void setFlowCtrl(MxNPort.FlowCtrl flow) throws MxException
RTSCTS_FLOW_ENABLE
and MxNPort.XONXOFF_FLOW_ENABLE
flow control settings. The UPort 1200/1400/1600 series support RTSCTS_FLOW_ENABLE
, MxNPort.XONXOFF_FLOW_ENABLE
, and DTRDSR_FLOW_ENABLE
.flow@throws
- MxException If an error occurs.MxException
- If an error occurs.public void setIoctlMode(MxNPort.IoctlMode mode) throws MxException
mode
- [in] IoctlMode
contains serial settings.MxException
- If an error occurs.public void setRTS(int mode) throws MxException
mode
- [in] for RTS settings; is either RTS_ON
or RTS_OFF
.MxException
- If an error occurs.public int write(byte[] buffer) throws MxException
write
in interface MxNPort
write
in class CommonNPortDriver
buffer
- [in] The buffer contains all data to send.MxException
- If an error occurs.public 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.public 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.