Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C writeRead method #388

Open
kasperski12 opened this issue Sep 30, 2024 · 0 comments
Open

I2C writeRead method #388

kasperski12 opened this issue Sep 30, 2024 · 0 comments

Comments

@kasperski12
Copy link

kasperski12 commented Sep 30, 2024

Hi all
I think that there is bug in default implementation of writeRead method in I2c.java

default int writeRead(byte[] writeBuffer, int writeSize, int writeOffset, byte[] readBuffer, int readSize,
        int readOffset) {
        return execute(() -> {
            int written = write(writeBuffer, writeOffset, writeSize);
            if (written != writeOffset)
                throw new IllegalStateException(
                    "Expected to write " + writeOffset + " bytes but only wrote " + written + " bytes");
            return read(readBuffer, readOffset, readSize);
        });
    }

The if conditions compares written to writeOffset instead of writeSize which is the number of bytes to write.

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

No branches or pull requests

1 participant