Class LinuxFsI2CBus
java.lang.Object
com.pi4j.io.i2c.I2CBusBase
com.pi4j.plugin.linuxfs.provider.i2c.LinuxFsI2CBus
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LinuxFileFile handle for this I2C busprotected final org.slf4j.LoggerLogger for the classFields inherited from class com.pi4j.io.i2c.I2CBusBase
bus, DEFAULT_LOCK_ACQUIRE_TIMEOUT, DEFAULT_LOCK_ACQUIRE_TIMEOUT_UNITS, lockAquireTimeout, lockAquireTimeoutUnit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the file handle for the I2C bus.<R> Rexecute(I2C i2c, CheckedFunction<LinuxFile, R> action) Executes an action that interacts with the underlying file handle.<R> RExecutes a callable action with the specified I2C device.voidexecuteIOCTL(I2C i2c, long command, ByteBuffer data, IntBuffer offsets) Executes an ioctl command on the I2C device.protected voidselectBusSlave(I2C i2c) Selects the slave device on the I2C bus, if not already selected.Methods inherited from class com.pi4j.io.i2c.I2CBusBase
_execute
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for the class -
file
File handle for this I2C bus
-
-
Constructor Details
-
LinuxFsI2CBus
Constructs a newLinuxFsI2CBus.- Parameters:
config- the I2C configuration- Throws:
Pi4JException- if the bus cannot be initialized due to missing sysfs or devfs paths
-
-
Method Details
-
execute
Executes a callable action with the specified I2C device.- Type Parameters:
R- the result type of the action- Parameters:
i2c- the I2C deviceaction- the action to perform- Returns:
- the result of the action
- Throws:
Pi4JException- if the action fails
-
execute
Executes an action that interacts with the underlying file handle.- Type Parameters:
R- the result type of the action- Parameters:
i2c- the I2C deviceaction- the action to perform- Returns:
- the result of the action
- Throws:
Pi4JException- if the action fails
-
executeIOCTL
Executes an ioctl command on the I2C device.- Parameters:
i2c- the I2C devicecommand- the ioctl commanddata- the data buffer for the commandoffsets- the offsets buffer- Throws:
Pi4JException- if the ioctl command fails
-
selectBusSlave
Selects the slave device on the I2C bus, if not already selected.- Parameters:
i2c- the I2C device to select- Throws:
IOException- if selecting the device fails
-
close
public void close()Closes the file handle for the I2C bus.
-