Skip to content

Implement defaults for missing I2C methods based on writeThenRead - #744

Merged
stefanhaustein merged 1 commit into
Pi4J:mainfrom
stefanhaustein:main
Aug 17, 2026
Merged

Implement defaults for missing I2C methods based on writeThenRead #744
stefanhaustein merged 1 commit into
Pi4J:mainfrom
stefanhaustein:main

Conversation

@stefanhaustein

@stefanhaustein stefanhaustein commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

-- or what else is available and fits, so actual implementations only need to implement writeThenRead.

(addressing a todo in the mcp2221 bridge, which can be simplified (together with ffm)) accordingly.

…what else is available and fits, so actual implementations only need to implement writeThenRead. Will look into ffm simplifications in a followup
@stefanhaustein
stefanhaustein requested a review from eitch August 17, 2026 17:44
* @return the value returned by the action
*/
<T> T execute(Callable<T> action);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on the plan to reduce what is implemented in providers. We need to force any i2c provider to implement

   default void writeThenRead(byte[] writeBuffer, int writeOffset, int writeSize, int readDelayNanos, byte[] readBuffer, int readOffset, int readSize) {

The default implementation is not correct. This is meant to be a start- write-restart-read-stop, a single atomic operation. When I tested FFM it was doing a single operation, we need to force the next implementation too do the same.
Can this single method be marked abstract to force its implementation ?

@stefanhaustein stefanhaustein Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's do this in a followup where we switch over ffm to only implement this method and make it abstract in an atomic small change

EDIT: Expanding defaults and fixing implementations can be seen as two two different steps, that's why I'd prefer to keep them separated. And cleaning up implementations is probably easier when we have all the defaults in place.

@taartspi taartspi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree we do make my SUG item next round

@stefanhaustein
stefanhaustein merged commit 0574324 into Pi4J:main Aug 17, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants