mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
small nits of last commit
This commit is contained in:
parent
759316e96f
commit
646338c414
@ -64,7 +64,7 @@ CHOICE_OUTPUT_SCRIPT_TYPE = ChoiceType({
|
|||||||
|
|
||||||
def get_transport_class_by_name(name):
|
def get_transport_class_by_name(name):
|
||||||
|
|
||||||
if name == 'usb':
|
if name == 'hid':
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport_hid import HidTransport
|
||||||
return HidTransport
|
return HidTransport
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ def get_transport(transport_name, path):
|
|||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.option('-t', '--transport', type=click.Choice(['usb', 'webusb', 'udp', 'pipe', 'bridge']), default='usb', help='Select transport used for communication.')
|
@click.option('-t', '--transport', type=click.Choice(['hid', 'webusb', 'udp', 'pipe', 'bridge']), default='hid', help='Select transport used for communication.')
|
||||||
@click.option('-p', '--path', help='Select device by transport-specific path.')
|
@click.option('-p', '--path', help='Select device by transport-specific path.')
|
||||||
@click.option('-v', '--verbose', is_flag=True, help='Show communication messages.')
|
@click.option('-v', '--verbose', is_flag=True, help='Show communication messages.')
|
||||||
@click.option('-j', '--json', 'is_json', is_flag=True, help='Print result as JSON object')
|
@click.option('-j', '--json', 'is_json', is_flag=True, help='Print result as JSON object')
|
||||||
|
@ -40,7 +40,7 @@ try:
|
|||||||
from trezorlib.transport_webusb import WebUsbTransport
|
from trezorlib.transport_webusb import WebUsbTransport
|
||||||
WEBUSB_ENABLED = True
|
WEBUSB_ENABLED = True
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print('WebUsb transport disabled:', e)
|
print('WebUSB transport disabled:', e)
|
||||||
WEBUSB_ENABLED = False
|
WEBUSB_ENABLED = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -70,7 +70,7 @@ class WebUsbHandle(object):
|
|||||||
|
|
||||||
class WebUsbTransport(Transport):
|
class WebUsbTransport(Transport):
|
||||||
'''
|
'''
|
||||||
HidTransport implements transport over USB HID interface.
|
WebUsbTransport implements transport over WebUSB interface.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, device, protocol=None, handle=None, debug=False):
|
def __init__(self, device, protocol=None, handle=None, debug=False):
|
||||||
@ -109,12 +109,12 @@ class WebUsbTransport(Transport):
|
|||||||
for transport in WebUsbTransport.enumerate():
|
for transport in WebUsbTransport.enumerate():
|
||||||
if path is None or dev_to_str(transport.device) == path:
|
if path is None or dev_to_str(transport.device) == path:
|
||||||
return transport
|
return transport
|
||||||
raise TransportException('HID device not found')
|
raise TransportException('WebUSB device not found')
|
||||||
|
|
||||||
def find_debug(self):
|
def find_debug(self):
|
||||||
if isinstance(self.protocol, ProtocolV2):
|
if isinstance(self.protocol, ProtocolV2):
|
||||||
# TODO test this
|
# TODO test this
|
||||||
# For v2 protocol, lets use the same HID interface, but with a different session
|
# For v2 protocol, lets use the same WebUSB interface, but with a different session
|
||||||
protocol = ProtocolV2()
|
protocol = ProtocolV2()
|
||||||
debug = WebUsbTransport(self.device, protocol, self.handle)
|
debug = WebUsbTransport(self.device, protocol, self.handle)
|
||||||
return debug
|
return debug
|
||||||
@ -123,7 +123,7 @@ class WebUsbTransport(Transport):
|
|||||||
protocol = ProtocolV1()
|
protocol = ProtocolV1()
|
||||||
debug = WebUsbTransport(self.device, protocol, None, True)
|
debug = WebUsbTransport(self.device, protocol, None, True)
|
||||||
return debug
|
return debug
|
||||||
raise TransportException('Debug HID device not found')
|
raise TransportException('Debug WebUSB device not found')
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
interface = DEBUG_INTERFACE if self.debug else INTERFACE
|
interface = DEBUG_INTERFACE if self.debug else INTERFACE
|
||||||
|
Loading…
Reference in New Issue
Block a user