public interface SerialPort
extends java.io.Closeable
A SerialPort is created using SerialPortBuilder
. Once closed it cannot be opened again but has to be
recreated.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the serial port.
|
int |
getBaudRate() |
DataBits |
getDataBits()
Get the current data bits config.
|
FlowControl |
getFlowControl()
Get the current flow control settings.
|
java.io.InputStream |
getInputStream()
Returns the input stream for this serial port.
|
java.io.OutputStream |
getOutputStream()
Returns the output stream for this serial port.
|
Parity |
getParity()
Get the parity.
|
java.lang.String |
getPortName()
Get the name of the serial port.
|
int |
getSerialPortTimeout()
Returns setting for serial port timeout.
|
StopBits |
getStopBits()
Get the current stop bits settings.
|
boolean |
isClosed()
Returns whether the serial port is currently open and available for communication.
|
void |
setBaudRate(int baudRate)
Sets the baud rate of the system.
|
void |
setDataBits(DataBits dataBits)
Set the data bits.
|
void |
setFlowControl(FlowControl flowControl)
Set the flow control type.
|
void |
setParity(Parity parity)
Set the new parity.
|
void |
setSerialPortTimeout(int serialPortTimeout)
Enable/disable serial port timeout with the specified timeout, in milliseconds.
|
void |
setStopBits(StopBits stopBits)
Set the stop bits.
|
java.io.InputStream getInputStream() throws java.io.IOException
Closing the returned InputStream will close the associated serial port.
java.io.IOException
- if an I/O error occurredjava.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- if an I/O error occurred.void close() throws java.io.IOException
Also closes the associated input and output streams.
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException
- if an I/O error occurred.boolean isClosed()
java.lang.String getPortName()
DataBits getDataBits()
void setDataBits(DataBits dataBits) throws java.io.IOException
dataBits
- the new dataBits.java.io.IOException
- if an I/O exception occurred when setting the new data bits..Parity getParity()
void setParity(Parity parity) throws java.io.IOException
parity
- the new parity.java.io.IOException
- if an I/O exception occurred when setting the new parity.StopBits getStopBits()
void setStopBits(StopBits stopBits) throws java.io.IOException
stopBits
- the stopBits to setjava.io.IOException
- if an I/O exception occurred when setting the new stop bits.int getBaudRate()
setBaudRate(int)
void setBaudRate(int baudRate) throws java.io.IOException
baudRate
- the new baud rate.java.io.IOException
- if an I/O exception occurred when setting the new baud rate.getBaudRate()
int getSerialPortTimeout()
0
returns implies that the option is disabled (i.e.,
timeout of infinity).setSerialPortTimeout(int)
void setSerialPortTimeout(int serialPortTimeout) throws java.io.IOException
> 0
. A timeout of zero is interpreted as an infinite timeout.serialPortTimeout
- the specified timeout, in milliseconds.java.io.IOException
- if there is an error in the underlying protocol.getSerialPortTimeout()
void setFlowControl(FlowControl flowControl) throws java.io.IOException
flowControl
- the flow control.java.io.IOException
- if an I/O exception occurred when setting the new baud rate.FlowControl getFlowControl()