1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

transport/hid: reload serial when closing

because device.wipe() causes the device to change serial, which breaks
the connection unnecessarily.
This commit is contained in:
matejcik 2018-11-23 14:42:12 +01:00
parent f3a13f50e0
commit 40eaa1fa36

View File

@ -61,7 +61,9 @@ class HidHandle:
if serial != self.serial:
self.handle.close()
self.handle = None
raise TransportException("Unexpected device on path %s" % self.path)
raise TransportException(
"Unexpected device {} on path {}".format(serial, self.path.decode())
)
self.handle.set_nonblocking(True)
@ -70,6 +72,8 @@ class HidHandle:
def close(self) -> None:
if self.handle is not None:
# reload serial, because device.wipe() can reset it
self.serial = self.handle.get_serial_number_string()
self.handle.close()
self.handle = None