Skip to content

Commit 09ecd35

Browse files
committed
Skip devices in BL mode during scan
1 parent 7a99728 commit 09ecd35

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/modulino/modulino.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
0x4: "Latch Relay"
2626
}
2727

28+
_BOOTLOADER_ADDRESS = const(0x64)
29+
2830
class _I2CHelper:
2931
"""
3032
A helper class for interacting with I2C devices on supported boards.
@@ -267,7 +269,7 @@ def enter_bootloader(self):
267269
sleep(0.25) # Wait for the device to reset
268270
return True
269271
except OSError as e:
270-
# ENODEV (e.errno == 19) can be thrown if either the device reset while writing out the buffer
272+
# ENODEV (e.errno == 19) can be thrown if the device resets while writing out the buffer
271273
return False
272274

273275
def read(self, amount_of_bytes: int) -> bytes | None:
@@ -328,6 +330,9 @@ def available_devices(bus: I2C = None) -> list[Modulino]:
328330
device_addresses = bus.scan()
329331
devices = []
330332
for address in device_addresses:
333+
if address == _BOOTLOADER_ADDRESS:
334+
# Skip bootloader address
335+
continue
331336
device = Modulino(i2c_bus=bus, address=address)
332337
devices.append(device)
333338
return devices

0 commit comments

Comments
 (0)