public final class UARTConfig extends java.lang.Object implements DeviceConfig<UART>, DeviceConfig.HardwareAddressing
UARTConfig
class encapsulates the hardware addressing information, and static and dynamic configuration
parameters of a UART.
Some hardware addressing, static or dynamic configuration parameters may be
set to UNASSIGNED
or null
(see
Unassigned, Default or Unused Parameter Values).
An instance of UARTConfig
can be passed to the open(DeviceConfig, ...)
and
open(Class, DeviceConfig, ...)
methods of the DeviceManager
to open the designated UART with the specified
configuration. A InvalidDeviceConfigException
is thrown when attempting to open a device with
an invalid or unsupported configuration.
Modifier and Type | Class and Description |
---|---|
static class |
UARTConfig.Builder
The
Builder class allows for creating and initializing
UARTConfig objects. |
DeviceConfig.HardwareAddressing
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, UNASSIGNED
Constructor and Description |
---|
UARTConfig(int controllerNumber,
int channelNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol)
Deprecated.
As of 1.1, use
UARTConfig.Builder instead. |
UARTConfig(int controllerNumber,
int channelNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol,
int inputBufferSize,
int outputBufferSize)
Deprecated.
As of 1.1, use
UARTConfig.Builder instead. |
UARTConfig(java.lang.String controllerName,
int channelNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol)
Deprecated.
As of 1.1, use
UARTConfig.Builder instead. |
UARTConfig(java.lang.String controllerName,
int channelNumber,
int baudRate,
int dataBits,
int parity,
int stopBits,
int flowcontrol,
int inputBufferSize,
int outputBufferSize)
Deprecated.
As of 1.1, use
UARTConfig.Builder instead. |
Modifier and Type | Method and Description |
---|---|
static UARTConfig |
deserialize(java.io.InputStream in)
Creates a new
UARTConfig whose state is deserialized from the specified InputStream . |
boolean |
equals(java.lang.Object obj)
Checks two
UARTConfig objects for equality. |
int |
getBaudRate()
Gets the configured initial speed in Bauds.
|
int |
getChannelNumber()
Gets the configured UART channel number.
|
java.lang.String |
getControllerName()
Gets the configured controller name (such as its device file name on UNIX systems).
|
int |
getControllerNumber()
Gets the configured UART controller number.
|
int |
getDataBits()
Gets the configured initial number of bits per character.
|
int |
getFlowControlMode()
Gets the configured initial flow control mode.
|
int |
getInputBufferSize()
Gets the requested or allocated input buffer size.
|
int |
getOutputBufferSize()
Gets the requested or allocated output buffer size.
|
int |
getParity()
Gets the configured initial parity.
|
int |
getStopBits()
Gets the configured initial number of stop bits per character.
|
int |
hashCode()
Returns the hash code value for this object.
|
int |
serialize(java.io.OutputStream out)
Serializes the state of this
UARTConfig object to the specified OutputStream . |
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
This bit flag can be bitwise-combined (OR) with other output flow control bit flags.
public static final int FLOWCONTROL_RTSCTS_OUT
This bit flag can be bitwise-combined (OR) with other output flow control bit flags.
public static final int FLOWCONTROL_XONXOFF_IN
This bit flag can be bitwise-combined (OR) with other input flow control bit flags. The actual XON and XOFF characters used for software flow control are device hardware and driver-dependent.
public static final int FLOWCONTROL_XONXOFF_OUT
This bit flag can be bitwise-combined (OR) with other input flow control bit flags. The actual XON and XOFF characters used for software flow control are device hardware and driver-dependent.
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
@Deprecated public UARTConfig(int controllerNumber, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol)
UARTConfig.Builder
instead.UARTConfig
with the specified hardware addressing information and configuration parameters.
The controller name is set to null
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerNumber
- the hardware UART controller's number (a positive or zero integer) or UNASSIGNED
.channelNumber
- the hardware UART channel's number (a positive or zero integer) or UNASSIGNED
.baudRate
- the speed in Bauds (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: FLOWCONTROL_NONE
if flow control is disabled; or a bit-wise OR combination of
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;channelNumber
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 or if more than one input or more than one output flow control mode is specified.@Deprecated public UARTConfig(int controllerNumber, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol, int inputBufferSize, int outputBufferSize)
UARTConfig.Builder
instead.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.
The controller name is set to null
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerNumber
- the hardware UART controller's number (a positive or zero integer) or UNASSIGNED
.channelNumber
- the hardware UART channel's number (a positive or zero integer) or UNASSIGNED
.baudRate
- the speed in Bauds (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: FLOWCONTROL_NONE
if flow control is disabled; or a bit-wise OR combination of
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.inputBufferSize
- the input buffer size (a positive or zero integer) or UNASSIGNED
- (advisory only).outputBufferSize
- the output buffer size (a positive or zero integer) or UNASSIGNED
- (advisory only).java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;channelNumber
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 or if more than one input or more than one output flow control mode is specified.inputBufferSize
is not in the defined range;outputBufferSize
is not in the defined range.@Deprecated public UARTConfig(java.lang.String controllerName, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol)
UARTConfig.Builder
instead.UARTConfig
with the specified hardware addressing information and configuration parameters.
The controller number is set to UNASSIGNED
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerName
- the controller name (such as its device file name on UNIX systems).channelNumber
- the hardware UART channel's number (a positive or zero integer) or UNASSIGNED
.baudRate
- the speed in Bauds (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: FLOWCONTROL_NONE
if flow control is disabled; or a bit-wise OR combination of
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.java.lang.IllegalArgumentException
- if any of the following is true:
channelNumber
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 or if more than one input or more than one output flow control mode is specified.java.lang.NullPointerException
- if controllerName
is null
.@Deprecated public UARTConfig(java.lang.String controllerName, int channelNumber, int baudRate, int dataBits, int parity, int stopBits, int flowcontrol, int inputBufferSize, int outputBufferSize)
UARTConfig.Builder
instead.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.
The controller number is set to UNASSIGNED
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerName
- the controller name (such as its device file name on UNIX systems).channelNumber
- the hardware UART channel's number (a positive or zero integer) or UNASSIGNED
.baudRate
- the speed in Bauds (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: FLOWCONTROL_NONE
if flow control is disabled; or a bit-wise OR combination of
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.inputBufferSize
- the input buffer size (a positive or zero integer) or UNASSIGNED
- (advisory only).outputBufferSize
- the output buffer size (a positive or zero integer) or UNASSIGNED
- (advisory only).java.lang.IllegalArgumentException
- if any of the following is true:
channelNumber
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 or if more than one input or more than one output flow control mode is specified.inputBufferSize
is not in the defined range;outputBufferSize
is not in the defined range.java.lang.NullPointerException
- if controllerName
is null
.public static UARTConfig deserialize(java.io.InputStream in) throws java.io.IOException
UARTConfig
whose state is deserialized from the specified InputStream
.
This method may be invoked to restore the state of a UARTConfig
object from a persistent store.in
- the stream to read from.UARTConfig
instance.java.io.IOException
- if an I/O error occurs or if the provided stream does not
contain a representation of a UARTConfig
object.public int serialize(java.io.OutputStream out) throws java.io.IOException
UARTConfig
object to the specified OutputStream
.
This method may be invoked by the DeviceManager
to save the state of this UARTConfig
object to a persistent store.serialize
in interface DeviceConfig<UART>
out
- the stream to write to.java.io.IOException
- if an I/O error occurs.DeviceProvider.deserialize(java.io.InputStream)
public int getBaudRate()
public int getDataBits()
DATABITS_5
, DATABITS_6
,
DATABITS_7
, DATABITS_8
or DATABITS_9
.public int getFlowControlMode()
FLOWCONTROL_NONE
if flow control is disabled; or a valid bit-wise OR combination of
FLOWCONTROL_RTSCTS_IN
, FLOWCONTROL_RTSCTS_OUT
, FLOWCONTROL_XONXOFF_IN
or
FLOWCONTROL_XONXOFF_OUT
.public int getInputBufferSize()
UNASSIGNED
.public int getOutputBufferSize()
UNASSIGNED
.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 getChannelNumber()
UNASSIGNED
.public int getControllerNumber()
getControllerNumber
in interface DeviceConfig.HardwareAddressing
UNASSIGNED
.public java.lang.String getControllerName()
getControllerName
in interface DeviceConfig.HardwareAddressing
null
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
UARTConfig
objects for equality.equals
in class java.lang.Object
obj
- the object to test for equality with this object.true
if obj
is a UARTConfig
and has
the same hardware addressing information and configuration parameter values
as this UARTConfig
object; false
otherwise.Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices