Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
266 stars 54 forks source link

java.io.IOException: Remote I/O error java.base/java.io.RandomAccessFile.writeBytes(Native Method) #335

Closed taartspi closed 3 months ago

taartspi commented 4 months ago

Using linuxfs-i2c, dependent upon i2c operations this exception can occur. If the program initially uses read or write, and later uses readRegister or writeRegister there is no exception. However if the program initially uses readRegister or writeRegister subsequent write or read may encounter this exception. As a temporary fix, when the program first create the i2c device, a read operation will be performed. It is possible the attached i2c device always performs an auto-increment in which case this additional read operation will increment the device's internal pointer. As a program is not assured the state of any hardware, the program is already responsible to reset the chip or explicitly set such internal registers so this temporary change should show minimal effect. When the proper fix is understood and implemented this 'extra' read will be removed.

eitch commented 4 months ago

I currently see this fix as ok

taartspi commented 3 months ago

Real fix found and implemented Fix will build in snapHot 2.5.2