|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.rim.device.api.system.IOPort
|
+--net.rim.device.api.system.SerialPort
Provides low-level access to the device's serial port.
You should avoid using this class in applications, as it is not
portable. Rather, if you need to gain access to the serial port, use the CLDC
Connector factory to serve a connection.
| Field Summary | ||
static int |
DEFAULT_PORT
Deprecated. |
|
static int |
PARITY_EVEN
Deprecated. |
|
static int |
PARITY_NONE
Deprecated. |
|
static int |
PARITY_ODD
Deprecated. |
|
| Constructor Summary | ||
SerialPort(int baud,
int dataBits,
int parity,
int stopBits,
int rxBufferSize,
int txBufferSize)
Deprecated. |
||
| Method Summary | ||
void |
close()
Deprecated. |
|
boolean |
getDtr()
Deprecated. |
|
int |
getTxCount()
Deprecated. |
|
static boolean |
isSupported()
Deprecated. |
|
int |
read()
Deprecated. |
|
int |
read(byte[] data)
Deprecated. |
|
int |
read(byte[] data,
int offset,
int length)
Deprecated. |
|
static void |
registerNotifyPattern(byte[] pattern)
Deprecated. |
|
void |
setDsr(boolean state)
Deprecated. |
|
void |
setProperties(int baud,
int dataBits,
int parity,
int stopBits)
Deprecated. |
|
void |
standbyMode(boolean state)
Deprecated. |
|
int |
write(byte[] data)
Deprecated. |
|
int |
write(byte[] data,
int offset,
int length)
Deprecated. |
|
int |
write(int b)
Deprecated. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
| Constructor Detail |
public SerialPort(int baud,
int dataBits,
int parity,
int stopBits,
int rxBufferSize,
int txBufferSize)
throws IOException
Building this object also allocates serial and transmit buffers in memory, and enables the serial driver, as well as hardware serial line drivers.
We recommend that you always close the port when you're not using it, as the hardware line drivers consume extra power while the port is open.
baud - Baud the serial port should use.dataBits - Number of bits to use for data (7 or 8).parity - Parity method to use; one of
PARITY_NONE,
PARITY_EVEN,
PARITY_ODD.stopBits - Number of stop bits to use (1 or 2).rxBufferSize - Receive buffer size. This parameter is deprecated;
the receive buffer size is fixed at 2048 bytes.txBufferSize - Transmit buffer size. This parameter is deprecated;
the transmit buffer size is fixed at 2048 bytes.IOException - If the port could not be opened.| Method Detail |
public void close()
Invoking this method closes this port, disables the line drivers, and frees any buffer memory that was allocated when the port was opened.
The system automatically invokes this method when the device is shut off. Applications may not assume that the port is still open once the device is powered on again.
public boolean getDtr()
throws IOException
IOException - Thrown if the port is not currently open.
public int getTxCount()
throws IOException
IOException - If the port is not currently open.public static boolean isSupported()
public int read()
throws IOException
IOException - Thrown if the port is not currently open.
public int read(byte[] data)
throws IOException
data - Buffer to contain the received bytes; to flush the
receive buffer, pass null.IOException - If the port is not currently open.
public int read(byte[] data,
int offset,
int length)
throws IOException
Invoke this method to stuff only a portion of your data buffer with bytes from the receive buffer.
data - Buffer to contain the received bytes; to flush the receive
buffer, pass null.offset - Position from the start of the buffer to begin stuffing
bytes from the receive buffer.length - Maximum number of bytes to read.IOException - If the port is not currently open.public static void registerNotifyPattern(byte[] pattern)
While DTR is active, the port is monitored at 9600 baud 8N1. If the
specified pattern occurs, the system sends a pattern notify event to the
applications (which must implement IOPortListener.patternReceived(byte[])
to handle).
pattern - Pattern to look for; the first byte must be non-zero, and
the pattern must be four bytes in length.
public void setDsr(boolean state)
throws IOException
state - Desired DSR signal state.IOException - Thrown if the port is not currently open.
public void setProperties(int baud,
int dataBits,
int parity,
int stopBits)
throws IOException
baud - Baud this port should use.dataBits - Number of bits to use for data (7 or 8).parity - Parity method to use; one of
PARITY_NONE,
PARITY_EVEN,
PARITY_ODD.stopBits - Number of stop bits to use (1 or 2).IOException - Thrown if the port is not currently open.
public void standbyMode(boolean state)
throws IOException
In standby mode, the port is kept open, but the serial drivers and processor go into suspend mode. The invoker must already have the port open, and must remember to invoke this method with false before using the port again.
state - If True, put port into standby mode; if False, wake port up
from standby mode.IOException - Thrown if the port is not currently open.
public int write(byte[] data)
throws IOException
Note that after calling this method, you must wait
for the IOPortListener.dataSent()
method to be invoked before writing additional data.
data - Bytes of data to send.IOException - If the port is not currently open.
public int write(byte[] data,
int offset,
int length)
throws IOException
Note that after calling this method, you must wait
for the IOPortListener.dataSent()
method to be invoked before writing additional data.
Use this method to place only a portion of a byte array into the transmit buffer.
data - Bytes array containing data to send.offset - First data byte from array to send.length - Number of data bytes to send.IOException - If the port is not currently open.
public int write(int b)
throws IOException
Note that after calling this method, you must wait
for the IOPortListener.dataSent()
method to be invoked before writing additional data.
b - Byte of data to send.IOException - If the port is not currently open.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.