public class I2CFactory extends Object
I2CBus
interface.Modifier and Type | Class and Description |
---|---|
static class |
I2CFactory.UnsupportedBusNumberException |
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_LOCKAQUIRE_TIMEOUT |
static TimeUnit |
DEFAULT_LOCKAQUIRE_TIMEOUT_UNITS |
Modifier and Type | Method and Description |
---|---|
static int[] |
getBusIds()
Fetch all available I2C bus numbers from sysfs.
|
static I2CBus |
getInstance(int busNumber)
Create new I2CBus instance.
|
static I2CBus |
getInstance(int busNumber,
long lockAquireTimeout,
TimeUnit lockAquireTimeoutUnit)
Create new I2CBus instance.
|
static void |
setFactory(I2CFactoryProvider factoryProvider)
allow changing the provider for the factory
|
public static final long DEFAULT_LOCKAQUIRE_TIMEOUT
public static final TimeUnit DEFAULT_LOCKAQUIRE_TIMEOUT_UNITS
public static I2CBus getInstance(int busNumber) throws I2CFactory.UnsupportedBusNumberException, IOException
The timeout for locking the bus for exclusive communication is set to DEFAULT_LOCKAQUIRE_TIMEOUT.
busNumber
- The bus numberI2CFactory.UnsupportedBusNumberException
- If the given bus-number is not supported by the underlying systemIOException
- If communication to i2c-bus failsDEFAULT_LOCKAQUIRE_TIMEOUT
,
DEFAULT_LOCKAQUIRE_TIMEOUT_UNITS
public static I2CBus getInstance(int busNumber, long lockAquireTimeout, TimeUnit lockAquireTimeoutUnit) throws I2CFactory.UnsupportedBusNumberException, IOException
busNumber
- The bus numberlockAquireTimeout
- The timeout for locking the bus for exclusive communicationlockAquireTimeoutUnit
- The units of lockAquireTimeoutI2CFactory.UnsupportedBusNumberException
- If the given bus-number is not supported by the underlying systemIOException
- If communication to i2c-bus failspublic static void setFactory(I2CFactoryProvider factoryProvider)
factoryProvider
- public static int[] getBusIds() throws IOException
IOException
- If fetching from sysfs interface failsCopyright © 2012–2019 Pi4J. All rights reserved.