mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
Use first USB device by default
This commit is contained in:
parent
b120043fcc
commit
8f42da3fcc
18
cmd.py
18
cmd.py
@ -9,10 +9,10 @@ from bitkeylib.debuglink import DebugLink
|
|||||||
|
|
||||||
def parse_args(commands):
|
def parse_args(commands):
|
||||||
parser = argparse.ArgumentParser(description='Commandline tool for Bitkey devices.')
|
parser = argparse.ArgumentParser(description='Commandline tool for Bitkey devices.')
|
||||||
parser.add_argument('-t', '--transport', dest='transport', choices=['usb', 'serial', 'pipe', 'socket'], default='serial', help="Transport used for talking with the device")
|
parser.add_argument('-t', '--transport', dest='transport', choices=['usb', 'serial', 'pipe', 'socket'], default='usb', help="Transport used for talking with the device")
|
||||||
parser.add_argument('-p', '--path', dest='path', default='/dev/ttyAMA0', help="Path used by the transport (usually serial port)")
|
parser.add_argument('-p', '--path', dest='path', default='', help="Path used by the transport (usually serial port)")
|
||||||
parser.add_argument('-dt', '--debuglink-transport', dest='debuglink_transport', choices=['usb', 'serial', 'pipe', 'socket'], default='socket', help="Debuglink transport")
|
parser.add_argument('-dt', '--debuglink-transport', dest='debuglink_transport', choices=['usb', 'serial', 'pipe', 'socket'], default='socket', help="Debuglink transport")
|
||||||
parser.add_argument('-dp', '--debuglink-path', dest='debuglink_path', default='0.0.0.0:8001', help="Path used by the transport (usually serial port)")
|
parser.add_argument('-dp', '--debuglink-path', dest='debuglink_path', default='127.0.0.1:2000', help="Path used by the transport (usually serial port)")
|
||||||
parser.add_argument('-j', '--json', dest='json', action='store_true', help="Prints result as json object")
|
parser.add_argument('-j', '--json', dest='json', action='store_true', help="Prints result as json object")
|
||||||
parser.add_argument('-d', '--debug', dest='debug', action='store_true', help='Enable low-level debugging')
|
parser.add_argument('-d', '--debug', dest='debug', action='store_true', help='Enable low-level debugging')
|
||||||
|
|
||||||
@ -42,6 +42,10 @@ def parse_args(commands):
|
|||||||
def get_transport(transport_string, path):
|
def get_transport(transport_string, path):
|
||||||
if transport_string == 'usb':
|
if transport_string == 'usb':
|
||||||
from bitkeylib.transport_hid import HidTransport
|
from bitkeylib.transport_hid import HidTransport
|
||||||
|
|
||||||
|
if path == '':
|
||||||
|
path = list_usb()[0]
|
||||||
|
|
||||||
return HidTransport(path)
|
return HidTransport(path)
|
||||||
|
|
||||||
if transport_string == 'serial':
|
if transport_string == 'serial':
|
||||||
@ -112,12 +116,16 @@ class Commands(object):
|
|||||||
(('-p', '--spv'), {'action': 'store_true'}),
|
(('-p', '--spv'), {'action': 'store_true'}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def list_usb():
|
||||||
|
from bitkeylib.transport_hid import HidTransport
|
||||||
|
devices = HidTransport.enumerate()
|
||||||
|
return devices
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args(Commands)
|
args = parse_args(Commands)
|
||||||
|
|
||||||
if args.cmd == 'list':
|
if args.cmd == 'list':
|
||||||
from bitkeylib.transport_hid import HidTransport
|
devices = list_usb()
|
||||||
devices = HidTransport.enumerate()
|
|
||||||
if args.json:
|
if args.json:
|
||||||
print json.dumps(devices)
|
print json.dumps(devices)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user