Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
273 stars 57 forks source link

[Major] I2C extensions, fixed and cleanup #351

Closed eitch closed 5 months ago

eitch commented 5 months ago

Added a I2C.execute(Callable) method, allowing to atomically execute multiple I2C calls in a thread safe way

Added I2C.writeRead(byte[], byte[]) methods to atomically perform a write and then immediately afterwards a read on the I2C bus.

Fixed an issue where the LinuxFsI2CBus was closed when closing an I2C device - This was wrong, as another device might still be open on the same bus, and an operation on the underlying RandomAccessFile would lead to exceptions

Fixed the workaround requiring an I2C.read() on a newly created LinuxFsI2C device, if the first call was an ioctl - The device was not selected prior to the ioctl call.

Additional code cleanup, more to come in an additional commit

eitch commented 5 months ago

@taartspi the new I2CBus is to enable the execute() method on the I2C class. Thus allowing to perform a call with multiple read/writes atomically

eitch commented 5 months ago

Rebased with develop after the other I2C changes

eitch commented 5 months ago

@FDelporte should we merge?