Skip to content

Commit

Permalink
Merge pull request #336 from taartspi/linuxi2c_ioexception
Browse files Browse the repository at this point in the history
Temporary fix for linuxfs-i2c  IOException. Also fix return code for …
  • Loading branch information
eitch authored Mar 15, 2024
2 parents 61fb5cb + 34d854e commit 8119be5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public int readRegister(byte[] register, byte[] buffer, int offset, int length)
buffer[i] = ioctlData.get(readBuffPosition +i );
; }

return (ioctlData.limit());
return (readLength);
}


Expand All @@ -330,8 +330,6 @@ public int writeReadRegisterWord(int register, int word) {
reg[1] = (byte) (word & 0xff);
reg[2] = (byte) ((word >> 8) & 0xff);
byte buff[] = new byte[2];

int rCode = this.readRegister(reg, buff, 0, buff.length);
word = (buff[1] << 8) | buff[0];
return word;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public synchronized I2C create(I2CConfig config) {
LinuxFsI2CBus i2CBus = this.i2CBusMap.computeIfAbsent(config.getBus(), busNr -> new LinuxFsI2CBus(config));
// create new I/O instance based on I/O config
LinuxFsI2C i2C = new LinuxFsI2C(i2CBus, this, config);
// Workaround, needed if first LinuxFsI2C usage is ioctl (readRegister or writeRegister)
i2C.read();
this.context.registry().add(i2C);
return i2C;
}
Expand Down

0 comments on commit 8119be5

Please sign in to comment.