Skip to content

Commit

Permalink
bitbox02: handle multiple connected bitbox02s correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
benma committed Apr 6, 2021
1 parent cd23d5b commit 15d8eca
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions hwilib/devices/bitbox02.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,19 @@ def init(self, expect_initialized: Optional[bool] = True) -> bitbox02.BitBox02:
return self.bb02

for device_info in devices.get_any_bitbox02s():
if device_info["path"].decode() == self.device_path:
bb02 = bitbox02.BitBox02(
transport=self.transport,
device_info=device_info,
noise_config=self.noise_config,
)
try:
bb02.check_min_version()
except FirmwareVersionOutdatedException as exc:
sys.stderr.write("WARNING: {}\n".format(exc))
raise
if device_info["path"].decode() != self.device_path:
continue

bb02 = bitbox02.BitBox02(
transport=self.transport,
device_info=device_info,
noise_config=self.noise_config,
)
try:
bb02.check_min_version()
except FirmwareVersionOutdatedException as exc:
sys.stderr.write("WARNING: {}\n".format(exc))
raise
self.bb02 = bb02
is_initialized = bb02.device_info()["initialized"]
if expect_initialized is not None:
Expand Down

0 comments on commit 15d8eca

Please sign in to comment.