1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00

Fixes HID detection on Mac

This commit is contained in:
slush0 2014-02-13 19:04:51 +01:00
parent a0bc12375c
commit f48cf157c7

View File

@ -31,7 +31,7 @@ class HidTransport(Transport):
# decide if the HID interface is normal transport
# or debuglink
if platform.system() in ('Linux', 'Darwin'):
if platform.system() == 'Linux':
# Sample: 0003:0017:00
if path.endswith(':00'):
return False
@ -44,6 +44,10 @@ class HidTransport(Transport):
return True
return False
elif platform.system() == 'Darwin':
# DebugLink doesn't work on Mac
return False
else:
raise Exception("USB interface detection not implemented for %s" % platform.system())
@ -56,6 +60,11 @@ class HidTransport(Transport):
serial_number = d['serial_number']
path = d['path']
# HIDAPI on Mac cannot detect correct HID interfaces, so device with
# DebugLink doesn't work on Mac...
if devices.get(serial_number) != None and devices[serial_number][0] == path:
raise Exception("Two devices with the same path and S/N found. This is Mac, right? :-/")
if (vendor_id, product_id) in DEVICE_IDS:
devices.setdefault(serial_number, [None, None])
devices[serial_number][int(bool(cls._detect_debuglink(path)))] = path