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

Endless hang when the light sensor is not connected or not responding #5

Closed
Abestanis opened this issue Apr 30, 2022 · 1 comment · Fixed by #7
Closed

Endless hang when the light sensor is not connected or not responding #5

Abestanis opened this issue Apr 30, 2022 · 1 comment · Fixed by #7
Assignees
Labels
Grove_Digital_Light_Sensor Label for Grove_Digital_Light_Sensor UAY Unassigned yet

Comments

@Abestanis
Copy link
Contributor

Hello, thank you for this awesome library!

I recently used it in a project, but I had to make some adjustments to the code, because I observed the following behavior:
I'm calling TSL2561_CalculateLux::readIRLuminosity which would never return, if the light sensor wasn't connected to the Arduino. This happened often during development, when the system was only partially assembled and it could have happened in the field, if a cable got loose or if the light sensor somehow wouldn't respond.

The reason for the hang is the following loop in TSL2561_CalculateLux::readRegister:

while (!Wire.available());

If the light sensor never responds, Wire.available() will never return true, making the loop an endless loop.

For this reason, I added a timeout to the while loop and set an error flag on the TSL2561_CalculateLux in the event of a timeout, which my code could check.

Would you be willing to accept a pull request which adds a timeout and some way to detect the timeout?

@lakshanthad
Copy link
Contributor

Hello,

Please PR and I will check it.

Thank you.

@MatthewJeffson MatthewJeffson added UAY Unassigned yet Grove_Digital_Light_Sensor Label for Grove_Digital_Light_Sensor labels Oct 9, 2024
@Lesords Lesords self-assigned this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Grove_Digital_Light_Sensor Label for Grove_Digital_Light_Sensor UAY Unassigned yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants