arduino-mcp23017 icon indicating copy to clipboard operation
arduino-mcp23017 copied to clipboard

Don't hide I2C error status.

Open dok-net opened this issue 2 years ago • 1 comments

Prior to this PR, most functions in the MCP23017 API fail silently, despite the I2C Wire libs error status return code. Now, like other I2C slave driver libs, the return type is bool instead of void, so the user can determine the success of the operations.

dok-net avatar Jun 25 '22 08:06 dok-net

I'm sorry, the PR obviously isn't finished yet. I missed that over a weekend or something. Still good to have your views on the matter in general. I think I will improve the patch until all functions that are still void return an error flag. Other libs for I2C devices face the same ambiguity between the functions that can have an error return, and those that return values when successful. Perhaps we could agree on adding an error state to the class which can be polled, and closes the gap on the functions that cannot return the state directly? It's all non-reentrant anyway. I don't agree that it's for debugging the software, because there can be hardware problems that the software developer otherwise might miss for awhile. So hiding error conditions is never a good idea, even doing it imperfectly is better that no error reporting at all.

dok-net avatar Jun 28 '22 20:06 dok-net