1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 01:18:54 +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 # decide if the HID interface is normal transport
# or debuglink # or debuglink
if platform.system() in ('Linux', 'Darwin'): if platform.system() == 'Linux':
# Sample: 0003:0017:00 # Sample: 0003:0017:00
if path.endswith(':00'): if path.endswith(':00'):
return False return False
@ -44,6 +44,10 @@ class HidTransport(Transport):
return True return True
return False return False
elif platform.system() == 'Darwin':
# DebugLink doesn't work on Mac
return False
else: else:
raise Exception("USB interface detection not implemented for %s" % platform.system()) raise Exception("USB interface detection not implemented for %s" % platform.system())
@ -56,6 +60,11 @@ class HidTransport(Transport):
serial_number = d['serial_number'] serial_number = d['serial_number']
path = d['path'] 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: if (vendor_id, product_id) in DEVICE_IDS:
devices.setdefault(serial_number, [None, None]) devices.setdefault(serial_number, [None, None])
devices[serial_number][int(bool(cls._detect_debuglink(path)))] = path devices[serial_number][int(bool(cls._detect_debuglink(path)))] = path