|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.oracle.deviceaccess.i2cbus.I2CManager
public class I2CManager
The I2CManager
class provides methods for getting I2CSlave
instances using its platform-specific unique numerical ID or name.
I2CSlave
instance for the I2C slave device the application
wants to exchange data with, either using its numerical ID or name.
I2CSlave slave = I2CManager.getSlave(3); // using its ID
Or,
I2CSlave slave = I2CManager.getSlave("ADC1"); // using its name
Once the peripheral acquired, the application can exchange data with the I2C
slave device using methods of the I2CSlave
interface such as the
writeThenRead()
method.
slave.writeThenRead(sndBuf, 0, 1, rcvBuf, 0, 1);
When the data exchange is over, the application should call the
Peripheral.close()
method to release I2C slave device.
slave.close();
Acquiring an I2CSlave
instance is subject to permission checks (see
I2CPermission
).
I2CSlave
,
I2CPermission
,
PeripheralTypeNotSupportedException
Method Summary | |
static I2CSlave |
getSlave(int id)
Gets an I2CSlave instance for the given ID. |
static I2CSlave |
getSlave(java.lang.String name)
Gets an I2CSlave instance for the given name. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static I2CSlave getSlave(int id) throws java.io.IOException, PeripheralTypeNotSupportedException, PeripheralNotFoundException, PeripheralNotAvailableException
I2CSlave
instance for the given ID. A new instance is returned upon each call.
id
- the I2C slave ID.
I2CSlave
instance for the given ID.
java.io.IOException
- if any I/O error occurred.
PeripheralTypeNotSupportedException
- if I2C is not supported.
PeripheralNotFoundException
- if the designated I2C slave device is not found.
PeripheralNotAvailableException
- if the peripheral is not currently available.
java.lang.SecurityException
- if the caller has no permission to access the designated I2C
slave.
java.lang.IllegalArgumentException
- if id
is not greater than or equal to 0
.public static I2CSlave getSlave(java.lang.String name) throws java.io.IOException, PeripheralTypeNotSupportedException, PeripheralNotFoundException, PeripheralNotAvailableException
I2CSlave
instance for the given name. A new instance is returned upon each call.
name
- the I2C slave's name.
I2CSlave
instance for the given name.
java.io.IOException
- if any I/O error occurred.
PeripheralTypeNotSupportedException
- if I2C is not supported.
PeripheralNotFoundException
- if the designated I2C slave device is not found.
PeripheralNotAvailableException
- if the peripheral is not currently available.
java.lang.SecurityException
- if the caller has no permission to access the designated I2C
slave.
java.lang.NullPointerException
- if name
is null
.
|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |