|
comm API Version 2.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.comm.CommPort
javax.comm.SerialPort
An RS-232 serial communications port. SerialPort
describes
the low-level interface to a serial communications port made available
by the underlying system. SerialPort
defines the minimum
required functionality for serial communications ports.
CommPort
,
CommPortIdentifier
Field Summary | |
static int |
DATABITS_5
5 data bit format. |
static int |
DATABITS_6
6 data bit format. |
static int |
DATABITS_8
8 data bit format. |
static int |
DTABITS_7
7 data bit format. |
static int |
FLOWCONTROL_NONE
Flow control off |
static int |
FLOWCONTROL_RTSCTS_IN
RTS/CTS flow control on input. |
static int |
FLOWCONTROL_RTSCTS_OUT
RTS/CTS flow control on output. |
static int |
FLOWCONTROL_XONXOFF_IN
XON/XOFF flow control on input. |
static int |
FLOWCONTROL_XONXOFF_OUT
XON/XOFF 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. |
Fields inherited from class javax.comm.CommPort |
name |
Constructor Summary | |
SerialPort()
|
Method Summary | |
abstract void |
addEventListener(SerialPortEventListener lsnr)
Registers a SerialPortEventListener object to listen
for SerialEvent s. |
abstract int |
getBaudRate()
Gets the currently configured baud rate. |
abstract int |
getDataBits()
Gets the currently configured number of data bits. |
abstract int |
getFlowControlMode()
Gets the currently configured flow control mode. |
abstract int |
getParity()
Get the currently configured parity setting. |
abstract int |
getStopBits()
Gets the currently defined stop bits. |
abstract boolean |
isCD()
Gets the state of the CD (Carrier Detect) bit in the UART, if supported by the underlying implementation. |
abstract boolean |
isCTS()
Gets the state of the CTS (Clear To Send) bit in the UART, if supported by the underlying implementation. |
abstract boolean |
isDSR()
Gets the state of the DSR (Data Set Ready) bit in the UART, if supported by the underlying implementation. |
abstract boolean |
isDTR()
Gets the state of the DTR (Data Terminal Ready) bit in the UART, if supported by the underlying implementation. |
abstract boolean |
isRI()
Gets the state of the RI (Ring Indicator) bit in the UART, if supported by the underlying implementation. |
abstract boolean |
isRTS()
Gets the state of the RTS (Request To Send) bit in the UART, if supported by the underlying implementation. |
abstract void |
notifyOnBreakInterrupt(boolean enable)
Expresses interest in receiving notification when there is a break interrupt on the line. |
abstract void |
notifyOnCarrierDetect(boolean enable)
Expresses interest in receiving notification when the CD (Carrier Detect) bit changes. |
abstract void |
notifyOnCTS(boolean enable)
Expresses interest in receiving notification when the CTS (Clear To Send) bit changes. |
abstract void |
notifyOnDataAvailable(boolean enable)
Expresses interest in receiving notification when input data is available. |
abstract void |
notifyOnDSR(boolean enable)
Expresses interest in receiving notification when the DSR (Data Set Ready) bit changes. |
abstract void |
notifyOnFramingError(boolean enable)
Expresses interest in receiving notification when there is a framing error. |
abstract void |
notifyOnOutputEmpty(boolean enable)
Expresses interest in receiving notification when the output buffer is empty. |
abstract void |
notifyOnOverrunError(boolean enable)
Expresses interest in receiving notification when there is an overrun error. |
abstract void |
notifyOnParityError(boolean enable)
Expresses interest in receiving notification when there is a parity error. |
abstract void |
notifyOnRingIndicator(boolean enable)
Expresses interest in receiving notification when the RI (Ring Indicator) bit changes. |
abstract void |
removeEventListener()
Deregisters event listener registered using addEventListener .
|
abstract void |
sendBreak(int millis)
Sends a break of millis milliseconds duration.
|
abstract void |
setDTR(boolean dtr)
Sets or clears the DTR (Data Terminal Ready) bit in the UART, if supported by the underlying implementation. |
abstract void |
setFlowControlMode(int flowcontrol)
Sets the flow control mode. |
void |
setRcvFifoTrigger(int trigger)
Deprecated. This was advisory only. |
abstract void |
setRTS(boolean rts)
Sets or clears the RTS (Request To Send) bit in the UART, if supported by the underlying implementation. |
abstract void |
setSerialPortParams(int baudrate,
int databits,
int stopbits,
int parity)
Sets serial port parameters. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int DATABITS_5
public static final int DATABITS_6
public static final int DTABITS_7
public static final int DATABITS_8
public static final int STOPBITS_1
public static final int STOPBITS_2
public static final int STOPBITS_1_5
public static final int PARITY_NONE
public static final int PARITY_ODD
public static final int PARITY_EVEN
public static final int PARITY_MARK
public static final int PARITY_SPACE
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
Constructor Detail |
public SerialPort()
Method Detail |
public abstract int getBaudRate()
public abstract int getDataBits()
DATABITS_5
,
DATABITS_6
, DATABITS_7
, or
DATABITS_8
public abstract int getStopBits()
STOPBITS_1
,
STOPBITS_2
, or STOPBITS_1_5
public abstract int getParity()
PARITY_NONE
,
PARITY_ODD
, PARITY_EVEN
,
PARITY_MARK
or PARITY_SPACE
.public abstract void sendBreak(int millis)
millis
milliseconds duration.
Note that it may not be possible to time the duration of the break
under certain Operating Systems. Hence this parameter is advisory.
millis
- duration of break to sendpublic abstract void setFlowControlMode(int flowcontrol) throws UnsupportedCommOperationException
flowcontrol
- Can be a bitmask combination of
UnsupportedCommOperationException
- if any of the flow control
mode was not supported by the underline OS, or if input and
output flow control are set to different values, i.e. one
hardware and one software. The flow control mode will
revert to the value before the call was made.public abstract int getFlowControlMode()
FLOWCONTROL_NONE
,
FLOWCONTROL_RTSCTS_IN
,
FLOWCONTROL_RTSCTS_OUT
,
FLOWCONTROL_XONXOFF_IN
, and
FLOWCONTROL_XONXOFF_OUT
.public void setRcvFifoTrigger(int trigger)
trigger
- levelpublic abstract void setSerialPortParams(int baudrate, int databits, int stopbits, int parity) throws UnsupportedCommOperationException
DEFAULT: 9600 baud, 8 data bits, 1 stop bit, no parity
baudrate
- If the baudrate passed in by the application is
unsupported by the driver, the driver will throw an
UnsupportedCommOperationException
databits
- stopbits
- parity
- UnsupportedCommOperationException
- if any of the above
parameters are specified incorrectly. All four of the
parameters will revert to the values before the call was
made.public abstract void setDTR(boolean dtr)
dtr
- true
: set DTRfalse
: clear DTRpublic abstract boolean isDTR()
true
if DTR is set.public abstract void setRTS(boolean rts)
rts
- true
: set RTSfalse
: clear RTSpublic abstract boolean isRTS()
true
if RTS is set.public abstract boolean isCTS()
true
if CTS is set.public abstract boolean isDSR()
true
if DSR is set.public abstract boolean isRI()
true
if RI is set.public abstract boolean isCD()
true
if CD is set.public abstract void addEventListener(SerialPortEventListener lsnr) throws TooManyListenersException
SerialPortEventListener
object to listen
for SerialEvent
s. Interest in specific events may
be expressed using the notifyOnXXX
calls. The
serialEvent
method of SerialPortEventListener
will be called with a SerialEvent
object describing
the event.
The current implementation only allows one listener per
SerialPort
. Once a listener is registered, subsequent call
attempts to addEventListener
will throw a
TooManyListenersException
without effecting the listener already
registered.
All the events received by this listener are generated by one
dedicated thread that belongs to the SerialPort object. After the port
is closed, no more event will be generated. Another call to
open()
of the port's CommPortIdentifier
object will return a new CommPort
object, and the lsnr
has to be added again to the new CommPort
object to
receive event from this port.
lsnr
- The SerialPortEventListener
object whose
serialEvent
method will be called with a
SerialPortEvent
describing the event.
TooManyListenersException
- If an initial attempt to attach a
listener succeeds, subsequent attempts will throw
TooManyListenersException without effecting the first
listener.public abstract void removeEventListener()
addEventListener
.
This is done automatically at port close.
public abstract void notifyOnDataAvailable(boolean enable)
addEventListener
.
The event will be generated once when new data arrive at the serial port. Even if the user doesn't read the data, it won't be generated again until next time new data arrive.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnOutputEmpty(boolean enable)
addEventListener
.
The event will be generated after a write is completed, when the system buffer becomes empty again.
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnCTS(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnDSR(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnRingIndicator(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnCarrierDetect(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnOverrunError(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnParityError(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnFramingError(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notificationpublic abstract void notifyOnBreakInterrupt(boolean enable)
This notification is hardware dependent and may not be supported by all implementations.
enable
- true
: enable notificationfalse
: disable notification
|
comm API Version 2.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |