Skip to content

Commit 15d8eca

Browse files
committed
bitbox02: handle multiple connected bitbox02s correctly
If there were more than one BitBox02 connected, enumerate would fail. This commit fixes a small mistake in the initialization, allowing HWI to handle multiple BitBox02s at once.
1 parent cd23d5b commit 15d8eca

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

hwilib/devices/bitbox02.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,19 @@ def init(self, expect_initialized: Optional[bool] = True) -> bitbox02.BitBox02:
285285
return self.bb02
286286

287287
for device_info in devices.get_any_bitbox02s():
288-
if device_info["path"].decode() == self.device_path:
289-
bb02 = bitbox02.BitBox02(
290-
transport=self.transport,
291-
device_info=device_info,
292-
noise_config=self.noise_config,
293-
)
294-
try:
295-
bb02.check_min_version()
296-
except FirmwareVersionOutdatedException as exc:
297-
sys.stderr.write("WARNING: {}\n".format(exc))
298-
raise
288+
if device_info["path"].decode() != self.device_path:
289+
continue
290+
291+
bb02 = bitbox02.BitBox02(
292+
transport=self.transport,
293+
device_info=device_info,
294+
noise_config=self.noise_config,
295+
)
296+
try:
297+
bb02.check_min_version()
298+
except FirmwareVersionOutdatedException as exc:
299+
sys.stderr.write("WARNING: {}\n".format(exc))
300+
raise
299301
self.bb02 = bb02
300302
is_initialized = bb02.device_info()["initialized"]
301303
if expect_initialized is not None:

0 commit comments

Comments
 (0)