-
Notifications
You must be signed in to change notification settings - Fork 5
Discard junk input bytes on creation #19
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
Works for my use case, however according to the |
time.sleep(0.1) | ||
uart.reset_input_buffer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have 2 concerns about this:
- if this is ESP32-S3 specific, this will unnecessarily delay other HW
- if the issue is specific to UART (on ESP32-S3) rather than US-100, the fix should probably reside in CP itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delay only happens once, in the constructor. I could probably make this 2 msecs instead of 100 msecs. I can test that.
Yes, ESP32-S3 should be fixed. I am looking at that. But this makes the library more robust for any case like this where it might get out of sync. And it makes the library usable without having to upgrade CircuitPython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair argument, esp. the second part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Feel free to merge when ready.
Updating https://github.com/adafruit/Adafruit_CircuitPython_US100 to 1.1.17 from 1.1.16: > Merge pull request adafruit/Adafruit_CircuitPython_US100#19 from dhalbert/discard-junk-input > Merge pull request adafruit/Adafruit_CircuitPython_US100#20 from vladak/units Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
adafruit/circuitpython#8887 and https://forums.adafruit.com/viewtopic.php?t=208042, by @vladak, describe a problem caused by the ESP32-S3 reading a single junk byte when a
busio.UART()
is first created.Prevent that problem by waiting long enough for the byte to appear, and then clearing out all the input bytes, so that
.distance
and.temperature
will only read wanted bytes.Also fixes #18 by adding some documentation.
@vladak Could you test? This is like the workaround I gave you, so test without that.