|
SMSLib 3.5.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.smslib.helper.SerialPort
public class SerialPort
An RS-232 serial communications port.
Please note: This is a wrapper around
javax.comm.SerialPort
(and so gnu.io.SerialPort
).
The API definition is taken from Sun. So honor them!
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.
Field Summary | |
---|---|
static int |
DATABITS_8
8 data bit format. |
static int |
FLOWCONTROL_RTSCTS_IN
RTS/CTS flow control on input. |
static int |
FLOWCONTROL_RTSCTS_OUT
RTS/CTS flow control on output. |
static int |
PARITY_NONE
No parity bit. |
static int |
STOPBITS_1
Number of STOP bits - 1. |
Method Summary | |
---|---|
void |
addEventListener(SerialPortEventListener lsnr)
Registers a SerialPortEventListener object to listen for SerialEvents. |
void |
close()
Closes the communications port. |
void |
enableReceiveThreshold(int i)
Enables receive threshold, if this feature is supported by the driver. |
void |
enableReceiveTimeout(int rcvTimeout)
Enables receive timeout, if this feature is supported by the driver. |
java.io.InputStream |
getInputStream()
Returns an input stream. |
java.io.OutputStream |
getOutputStream()
Returns an output stream. |
void |
notifyOnBreakInterrupt(boolean b)
Expresses interest in receiving notification when there is a break interrupt on the line. |
void |
notifyOnDataAvailable(boolean b)
Expresses interest in receiving notification when input data is available. |
void |
notifyOnFramingError(boolean b)
Expresses interest in receiving notification when there is a parity error. |
void |
notifyOnOutputEmpty(boolean b)
Expresses interest in receiving notification when the output buffer is empty. |
void |
notifyOnOverrunError(boolean b)
Expresses interest in receiving notification when there is an overrun error. |
void |
notifyOnParityError(boolean b)
Expresses interest in receiving notification when there is a parity error. |
void |
setFlowControlMode(int flowcontrol)
Sets the flow control mode. |
void |
setInputBufferSize(int serial_buffer_size)
Gets the input buffer size. |
void |
setOutputBufferSize(int serial_buffer_size)
Sets the output buffer size. |
void |
setSerialPortParams(int baudrate,
int dataBits,
int stopBits,
int parity)
Sets serial port parameters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FLOWCONTROL_RTSCTS_IN
public static final int DATABITS_8
public static final int STOPBITS_1
public static final int PARITY_NONE
public static final int FLOWCONTROL_RTSCTS_OUT
Method Detail |
---|
public void addEventListener(SerialPortEventListener lsnr)
lsnr
- The SerialPortEventListener object whose serialEvent method
will be called with a SerialEvent describing the event.
java.util.TooManyListenersException
- (Wrapped as RuntimeException) If an initial attempt to attach
a listener succeeds, subsequent attempts will throw
TooManyListenersException without effecting the first
listener.public void close()
close
when it is done with the port. Notification of this
ownership change will be propagated to all classes registered using
addPortOwnershipListener
.
public void enableReceiveThreshold(int i)
i
- when this many bytes are in the input buffer, return
immediately from read.
UnsupportedCommOperationException
- -
(Wrapped as RuntimeException) is thrown if receive threshold
is not supported by the underlying driver.public void enableReceiveTimeout(int rcvTimeout)
read
from
the input stream for this port will return immediately.
enableReceiveTimeout
is an advisory method which the
driver may not implement. By default, receive timeout is not enabled.
An application can determine whether the driver supports this feature by
first calling the enableReceiveTimeout
method and then
calling the isReceiveTimeout
method. If
isReceiveTimeout
still returns false, then receive timeout
is not supported by the driver.
See getInputStream
for description of exact behaviour.
rcvTimeout
- when this many milliseconds have elapsed, return immediately
from read, regardless of bytes in input buffer.public java.io.InputStream getInputStream()
getInputStream
returns null.
The read behaviour of the input stream returned by
getInputStream
depends on combination of the threshold and
timeout values. The possible behaviours are described in the table below:
Threshold | Timeout | Read Buffer Size | Read Behaviour | ||
---|---|---|---|---|---|
State | Value | State | Value | ||
disabled | - | disabled | - | n bytes | block until any data is available |
enabled | m bytes | disabled | - | n bytes | block until min(m,n) bytes are available |
disabled | - | enabled | x ms | n bytes | block for x ms or until any data is available |
enabled | m bytes | enabled | x ms | n bytes | block for x ms or until min(m,n) bytes are available |
Note, however, that framing errors may cause the Timeout and Threshold values to complete prematurely without raising an exception.
Enabling the Timeout OR Threshold with a value a zero is a special case. This causes the underlying driver to poll for incoming data instead being event driven. Otherwise, the behaviour is identical to having both the Timeout and Threshold disabled.
public java.io.OutputStream getOutputStream()
public void notifyOnBreakInterrupt(boolean b)
b
- public void notifyOnDataAvailable(boolean b)
b
- public void notifyOnFramingError(boolean b)
b
- public void notifyOnOutputEmpty(boolean b)
b
- public void notifyOnOverrunError(boolean b)
b
- public void notifyOnParityError(boolean b)
b
- public void setFlowControlMode(int flowcontrol)
flowcontrol
- Can be a bitmask combination of
public void setInputBufferSize(int serial_buffer_size)
serial_buffer_size
- input buffer size currently in usepublic void setOutputBufferSize(int serial_buffer_size)
serial_buffer_size
- size of the output bufferpublic void setSerialPortParams(int baudrate, int dataBits, int stopBits, int parity)
baudrate
- If the baudrate passed in by the application is unsupported by
the driver, the driver will throw an
UnsupportedCommOperationExceptiondataBits
- stopBits
- parity
-
|
SMSLib 3.5.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |