Skip to content

Should arduino::MbedI2C::read() return -1 if there is no data available? #601

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

Closed
carlosperate opened this issue Dec 25, 2022 · 2 comments · Fixed by #605
Closed

Should arduino::MbedI2C::read() return -1 if there is no data available? #601

carlosperate opened this issue Dec 25, 2022 · 2 comments · Fixed by #605
Labels
bug Something isn't working

Comments

@carlosperate
Copy link
Contributor

Assuming arduino/reference-en#897 in the docs repo is correct, it looks like arduino::MbedI2C::read() should be returning -1 instead of 0 at the end of the method:

int arduino::MbedI2C::read() {
if (rxBuffer.available()) {
return rxBuffer.read_char();
}
return 0;
}

As reference, these implementations return -1:

@facchinm
Copy link
Member

facchinm commented Jan 2, 2023

Hi @carlosperate , you are very right indeed 🙂
Would you mind submitting a PR so we can give proper attribution for the fix? Thx

@facchinm facchinm added the bug Something isn't working label Jan 2, 2023
@carlosperate
Copy link
Contributor Author

Sure thing! I'll create one between tonight and tomorrow 👍

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 a pull request may close this issue.

2 participants