public final class UARTConfig extends java.lang.Object implements PeripheralConfig
UARTConfig
class encapsulates the hardware addressing information, and static and dynamic configuration
parameters of a UART.
Some hardware addressing parameter, and static and dynamic configuration parameters may be set to PeripheralConfig.DEFAULT
.
Whether such default settings are supported is platform- as well as peripheral driver-dependent.
An instance of UARTConfig
can be passed to the PeripheralManager.open(PeripheralConfig)
or
PeripheralManager.open(Class, PeripheralConfig)
method to open the designated UART with the specified
configuration. A PeripheralConfigInvalidException
is thrown when attempting to open a peripheral device with
an invalid or unsupported configuration.
Modifier and Type | Field and Description |
---|---|
static int |
DATABITS_5
5 data bit format.
|
static int |
DATABITS_6
6 data bit format.
|
static int |
DATABITS_7
7 data bit format.
|
static int |
DATABITS_8
8 data bit format.
|
static int |
DATABITS_9
9 data bit format.
|
static int |
FLOWCONTROL_NONE
Flow control off.
|
static int |
FLOWCONTROL_RTSCTS_IN
RTS/CTS (hardware) flow control on input.
|
static int |
FLOWCONTROL_RTSCTS_OUT
RTS/CTS (hardware) flow control on output.
|
static int |
FLOWCONTROL_XONXOFF_IN
XON/XOFF (software) flow control on input.
|
static int |
FLOWCONTROL_XONXOFF_OUT
XON/XOFF (software) flow control on output.
|
static int |
PARITY_EVEN
EVEN parity scheme.
|
static int |
PARITY_MARK
MARK parity scheme.
|
static int |
PARITY_NONE
No parity bit.
|
static int |
PARITY_ODD
ODD parity scheme.
|
static int |
PARITY_SPACE
SPACE parity scheme.
|
static int |
STOPBITS_1
Number of STOP bits - 1.
|
static int |
STOPBITS_1_5
Number of STOP bits - 1-1/2.
|
static int |
STOPBITS_2
Number of STOP bits - 2.
|
DEFAULT
Constructor and Description |
---|
UARTConfig(int uartNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol)
Creates a new
UARTConfig with the specified hardware addressing information and configuration parameters. |
UARTConfig(int uartNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol,
int inputBufferSize,
int outputBufferSize)
Creates a new
UARTConfig with the specified hardware addressing information and configuration parameters. |
Modifier and Type | Method and Description |
---|---|
int |
getBaudRate()
Gets the configured default/initial speed in Bauds.
|
int |
getDataBits()
Gets the configured default/initial number of bits per character.
|
int |
getFlowControlMode()
Gets the configured flow control mode.
|
int |
getInputBufferSize()
Gets the requested input buffer size.
|
int |
getOutputBufferSize()
Gets the requested output buffer size.
|
int |
getParity()
Gets the configured default/initial parity.
|
int |
getStopBits()
Gets the configured default/initial number of stop bits per character.
|
int |
getUARTNumber()
Gets the configured UART number.
|
public static final int DATABITS_5
public static final int DATABITS_6
public static final int DATABITS_7
public static final int DATABITS_8
public static final int DATABITS_9
public static final int FLOWCONTROL_NONE
public static final int FLOWCONTROL_RTSCTS_IN
public static final int FLOWCONTROL_RTSCTS_OUT
public static final int FLOWCONTROL_XONXOFF_IN
public static final int FLOWCONTROL_XONXOFF_OUT
public static final int PARITY_EVEN
public static final int PARITY_MARK
public static final int PARITY_NONE
public static final int PARITY_ODD
public static final int PARITY_SPACE
public static final int STOPBITS_1
public static final int STOPBITS_1_5
public static final int STOPBITS_2
public UARTConfig(int uartNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol)
UARTConfig
with the specified hardware addressing information and configuration parameters.uartNumber
- the hardware UART's number (a positive or null integer) or PeripheralConfig.DEFAULT
.baudRate
- the speed in Bauds of the UART (a positive integer).dataBits
- the number of bits per character, one of: DATABITS_5
, DATABITS_6
,
DATABITS_7
, DATABITS_8
or DATABITS_9
.parity
- the parity, one of: PARITY_ODD
, PARITY_EVEN
, PARITY_MARK
,
PARITY_SPACE
, or PARITY_NONE
.stopBits
- the number of stop bits per character, on of: STOPBITS_1
, STOPBITS_1_5
, or
STOPBITS_2
.flowcontrol
- the flow control mode - a bit-wise OR combination of FLOWCONTROL_NONE
,
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.java.lang.IllegalArgumentException
- if any of the following is true:
uartNumber
is not in the defined range;baudRate
is not in the defined range;dataBits
is not in the defined range;parity
is not in the defined range;stopBits
is not in the defined range;flowcontrol
is not in the defined range.public UARTConfig(int uartNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol, int inputBufferSize, int outputBufferSize)
UARTConfig
with the specified hardware addressing information and configuration parameters.
The platform/underlying driver may or may not allocate the requested sizes for the input and output buffers.uartNumber
- the hardware UART's number (a positive or null integer) or PeripheralConfig.DEFAULT
.baudRate
- the speed in Bauds of the UART (a positive integer).dataBits
- the number of bits per character, one of: DATABITS_5
, DATABITS_6
,
DATABITS_7
, DATABITS_8
or DATABITS_9
.parity
- the parity, one of: PARITY_ODD
, PARITY_EVEN
, PARITY_MARK
,
PARITY_SPACE
, or PARITY_NONE
.stopBits
- the number of stop bits per character, on of: STOPBITS_1
, STOPBITS_1_5
, or
STOPBITS_2
.flowcontrol
- the flow control mode - a bit-wise OR combination of FLOWCONTROL_NONE
,
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.inputBufferSize
- the input buffer size (a positive or null integer) - (advisory only).outputBufferSize
- the output buffer size (a positive or null integer) - (advisory only).java.lang.IllegalArgumentException
- if any of the following is true:
uartNumber
is not in the defined range;baudRate
is not in the defined range;dataBits
is not in the defined range;parity
is not in the defined range;stopBits
is not in the defined range;flowcontrol
is not in the defined range;inputBufferSize
is not in the defined range;outputBufferSize
is not in the defined range.public int getBaudRate()
public int getDataBits()
DATABITS_5
, DATABITS_6
,
DATABITS_7
, DATABITS_8
or DATABITS_9
.public int getFlowControlMode()
FLOWCONTROL_NONE
,
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.public int getInputBufferSize()
public int getOutputBufferSize()
public int getParity()
PARITY_ODD
, PARITY_EVEN
, PARITY_MARK
,
PARITY_SPACE
, or PARITY_NONE
.public int getStopBits()
STOPBITS_1
, STOPBITS_1_5
,
or STOPBITS_2
.public int getUARTNumber()
PeripheralConfig.DEFAULT
.Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.