net.rim.device.api.system
Class IOPort

java.lang.Object
  extended by net.rim.device.api.system.IOPort
Direct Known Subclasses:
BluetoothSerialPort, SerialPort, USBPort

public abstract class IOPort
extends Object

Provides low-level access to the device's I/O port.

See Also:
IOPortListener

Constructor Summary
protected IOPort()
          Constructs a new IOPort instance.
 
Method Summary
abstract  void close()
          Closes the I/O port.
abstract  int read()
          Reads single data byte from the receive buffer.
abstract  int read(byte[] data)
          Reads data bytes from the receive buffer.
abstract  int read(byte[] data, int offset, int length)
          Reads some data bytes from the receive buffer.
static void registerNotifyPattern(byte[] pattern)
          Deprecated. Please use SerialPort.registerNotifyPattern(byte[]) instead.
abstract  int write(byte[] data)
          Places bytes to send into the transmit buffer.
abstract  int write(byte[] data, int offset, int length)
          Places some bytes to send into the transmit buffer.
abstract  int write(int b)
          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
 



Constructor Detail

IOPort

protected IOPort()
Constructs a new IOPort instance.



Method Detail

close

public abstract void close()
Closes the I/O port.


write

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

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 abstract int write(byte[] data,
                          int offset,
                          int length)
                   throws IOException
Places some bytes to send into the transmit buffer.

Use this method to place only a portion of a byte array into the transmit buffer.

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 abstract int write(int b)
                   throws IOException
Places a single byte to send into the transmit buffer.

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

read

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

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 abstract int read(byte[] data,
                         int offset,
                         int length)
                  throws IOException
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.

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 abstract int read()
                  throws IOException
Reads single data byte from the receive buffer.

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

registerNotifyPattern

public static void registerNotifyPattern(byte[] pattern)
Deprecated. Please use SerialPort.registerNotifyPattern(byte[]) instead.

Registers a pattern to look for on the port.

For serial ports:
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.





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.