net.rim.device.api.system
Class SerialPort

java.lang.Object
  extended by net.rim.device.api.system.IOPort
      extended by net.rim.device.api.system.SerialPort

Deprecated. The serial port is no longer supported.

public final class SerialPort
extends IOPort

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

PARITY_NONE

public static final int PARITY_NONE
Deprecated. 
Connection has no parity.

See Also:
Constant Field Values

PARITY_EVEN

public static final int PARITY_EVEN
Deprecated. 
Connection has even parity.

See Also:
Constant Field Values

PARITY_ODD

public static final int PARITY_ODD
Deprecated. 
Connection has odd parity.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Deprecated. 
Default serial port.

See Also:
Constant Field Values


Constructor Detail

SerialPort

public SerialPort(int baud,
                  int dataBits,
                  int parity,
                  int stopBits,
                  int rxBufferSize,
                  int txBufferSize)
           throws IOException
Deprecated. 
Constructs a new SerialPort object, opening the default port.

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.

Parameters:
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.
Throws:
IOException - If the port could not be opened.


Method Detail

isSupported

public static boolean isSupported()
Deprecated. 
Determines if the device has a serial port.

Returns:
True if the device has a serial port.

setProperties

public void setProperties(int baud,
                          int dataBits,
                          int parity,
                          int stopBits)
                   throws IOException
Deprecated. 
Changes this port's configuration.

Parameters:
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).
Throws:
IOException - Thrown if the port is not currently open.

setDsr

public void setDsr(boolean state)
            throws IOException
Deprecated. 
Sets DSR modem control line.

Parameters:
state - Desired DSR signal state.
Throws:
IOException - Thrown if the port is not currently open.

standbyMode

public void standbyMode(boolean state)
                 throws IOException
Deprecated. 
Toggles standby mode state.

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.

Parameters:
state - If True, put port into standby mode; if False, wake port up from standby mode.
Throws:
IOException - Thrown if the port is not currently open.

getDtr

public boolean getDtr()
               throws IOException
Deprecated. 
Retrieves state of the DTR line.

Returns:
Current state of the DTR line.
Throws:
IOException - Thrown if the port is not currently open.

getTxCount

public int getTxCount()
               throws IOException
Deprecated. 
Retreives number of characters reamining in the transmit buffer.

Returns:
Number of characters remaining to transmit.
Throws:
IOException - If the port is not currently open.

close

public void close()
Deprecated. 
Closes the serial port.

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.

Specified by:
close in class IOPort

write

public int write(byte[] data)
          throws IOException
Deprecated. 
Places bytes to send into the transmit buffer.

Note that after calling this method, you must wait for the IOPortListener.dataSent() method to be invoked before writing additional data.

Specified by:
write in class IOPort
Parameters:
data - Bytes of data to send.
Returns:
Number of bytes placed in the buffer.
Throws:
IOException - If the port is not currently open.

write

public int write(byte[] data,
                 int offset,
                 int length)
          throws IOException
Deprecated. 
Places some bytes to send into the transmit buffer.

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.

Specified by:
write in class IOPort
Parameters:
data - Bytes array containing data to send.
offset - First data byte from array to send.
length - Number of data bytes to send.
Returns:
Number of bytes actually placed in the buffer.
Throws:
IOException - If the port is not currently open.

write

public int write(int b)
          throws IOException
Deprecated. 
Places a single byte to send into the transmit buffer.

Note that after calling this method, you must wait for the IOPortListener.dataSent() method to be invoked before writing additional data.

Specified by:
write in class IOPort
Parameters:
b - Byte of data to send.
Returns:
Numebr of bytes actually placed in the buffer (1 or 0).
Throws:
IOException - If the port is not currently open.

read

public int read(byte[] data)
         throws IOException
Deprecated. 
Reads data bytes from the receive buffer.

Specified by:
read in class IOPort
Parameters:
data - Buffer to contain the received bytes; to flush the receive buffer, pass null.
Returns:
Number of bytes placed in the data buffer.
Throws:
IOException - If the port is not currently open.

read

public int read(byte[] data,
                int offset,
                int length)
         throws IOException
Deprecated. 
Reads some data bytes from the receive buffer.

Invoke this method to stuff only a portion of your data buffer with bytes from the receive buffer.

Specified by:
read in class IOPort
Parameters:
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.
Returns:
Actual number of bytes placed in the receive buffer.
Throws:
IOException - If the port is not currently open.

read

public int read()
         throws IOException
Deprecated. 
Reads single data byte from the receive buffer.

Specified by:
read in class IOPort
Returns:
The byte read, or a negative number if an error occurred or no bytes were available.
Throws:
IOException - Thrown if the port is not currently open.

registerNotifyPattern

public static void registerNotifyPattern(byte[] pattern)
Deprecated. 
Registers a pattern to look for on the port.

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).

Parameters:
pattern - Pattern to look for; the first byte must be non-zero, and the pattern must be four bytes in length.
Since:
BlackBerry API 4.0.0





Copyright 1999-2010 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. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.