|
|||||||||
| 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.USBPort
Provides low-level access to the device's USB port.
You should avoid using this class in applications, as it is not
portable. Rather, if you need to gain access to the USB port, use the CLDC
Connector factory to serve a connection.
Note that access to the USB port is restricted by the application control
ApplicationPermissions.PERMISSION_USB.
| Constructor Summary | ||
USBPort(int channel)
Constructs a new USB object, opening the specified channel. |
||
| Method Summary | ||
void |
close()
Closes the channel. |
|
static void |
deregisterChannel(int channel)
De-registers a channel. |
|
static int |
getConnectionState()
Retrieve the current USB connection state. |
|
static int |
getMaximumRxSize()
Retrive the maximum RX buffer size that can be registered. |
|
static int |
getMaximumTxSize()
Retrive the maximum TX buffer size that can be registered. |
|
static boolean |
isSupported()
Determines if the device has a serial port. |
|
int |
read()
Reads single data byte from the receive buffer. |
|
int |
read(byte[] data)
Reads data bytes from the receive buffer. |
|
int |
read(byte[] data,
int offset,
int length)
Reads some data bytes from the receive buffer. |
|
static int |
registerChannel(String name,
int maxRxSize,
int maxTxSize)
Registers a channel. |
|
int |
write(byte[] data)
Places bytes to send into the transmit buffer. |
|
int |
write(byte[] data,
int offset,
int length)
Places some bytes to send into the transmit buffer. |
|
int |
write(int b)
Places a single byte to send into the transmit buffer. |
|
| Methods inherited from class net.rim.device.api.system.IOPort |
registerNotifyPattern |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public USBPort(int channel)
throws IOException
channel - The channel to open.IOException - If the port could not be opened.ControlledAccessException - if application control forbids this operation.| Method Detail |
public void close()
The system automatically invokes this method when the device is shut off. Applications may not assume that the channel is still open once the device is powered on again.
ControlledAccessException - if application control forbids this operation.
public static void deregisterChannel(int channel)
throws IOException
channel - The channel handle.IOException - Thrown if an I/O error occurs.ControlledAccessException - if application control forbids this operation.public static int getConnectionState()
public static int getMaximumRxSize()
throws IOException
IOException - Thrown if an I/O error occurs.ControlledAccessException - if application control forbids this operation.
public static int getMaximumTxSize()
throws IOException
IOException - Thrown if an I/O error occurs.ControlledAccessException - if application control forbids this operation.public static boolean isSupported()
public int read()
throws IOException
IOException - If the port is not currently open.ControlledAccessException - if application control forbids this operation.
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.ControlledAccessException - if application control forbids this operation.
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.ControlledAccessException - if application control forbids this operation.public static int registerChannel(String name, int maxRxSize, int maxTxSize) throws IOException
name - The name of the channel. Note that channel names starting with
"RIM" are reserved for internal use. 3rd party applications registering
a name that starts with "RIM" will receive a ControlledAccessException.maxRxSize - The maximum receive size.maxTxSize - The maximum transmit size.IOException - Thrown if an I/O error occurs.ControlledAccessException - if application control forbids this operation or if
the name of the channel is illegal, as defined above.
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.ControlledAccessException - if application control forbids this operation.
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.ControlledAccessException - if application control forbids this operation.
public int write(int b)
throws IOException
b - Byte of data to send.IOException - If the port is not currently open.ControlledAccessException - if application control forbids this operation.
|
|||||||||
| 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.