Skip to content

Simplify Module::read() after requestFrom() - #81

Open
n3orma wants to merge 1 commit into
arduino-libraries:mainfrom
n3orma:patch-4
Open

n3orma wants to merge 1 commit into
arduino-libraries:mainfrom
n3orma:patch-4

Conversation

@n3orma

@n3orma n3orma commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #72

This PR updates Module::read() to use the return value of requestFrom() directly.

Module::read() requests howmany + 1 bytes in total:

1 byte for the pinstrap address

howmany bytes for the requested module data

Previously, the function only checked whether at least howmany bytes were available, which did not account for the extra pinstrap address byte.

The updated code verifies that all howmany + 1 expected bytes were received before reading them. It also removes the unnecessary wait loop after requestFrom() and the extra receive-buffer clearing loop.

If fewer than howmany + 1 bytes are received, the function now returns false.

Refactor I2C request handling to improve readability and efficiency.
@per1234 per1234 added the bug Something isn't working label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No need to wait after Wire.requestFrom().

2 participants