public class SerialPortBuilder
extends java.lang.Object
SerialPort port = newBuilder("/dev/ttyS0")
.setBaudRate(19200)
.setParity(Parity.EVEN)
.build();
InputStream is = port.getInputStream();
..
Modifier and Type | Method and Description |
---|---|
SerialPort |
build()
Combine all of the options that have been set and return a new SerialPort object.
|
static java.lang.String[] |
getSerialPortNames()
Get the serial port names on the host system.
|
static SerialPortBuilder |
newBuilder(java.lang.String portName)
Constructs a new SerialPortBuilder with the default values.
|
SerialPortBuilder |
setBaudRate(int baudRate)
Set the baud rate for the serial port.
|
SerialPortBuilder |
setDataBits(DataBits dataBits)
Set the number of data bits transfered with the serial port.
|
SerialPortBuilder |
setFlowControl(FlowControl flowControl)
Set the flow control type.
|
SerialPortBuilder |
setParity(Parity parity)
Set the parity of the serial port.
|
SerialPortBuilder |
setPortName(java.lang.String portName)
Set the serial port name.
|
SerialPortBuilder |
setStopBits(StopBits stopBits)
Set the number of stop bits after each data bits.
|
public static java.lang.String[] getSerialPortNames()
public static SerialPortBuilder newBuilder(java.lang.String portName)
portName
- the serial port name. E.g. on Unix systems: "/dev/ttyUSB0"
and on Unixpublic SerialPortBuilder setPortName(java.lang.String portName)
portName
- the serial port name e.g. "/dev/ttyUSB0"
public SerialPortBuilder setBaudRate(int baudRate)
baudRate
- the baud rate.setBaudRate(int)
public SerialPortBuilder setDataBits(DataBits dataBits)
dataBits
- the number of dataBits.SerialPort.setDataBits(DataBits)
public SerialPortBuilder setParity(Parity parity)
parity
- the parity.SerialPort.setParity(Parity)
public SerialPortBuilder setStopBits(StopBits stopBits)
stopBits
- the number of stop bits.SerialPort.setStopBits(StopBits)
public SerialPortBuilder setFlowControl(FlowControl flowControl)
flowControl
- the flow control.SerialPort.setFlowControl(FlowControl)
public SerialPort build() throws java.io.IOException
java.io.IOException
- if an I/O exception occurred while opening the serial port.