public class I2CBusImpl extends Object implements I2CBus
| Modifier and Type | Field and Description | 
|---|---|
| protected int | busNumberUsed to identifiy the i2c bus within Pi4J | 
| protected LinuxFile | fileFile handle for this i2c bus | 
| protected String | filenameFile name of this i2c bus | 
| protected int | lastAddress | 
| protected long | lockAquireTimeout | 
| protected TimeUnit | lockAquireTimeoutUnit | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | I2CBusImpl(int busNumber,
          String fileName,
          long lockAquireTimeout,
          TimeUnit lockAquireTimeoutUnit)Constructor of i2c bus implementation. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Closes this i2c bus. | 
| int | getBusNumber() | 
| I2CDevice | getDevice(int address)Returns i2c device implementation ( I2CDeviceImpl). | 
| void | ioctl(I2CDevice device,
     long command,
     ByteBuffer values,
     IntBuffer offsets) | 
| void | ioctl(I2CDevice device,
     long command,
     int value) | 
| protected void | open()Opens the bus. | 
| int | readByte(I2CDevice device,
        int localAddress) | 
| int | readByteDirect(I2CDevice device) | 
| int | readBytes(I2CDevice device,
         int localAddress,
         int size,
         int offset,
         byte[] buffer) | 
| int | readBytesDirect(I2CDevice device,
               int size,
               int offset,
               byte[] buffer) | 
| <T> T | runBusLockedDeviceAction(I2CDevice device,
                        Callable<T> action)Selects a device on the bus for an action, and locks parallel access around file descriptor operations. | 
| protected void | selectBusSlave(I2CDevice device)Selects the slave device if not already selected on this bus. | 
| protected void | testForProperOperationConditions(I2CDevice device) | 
| String | toString() | 
| int | writeAndReadBytesDirect(I2CDevice device,
                       int writeSize,
                       int writeOffset,
                       byte[] writeBuffer,
                       int readSize,
                       int readOffset,
                       byte[] readBuffer) | 
| void | writeByte(I2CDevice device,
         int localAddress,
         byte data) | 
| void | writeByteDirect(I2CDevice device,
               byte data) | 
| void | writeBytes(I2CDevice device,
          int localAddress,
          int size,
          int offset,
          byte[] buffer) | 
| void | writeBytesDirect(I2CDevice device,
                int size,
                int offset,
                byte[] buffer) | 
protected int lastAddress
protected int busNumber
protected long lockAquireTimeout
protected TimeUnit lockAquireTimeoutUnit
protected I2CBusImpl(int busNumber, String fileName, long lockAquireTimeout, TimeUnit lockAquireTimeoutUnit)
busNumber - used to identifiy the i2c bus within Pi4JIOException - thrown in case that file cannot be openedpublic I2CDevice getDevice(int address) throws IOException
I2CDeviceImpl).getDevice in interface I2CBusaddress - address of i2c deviceIOException - never in this implementationprotected void open() throws IOException
IOException - thrown in case there are problems opening the i2c bus.public void close() throws IOException
close in interface I2CBusIOException - never in this implementationpublic int readByteDirect(I2CDevice device) throws IOException
IOExceptionpublic int readBytesDirect(I2CDevice device, int size, int offset, byte[] buffer) throws IOException
IOExceptionpublic int readByte(I2CDevice device, int localAddress) throws IOException
IOExceptionpublic int readBytes(I2CDevice device, int localAddress, int size, int offset, byte[] buffer) throws IOException
IOExceptionpublic void writeByteDirect(I2CDevice device, byte data) throws IOException
IOExceptionpublic void writeBytesDirect(I2CDevice device, int size, int offset, byte[] buffer) throws IOException
IOExceptionpublic void writeByte(I2CDevice device, int localAddress, byte data) throws IOException
IOExceptionpublic void writeBytes(I2CDevice device, int localAddress, int size, int offset, byte[] buffer) throws IOException
IOExceptionpublic int writeAndReadBytesDirect(I2CDevice device, int writeSize, int writeOffset, byte[] writeBuffer, int readSize, int readOffset, byte[] readBuffer) throws IOException
IOExceptionpublic void ioctl(I2CDevice device, long command, int value) throws IOException
IOExceptionpublic void ioctl(I2CDevice device, long command, ByteBuffer values, IntBuffer offsets) throws IOException
IOExceptionpublic <T> T runBusLockedDeviceAction(I2CDevice device, Callable<T> action) throws IOException
The timeout used for the acquisition of the lock may be defined on getting the I2CBus from I2CFactory.
The 'run'-method of 'action' may throw an 'IOExceptionWrapperException' to wrap IOExceptions. The wrapped IOException is unwrapped by this method and rethrown as IOException.
T - The result-type of the methoddevice - Device to be selected on the busaction - The action to be runRuntimeException - thrown by the custom codeIOException - see method description aboveI2CFactory.getInstance(int, long, java.util.concurrent.TimeUnit)protected void selectBusSlave(I2CDevice device) throws IOException
device - Device to selectIOExceptionprotected void testForProperOperationConditions(I2CDevice device) throws IOException
IOExceptionpublic int getBusNumber()
getBusNumber in interface I2CBusCopyright © 2012–2019 Pi4J. All rights reserved.