From 40eaa1fa36a34640c897f7374ca4ec9116d2b5dc Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 23 Nov 2018 14:42:12 +0100 Subject: [PATCH] transport/hid: reload serial when closing because device.wipe() causes the device to change serial, which breaks the connection unnecessarily. --- trezorlib/transport/hid.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trezorlib/transport/hid.py b/trezorlib/transport/hid.py index 3bd4a9f7e..5234c6d92 100644 --- a/trezorlib/transport/hid.py +++ b/trezorlib/transport/hid.py @@ -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