-
Notifications
You must be signed in to change notification settings - Fork 11
Added error handling #6
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
Conversation
- Changed protos for all functions with Wire failure potential. - Added fcn exits for Wire failures. - Added local timeout for measurement fcn. - Added retry limit.
Thank you for this! Much better with your improvements. But do please explain how the retries line works. We realize it works just fine, but how? It has me and a few fellow engineers debating post increment variable tests. |
Hi @nseidle, thanks so much for merging I think this will save people a lot of work down the road. The retries line works because post-(in/de)crement operators execute after the variable is used in the conditional statement. pre-(in/de)crement operators execute before the variable is used. More here: https://www.geeksforgeeks.org/pre-increment-and-post-increment-in-c/ =] |
Thank you! We assumed this but that doesn't explain how we see x stopping at 255. uint_8 wraps at 255 so: x = 254 x = 255 x = 0 I know this doesn't reflect reality, but what am I missing? |
Durrr yeah I made the assumption the number of retries would never be set to such a high number, so it should break under that condition! 😅 |
I am even more confused. The number of retries is not set as far as I can see. I assumed you were relying on a roll-over trick to cap the retries at 255. Am I mistaken? What was your intent with the retries line? |
I define retries as 3 here: https://github.com/sparkfun/SparkFun_AS726X_Arduino_Library/blob/master/src%2FAS726X.h#L172 Other than that, I dunno! |
Ah! Now I see you basically have a typo but got really lucky :)
should be
We just got lucky that (retries++ > retries) fails at 255 and not infinity. I'll fix it. |
Oh boy, thanks for catching that! Now to make sure I'm not doing the same in my production code... As an aside, I remember talking directly to you over email sometime when I was in college (2001-2005). I'm thrilled to see how SparkFun has become bedrock for the embedded community, and how responsive the team still is 20 years later. =] |
Np! Crazy! I'm pleased (and just as shocked as you are!) that we're still around. Thanks again for helping out the open source world. Let us know if anything else pops up. |
I found many avenues where this library could lock the system and patched them so we can always return.