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

TinyWireM code requestFrom() incompatible with Wire requestFrom() #13

Open
bperrybap opened this issue May 11, 2017 · 1 comment
Open

Comments

@bperrybap
Copy link

bperrybap commented May 11, 2017

The Wire library function requestFrom() function returns the number of bytes transferred.
The TinyWireM library code function requestFrom() returns a status where zero means success.

The TinyWireM requestFrom() is fundamentally incompatible with the Wire library requestFrom().
Code that expects the Wire API behavior and checks and uses the return value, breaks.
Given that the Adafruit tiny core provides a Wire wrapper for TinyWireM, the API functions need to behave the same as Wire.

The fix is pretty simple and isolated to the requestFrom() code in TinyWireM.cpp
I'm not sure if there is any concern about breaking any existing code that is depending on the current behavior.
Unfortunately, there is no magic bullet fix, either code that works with Wire breaks or code the depends on existing TinyWireM behavior of requestFrom() breaks when the code is fixed.

Note that this same issue/bug also affects the TinyWireM library:
https://github.com/adafruit/TinyWireM

@bperrybap
Copy link
Author

Here is the documentation for requestFrom() for further clarity on return values:
https://www.arduino.cc/en/Reference/WireRequestFrom

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