Package com.pi4j.io.i2c
Interface I2CDevice
- 
- All Known Implementing Classes:
- I2CDeviceImpl
 
 public interface I2CDeviceThis is abstraction of an i2c device. It allows data to be read or written to the device.- Author:
- Daniel Sendula, refactored by RasPelikan
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetAddress()voidioctl(long command, int value)Runs an ioctl on this device.voidioctl(long command, ByteBuffer data, IntBuffer offsets)Runs an ioctl on this device.intread()This method reads one byte from the i2c device.intread(byte[] buffer, int offset, int size)This method reads bytes directly from the i2c device to given buffer at asked offset.intread(byte[] writeBuffer, int writeOffset, int writeSize, byte[] readBuffer, int readOffset, int readSize)This method writes and reads bytes to/from the i2c device in a single method callintread(int address)This method reads one byte from the i2c device.intread(int address, byte[] buffer, int offset, int size)This method reads bytes from the i2c device to given buffer at asked offset.voidwrite(byte b)This method writes one byte directly to i2c device.voidwrite(byte[] buffer)This method writes all bytes included in the given buffer directly to the i2c device.voidwrite(byte[] buffer, int offset, int size)This method writes several bytes directly to the i2c device from given buffer at given offset.voidwrite(int address, byte b)This method writes one byte to i2c device.voidwrite(int address, byte[] buffer)This method writes all bytes included in the given buffer directory to the register address on the i2c devicevoidwrite(int address, byte[] buffer, int offset, int size)This method writes several bytes to the i2c device from given buffer at given offset.
 
- 
- 
- 
Method Detail- 
getAddressint getAddress() - Returns:
- The address for which this instance is constructed for.
 
 - 
writevoid write(byte b) throws IOExceptionThis method writes one byte directly to i2c device.- Parameters:
- b- byte to be written
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
writevoid write(byte[] buffer, int offset, int size) throws IOExceptionThis method writes several bytes directly to the i2c device from given buffer at given offset.- Parameters:
- buffer- buffer of data to be written to the i2c device in one go
- offset- offset in buffer
- size- number of bytes to be written
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
writevoid write(byte[] buffer) throws IOExceptionThis method writes all bytes included in the given buffer directly to the i2c device.- Parameters:
- buffer- buffer of data to be written to the i2c device in one go
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
writevoid write(int address, byte b) throws IOExceptionThis method writes one byte to i2c device.- Parameters:
- address- local address in the i2c device
- b- byte to be written
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
writevoid write(int address, byte[] buffer, int offset, int size) throws IOExceptionThis method writes several bytes to the i2c device from given buffer at given offset.- Parameters:
- address- local address in the i2c device
- buffer- buffer of data to be written to the i2c device in one go
- offset- offset in buffer
- size- number of bytes to be written
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
writevoid write(int address, byte[] buffer) throws IOExceptionThis method writes all bytes included in the given buffer directory to the register address on the i2c device- Parameters:
- address- local address in the i2c device
- buffer- buffer of data to be written to the i2c device in one go
- Throws:
- IOException- thrown in case byte cannot be written to the i2c device or i2c bus
 
 - 
readint read() throws IOException This method reads one byte from the i2c device. Result is between 0 and 255 if read operation was successful, else a negative number for an error.- Returns:
- byte value read: positive number (or zero) to 255 if read was successful. Negative number if reading failed.
- Throws:
- IOException- thrown in case byte cannot be read from the i2c device or i2c bus
 
 - 
readint read(byte[] buffer, int offset, int size) throws IOExceptionThis method reads bytes directly from the i2c device to given buffer at asked offset.- Parameters:
- buffer- buffer of data to be read from the i2c device in one go
- offset- offset in buffer
- size- number of bytes to be read
- Returns:
- number of bytes read
- Throws:
- IOException- thrown in case byte cannot be read from the i2c device or i2c bus
 
 - 
readint read(int address) throws IOException This method reads one byte from the i2c device. Result is between 0 and 255 if read operation was successful, else a negative number for an error.- Parameters:
- address- local address in the i2c device
- Returns:
- byte value read: positive number (or zero) to 255 if read was successful. Negative number if reading failed.
- Throws:
- IOException- thrown in case byte cannot be read from the i2c device or i2c bus
 
 - 
readint read(int address, byte[] buffer, int offset, int size) throws IOExceptionThis method reads bytes from the i2c device to given buffer at asked offset.- Parameters:
- address- local address in the i2c device
- buffer- buffer of data to be read from the i2c device in one go
- offset- offset in buffer
- size- number of bytes to be read
- Returns:
- number of bytes read
- Throws:
- IOException- thrown in case byte cannot be read from the i2c device or i2c bus
 
 - 
ioctlvoid ioctl(long command, int value) throws IOExceptionRuns an ioctl on this device.- Throws:
- IOException
- See Also:
- LinuxFile.ioctl(long, int)
 
 - 
ioctlvoid ioctl(long command, ByteBuffer data, IntBuffer offsets) throws IOExceptionRuns an ioctl on this device.- Throws:
- IOException
- See Also:
- LinuxFile.ioctl(long, ByteBuffer, IntBuffer)
 
 - 
readint read(byte[] writeBuffer, int writeOffset, int writeSize, byte[] readBuffer, int readOffset, int readSize) throws IOExceptionThis method writes and reads bytes to/from the i2c device in a single method call- Parameters:
- writeBuffer- buffer of data to be written to the i2c device in one go
- writeOffset- offset in write buffer
- writeSize- number of bytes to be written from buffer
- readBuffer- buffer of data to be read from the i2c device in one go
- readOffset- offset in read buffer
- readSize- number of bytes to be read
- Returns:
- number of bytes read
- Throws:
- IOException- thrown in case byte cannot be read from the i2c device or i2c bus
 
 
- 
 
-