Oracle Java Wireless Client

com.oracle.deviceaccess.i2cbus
Class I2CManager

java.lang.Object
  extended by com.oracle.deviceaccess.i2cbus.I2CManager

public class I2CManager
extends java.lang.Object

The I2CManager class provides methods for getting I2CSlave instances using its platform-specific unique numerical ID or name.

In order to communicate with a specific slave, an application should first acquire an 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).

See Also:
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

getSlave

public static I2CSlave getSlave(int id)
                         throws java.io.IOException,
                                PeripheralTypeNotSupportedException,
                                PeripheralNotFoundException,
                                PeripheralNotAvailableException
Gets an I2CSlave instance for the given ID. A new instance is returned upon each call.

Parameters:
id - the I2C slave ID.
Returns:
an I2CSlave instance for the given ID.
Throws:
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.

getSlave

public static I2CSlave getSlave(java.lang.String name)
                         throws java.io.IOException,
                                PeripheralTypeNotSupportedException,
                                PeripheralNotFoundException,
                                PeripheralNotAvailableException
Gets an I2CSlave instance for the given name. A new instance is returned upon each call.

Parameters:
name - the I2C slave's name.
Returns:
an I2CSlave instance for the given name.
Throws:
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

Copyright (c) 1990, 2012, Oracle and/or its affiliates. All rights reserved.