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

try_lock increase wait time from 0 to 1 ms #101

Closed
wants to merge 1 commit into from

Conversation

ilario
Copy link

@ilario ilario commented Aug 7, 2024

In the initial code a loop was present inside I2CDevice.__enter__ and I2CDevice.__probe_for_device that was then modified in #91.

I have the issue described in adafruit/Adafruit_CircuitPython_TCA9548A#52: the CPU goes to 100% when the I2C board is not reachable.

Increasing the waiting time from 0 ms to 1 ms decreases the CPU usage of a A64-OLinuXino from 100% to 2%, increasing the battery life during power cuts.

Maybe there is a smarter solution than just increasing the sleep time?

A similar change has also been proposed for the TCA9548A code in adafruit/Adafruit_CircuitPython_TCA9548A#53

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't make this change. Instead, the I2C driver for your SBC should be smarter.

@ilario
Copy link
Author

ilario commented Sep 6, 2024

Please don't make this change.

Ok, closing.

Instead, the I2C driver for your SBC should be smarter.

To me it seems that my SBC (an A64-OLinuXino) is irrelevant here. Can anyone try with another hardware? The while-sleep(0) loop seems the culprit to me.
Looking where the try_lock is defined I got until this, which does not look hardware-related to me:
https://github.com/adafruit/Adafruit_Blinka/blob/1c4358371c4945d08fb208fa83e425f5b1af9d45/src/adafruit_blinka/__init__.py#L64-L69

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

Successfully merging this pull request may close these issues.

2 participants