-
Notifications
You must be signed in to change notification settings - Fork 10
Clearer error printout for I2C communication error #13
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ladyada
approved these changes
Mar 8, 2022
looks ok to me @caternuson can also take a look |
Oh yah, that issue. Thanks for picking this up and PRing a fix. LGTM. Even tested. Did black change the long string message syntax to be multi-line? Looks like it's adding a bunch of white space. BEFORE Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
0
>>> scd4x.altitude = 42
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 284, in altitude
File "/lib/adafruit_scd4x.py", line 307, in _send_command
OSError: [Errno 5] Input/output error
>>> AFTER Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 302, in altitude
File "/lib/adafruit_scd4x.py", line 329, in _send_command
RuntimeError: Could not communicate via I2C, some commands/settings unavailable while in working mode
>>> |
Thanks for testing! I think I botched how I accounted for breaking up the string, this new commit should fix that whitespace. |
Yep. Looks good: Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_scd4x
>>> scd4x = adafruit_scd4x.SCD4X(board.I2C())
>>> scd4x.altitude
42
>>> scd4x.start_periodic_measurement()
>>> scd4x.altitude
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_scd4x.py", line 302, in altitude
File "/lib/adafruit_scd4x.py", line 329, in _send_command
RuntimeError: Could not communicate via I2C, some commands/settings unavailable while in working mode
>>> |
caternuson
approved these changes
Mar 8, 2022
adafruit-adabot
added a commit
to adafruit/Adafruit_CircuitPython_Bundle
that referenced
this pull request
Mar 10, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_SCD4X to 1.3.0 from 1.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_SCD4X#13 from tekktrik/dev/clearer-i2c-failure > Fixed readthedocs build > Post-patch cleanup > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_MIDI to 1.4.7 from 1.4.6: > Merge pull request adafruit/Adafruit_CircuitPython_MIDI#48 from tekktrik/dev/expose-velocity-attr > Fixed readthedocs build > Consolidate Documentation sections of README
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #10 by:
OSError
into aRuntimeError
that explains that some commands are unavailable in working mode. Still mentions it as an I2C communication just in case it really isstart_periodic_measurement()
(and a reference to that instart_low_periodic_measurement()
) to help clarify.Not tested yet, but wanted to know if this is the right solution