Skip to content

I2C error after soft reboot #14

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

Closed
BrianPugh opened this issue Jan 14, 2021 · 4 comments
Closed

I2C error after soft reboot #14

BrianPugh opened this issue Jan 14, 2021 · 4 comments

Comments

@BrianPugh
Copy link
Contributor

I am having a very similar issue outlined in this issue:
adafruit/circuitpython#2060

Essentially, I am able to communicate with the VEML7700 on first boot from my nRF52840, but subsequent soft reboots (such as during code reloads) cause the traceback as follows:

>>> veml7700 = adafruit_veml7700.VEML7700(i2c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/adafruit_veml7700.py", line 207, in __init__
  File "adafruit_register/i2c_bit.py", line 70, in __set__
  File "adafruit_register/i2c_bit.py", line 65, in __set__
  File "adafruit_bus_device/i2c_device.py", line 143, in write_then_readinto
OSError: [Errno 19] Unsupported operation

Through experimentation, I have found that this can be mitigated by replacing this line:

self.light_shutdown = False # Enable the ambient light sensor

with:

try:
    self.light_shutdown = False
except OSError:
    self.light_shutdown = False

On a cold boot, the first self.light_shutdown = False works successfully. On subsequent soft reboots, it will fail with the traceback previously mentioned; however, running the command again always works. I guess maybe the first attempt flushs some buffer or fixes some invalid state?

I can make a PR if convenient, but just checking if this maybe is just a symptom of an upstream bug that should be fixed instead.

@ladyada
Copy link
Member

ladyada commented Jan 14, 2021

hi idea is good! for implementation i think better to perhaps have a loop where it tries 3 times to enable, and if it does not enable (else: at the end of the for loop) it throws a runtime error

@BrianPugh
Copy link
Contributor Author

cool! I'll make a PR soon with this change

@BrianPugh
Copy link
Contributor Author

closing since PR15 has been merged

@jposada202020
Copy link
Contributor

@BrianPugh Thanks :)

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

3 participants