|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.system.IOPort
net.rim.device.api.system.SerialPort
public final class 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. Default serial port. |
|
static int |
PARITY_EVEN
Deprecated. Connection has even parity. |
|
static int |
PARITY_NONE
Deprecated. Connection has no parity. |
|
static int |
PARITY_ODD
Deprecated. Connection has odd parity. |
|
| Constructor Summary | ||
|---|---|---|
SerialPort(int baud,
int dataBits,
int parity,
int stopBits,
int rxBufferSize,
int txBufferSize)
Deprecated. Constructs a new SerialPort object, opening the default port. |
||
| Method Summary | ||
|---|---|---|
void |
close()
Deprecated. Closes the serial port. |
|
boolean |
getDtr()
Deprecated. Retrieves state of the DTR line. |
|
int |
getTxCount()
Deprecated. Retreives number of characters reamining in the transmit buffer. |
|
static boolean |
isSupported()
Deprecated. Determines if the device has a serial port. |
|
int |
read()
Deprecated. Reads single data byte from the receive buffer. |
|
int |
read(byte[] data)
Deprecated. Reads data bytes from the receive buffer. |
|
int |
read(byte[] data,
int offset,
int length)
Deprecated. Reads some data bytes from the receive buffer. |
|
static void |
registerNotifyPattern(byte[] pattern)
Deprecated. Registers a pattern to look for on the port. |
|
void |
setDsr(boolean state)
Deprecated. Sets DSR modem control line. |
|
void |
setProperties(int baud,
int dataBits,
int parity,
int stopBits)
Deprecated. Changes this port's configuration. |
|
void |
standbyMode(boolean state)
Deprecated. Toggles standby mode state. |
|
int |
write(byte[] data)
Deprecated. Places bytes to send into the transmit buffer. |
|
int |
write(byte[] data,
int offset,
int length)
Deprecated. Places some bytes to send into the transmit buffer. |
|
int |
write(int b)
Deprecated. Places a single byte to send into the transmit buffer. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PARITY_NONE
public static final int PARITY_EVEN
public static final int PARITY_ODD
public static final int DEFAULT_PORT
| 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
SerialPort.PARITY_NONE,
SerialPort.PARITY_EVEN,
SerialPort.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 static boolean isSupported()
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
SerialPort.PARITY_NONE,
SerialPort.PARITY_EVEN,
SerialPort.PARITY_ODD.stopBits - Number of stop bits to use (1 or 2).
IOException - Thrown if the port is not currently open.
public void setDsr(boolean state)
throws IOException
state - Desired DSR signal state.
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 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 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.
close in class IOPort
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.
write in class IOPortdata - 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.
write in class IOPortdata - 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.
write in class IOPortb - Byte of data to send.
IOException - If the port is not currently open.
public int read(byte[] data)
throws IOException
read in class IOPortdata - 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.
read in class IOPortdata - 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 int read()
throws IOException
read in class IOPortIOException - Thrown 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal