public class NativeI2CDeviceSysFs extends Object implements I2CSMBusInterface
Native Java implementation of the I2C SMBus commands using sysfs and a single native method to select the slave address.
Reference Kernel I2C dev interface and SMBus Protocol.
Warning Not all methods have been tested!
I2CSMBusInterface.NotSupportedException
MAX_I2C_BLOCK_SIZE
Constructor and Description |
---|
NativeI2CDeviceSysFs(int controller,
int deviceAddress,
boolean force) |
Modifier and Type | Method and Description |
---|---|
byte[] |
blockProcessCall(int register,
byte[] data,
int length)
SMBus Block Write - Block Read Process Call
SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.
|
void |
close() |
short |
processCall(int register,
short data)
SMBus Process Call:
This command selects a device register (through the Comm byte), sends
16 bits of data to it, and reads 16 bits of data in return.
|
byte[] |
readBlockData(int register)
SMBus Block Read: i2c_smbus_read_block_data()
This command reads a block of up to 32 bytes from a device, from a
designated register that is specified through the Comm byte.
|
byte |
readByte()
SMBus Receive Byte: i2c_smbus_read_byte()
This reads a single byte from a device, without specifying a device
register.
|
byte |
readByteData(int register)
SMBus Read Byte: i2c_smbus_read_byte_data()
This reads a single byte from a device, from a designated register.
|
byte[] |
readBytes(int length) |
byte[] |
readI2CBlockData(int register,
int length)
I2C Block Read: i2c_smbus_read_i2c_block_data()
This command reads a block of bytes from a device, from a
designated register that is specified through the Comm byte.
|
short |
readWordData(int register)
SMBus Read Word: i2c_smbus_read_word_data()
This operation is very like Read Byte; again, data is read from a
device, from a designated register that is specified through the Comm
byte.
|
void |
writeBlockData(int register,
byte[] data)
SMBus Block Write: i2c_smbus_write_block_data()
The opposite of the Block Read command, this writes up to 32 bytes to
a device, to a designated register that is specified through the
Comm byte.
|
void |
writeByte(byte data)
SMBus Send Byte: i2c_smbus_write_byte()
This operation is the reverse of Receive Byte: it sends a single byte
to a device.
|
void |
writeByteData(int register,
byte data)
SMBus Write Byte: i2c_smbus_write_byte_data()
This writes a single byte to a device, to a designated register.
|
void |
writeBytes(byte[] data) |
void |
writeI2CBlockData(int register,
byte[] data)
I2C Block Write: i2c_smbus_write_i2c_block_data()
The opposite of the Block Read command, this writes bytes to
a device, to a designated register that is specified through the
Comm byte.
|
void |
writeWordData(int register,
short data)
SMBus Write Word: i2c_smbus_write_word_data()
This is the opposite of the Read Word operation.
|
public NativeI2CDeviceSysFs(int controller, int deviceAddress, boolean force)
public void close()
close
in interface I2CSMBusInterface
close
in interface Closeable
close
in interface AutoCloseable
public byte readByte()
I2CSMBusInterface
readByte
in interface I2CSMBusInterface
public void writeByte(byte data)
I2CSMBusInterface
writeByte
in interface I2CSMBusInterface
data
- value to writepublic byte[] readBytes(int length)
readBytes
in interface I2CSMBusInterface
public void writeBytes(byte[] data)
writeBytes
in interface I2CSMBusInterface
public byte readByteData(int register)
I2CSMBusInterface
readByteData
in interface I2CSMBusInterface
register
- the register to read frompublic void writeByteData(int register, byte data)
I2CSMBusInterface
writeByteData
in interface I2CSMBusInterface
register
- the register to write todata
- value to writepublic short readWordData(int register)
I2CSMBusInterface
readWordData
in interface I2CSMBusInterface
register
- the register to read frompublic void writeWordData(int register, short data)
I2CSMBusInterface
writeWordData
in interface I2CSMBusInterface
register
- the register to write todata
- value to writepublic short processCall(int register, short data)
I2CSMBusInterface
processCall
in interface I2CSMBusInterface
register
- the register to write to / read fromdata
- value to writepublic byte[] readBlockData(int register)
I2CSMBusInterface
readBlockData
in interface I2CSMBusInterface
register
- the register to read frompublic void writeBlockData(int register, byte[] data)
I2CSMBusInterface
writeBlockData
in interface I2CSMBusInterface
register
- the register to write todata
- values to writepublic byte[] blockProcessCall(int register, byte[] data, int length)
I2CSMBusInterface
blockProcessCall
in interface I2CSMBusInterface
register
- the register to write todata
- data to writelength
- Lengthpublic byte[] readI2CBlockData(int register, int length)
I2CSMBusInterface
readI2CBlockData
in interface I2CSMBusInterface
register
- the register to read fromlength
- amount of data to readpublic void writeI2CBlockData(int register, byte[] data)
I2CSMBusInterface
writeI2CBlockData
in interface I2CSMBusInterface
register
- the register to write todata
- values to writeCopyright © 2016–2017 mattjlewis. All rights reserved.