public static final class UARTConfig.Builder
extends java.lang.Object
Builder
class allows for creating and initializing
UARTConfig
objects. Calls can be chained in the following manner:
UARTConfig config = new UARTConfig.Builder() .setControllerNumber(1) .setChannelNumber(1) .setBaudRate(56000) .setDataBits(DATABITS_9) .setStopBits(STOPBITS_2) .setParity(PARITY_EVEN) .setFlowControlMode(FLOWCONTROL_NONE) .setInputBufferSize(0) .setOutputBufferSize(0) .build();
Constructor and Description |
---|
UARTConfig.Builder() |
Modifier and Type | Method and Description |
---|---|
UARTConfig |
build()
Creates a new
UARTConfig instance initialized with the
values set for each configuration parameters. |
UARTConfig.Builder |
setBaudRate(int baudRate)
Sets the speed in Bauds (default value is
9600 if not set). |
UARTConfig.Builder |
setChannelNumber(int channelNumber)
Sets the channel number (default value is
UNASSIGNED if not
set). |
UARTConfig.Builder |
setControllerName(java.lang.String controllerName)
Sets the controller name (default value is
null if not set). |
UARTConfig.Builder |
setControllerNumber(int controllerNumber)
Sets the controller number (default value is
UNASSIGNED if
not set). |
UARTConfig.Builder |
setDataBits(int dataBits)
Sets the number of bits per character (default value is
DATABITS_8 if not set). |
UARTConfig.Builder |
setFlowControlMode(int flowcontrol)
Sets the flow control mode (default value is
FLOWCONTROL_NONE
if not set). |
UARTConfig.Builder |
setInputBufferSize(int inputBufferSize)
Sets the requested input buffer size (default value is
UNASSIGNED if not set). |
UARTConfig.Builder |
setOutputBufferSize(int outputBufferSize)
Sets the requested output buffer size (default value is
UNASSIGNED if not set). |
UARTConfig.Builder |
setParity(int parity)
Sets the parity (default value is
PARITY_NONE if not set). |
UARTConfig.Builder |
setStopBits(int stopBits)
Sets the number of stop bits per character (default value is
STOPBITS_1 if not set). |
public UARTConfig build()
UARTConfig
instance initialized with the
values set for each configuration parameters. If a configuration
parameter was not explictly set its default value will be used.UARTConfig
instance.public UARTConfig.Builder setControllerName(java.lang.String controllerName)
null
if not set).controllerName
- the controller name (such as its device
file name on UNIX systems) or null
.Builder
instance.public UARTConfig.Builder setChannelNumber(int channelNumber)
UNASSIGNED
if not
set).channelNumber
- the channel number (a positive or zero integer)
or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if channelNumber
is not in
the defined range.public UARTConfig.Builder setControllerNumber(int controllerNumber)
UNASSIGNED
if
not set).controllerNumber
- the hardware converter's number (a positive
or zero integer) or UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if controllerNumber
is not
in the defined range.public UARTConfig.Builder setBaudRate(int baudRate)
9600
if not set).baudRate
- the speed in Bauds (a positive integer).Builder
instance.java.lang.IllegalArgumentException
- if baudRate
is not in the
defined range.public UARTConfig.Builder setDataBits(int dataBits)
DATABITS_8
if not set).dataBits
- the number of bits per character, one of: UARTConfig.DATABITS_5
, UARTConfig.DATABITS_6
,
UARTConfig.DATABITS_7
, UARTConfig.DATABITS_8
or UARTConfig.DATABITS_9
.Builder
instance.java.lang.IllegalArgumentException
- if dataBits
is not in the
defined range.public UARTConfig.Builder setFlowControlMode(int flowcontrol)
FLOWCONTROL_NONE
if not set).flowcontrol
- the flow control mode: UARTConfig.FLOWCONTROL_NONE
if flow control is disabled; or a bit-wise OR combination of
UARTConfig.FLOWCONTROL_RTSCTS_IN
, UARTConfig.FLOWCONTROL_RTSCTS_OUT
, UARTConfig.FLOWCONTROL_XONXOFF_IN
or UARTConfig.FLOWCONTROL_XONXOFF_OUT
.Builder
instance.java.lang.IllegalArgumentException
- if flowcontrol
is not in the defined range
or if more than one input or more than one output flow control mode is specified.public UARTConfig.Builder setInputBufferSize(int inputBufferSize)
UNASSIGNED
if not set).inputBufferSize
- the requested input buffer size in number of
samples (a positive or zero integer) or
UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if inputBufferSize
is not in
the defined range.public UARTConfig.Builder setOutputBufferSize(int outputBufferSize)
UNASSIGNED
if not set).outputBufferSize
- the requested output buffer size in number of
samples (a positive or zero integer) or
UNASSIGNED
.Builder
instance.java.lang.IllegalArgumentException
- if outputBufferSize
is not
in the defined range.public UARTConfig.Builder setParity(int parity)
PARITY_NONE
if not set).parity
- the parity, one of: UARTConfig.PARITY_ODD
, UARTConfig.PARITY_EVEN
, UARTConfig.PARITY_MARK
,
UARTConfig.PARITY_SPACE
, or UARTConfig.PARITY_NONE
.Builder
instance.java.lang.IllegalArgumentException
- if parity
is not in the
defined range.public UARTConfig.Builder setStopBits(int stopBits)
STOPBITS_1
if not set).stopBits
- the number of stop bits per character, on of:
UARTConfig.STOPBITS_1
, UARTConfig.STOPBITS_1_5
, or UARTConfig.STOPBITS_2
.Builder
instance.java.lang.IllegalArgumentException
- if stopBits
is not in the
defined range.Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices