net.rim.device.api.system
Class SerialPort

java.lang.Object
  |
  +--net.rim.device.api.system.IOPort
        |
        +--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. 
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

DEFAULT_PORT

public static final int DEFAULT_PORT
Deprecated. 
Default serial port.

PARITY_EVEN

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

PARITY_NONE

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

PARITY_ODD

public static final int PARITY_ODD
Deprecated. 
Connection has odd parity.
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 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.
Throws:
IOException - If the port could not be opened.
Method Detail

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.

Overrides:
close in class IOPort

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.

isSupported

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

read

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

Overrides:
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.

read

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

Overrides:
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.

Overrides:
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.

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:
JDE 4.0.0

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.

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 PARITY_NONE, PARITY_EVEN, PARITY_ODD.
stopBits - Number of stop bits to use (1 or 2).
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.

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.

Overrides:
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.

Overrides:
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.

Overrides:
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.



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.