sysfs: Should fix #272 by using first byte of data as command register for I2C reads
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
12a6d4dda6
commit
c432f50ae0
|
@ -94,12 +94,17 @@ func (d *i2cDevice) Read(b []byte) (n int, err error) {
|
|||
return d.file.Read(b)
|
||||
}
|
||||
|
||||
data := make([]byte, len(b)+1)
|
||||
data[0] = byte(len(b))
|
||||
// Command byte - a data byte which often selects a register on the device:
|
||||
// https://www.kernel.org/doc/Documentation/i2c/smbus-protocol
|
||||
command := byte(b[0])
|
||||
buf := b[1:]
|
||||
data := make([]byte, len(buf)+1)
|
||||
data[0] = byte(len(buf))
|
||||
copy(data[1:], buf)
|
||||
|
||||
smbus := &i2cSmbusIoctlData{
|
||||
readWrite: I2C_SMBUS_READ,
|
||||
command: 0,
|
||||
command: command,
|
||||
size: I2C_SMBUS_I2C_BLOCK_DATA,
|
||||
data: uintptr(unsafe.Pointer(&data[0])),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue