1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 12:08:59 +00:00

use usage_page to detect interfaces

This commit is contained in:
Pavol Rusnak 2016-10-03 10:39:58 +02:00
parent 9d3fb81f97
commit bac91afca7
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -14,18 +14,15 @@ def enumerate():
product_id = d['product_id'] product_id = d['product_id']
serial_number = d['serial_number'] serial_number = d['serial_number']
interface_number = d['interface_number'] interface_number = d['interface_number']
usage_page = d['usage_page']
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])
if interface_number == 0 or interface_number == -1: # normal link # first match by usage_page, then try interface number
if usage_page == 0xFF00 or interface_number == 0: # normal link
devices[serial_number][0] = path devices[serial_number][0] = path
elif interface_number == 1: # debug link elif usage_page == 0xFF01 or interface_number == 1: # debug link
devices[serial_number][1] = path devices[serial_number][1] = path
# List of two-tuples (path_normal, path_debuglink) # List of two-tuples (path_normal, path_debuglink)