-
Notifications
You must be signed in to change notification settings - Fork 11
MemoryError on scan() when nothing is attached to bus #7
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
Comments
The scan currently has no limit check. It would be pretty easy to add one, but not sure what the max value should be. Maybe just set it to something sane, Probably related: |
max 10 is plenty! |
Just add a property? import board
from adafruit_onewire.bus import OneWireBus
ow_bus = OneWireBus(board.D5)
# scan for up to max number of devices, throw error if more are discovered
ow_bus.scan()
# if more actually exist, reset the limit
ow_bus.maximum_devices = 20 |
yep thats fine |
PR'd it up: #9 |
For now, fixed with #9. |
@caternuson Why was the solution to add a limit when there is nothing on the bus? Shouldn't we return an empty list in that case? |
@tannewt Can't remember exactly, but I think maybe it was because the scan can't distinguish between connected devices and not connected devices, so with nothing connected, it runs open ended. |
For my own notes since I know I'll be back here eventually: No attached devices, data pull-up resistor present => empty list returned. No attached devices, data pin floating => hits the max limit. So I think it's to do with the bus idle state being incorrect. |
When no sensor is attached to the OneWire bus on calling scan() a MemoryError occurs:
I tested this on a Trinket M0, Feather M0 express and Feather M0 basic with CircuitPython 2.2.0, 2.3.1 and the 3.0 beta.
I tested the negative (with sensor attached and working) on Trinket M0 and Feather M0 basic with CircuitPython 2.3.1.
The text was updated successfully, but these errors were encountered: