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

use new hidapi api

This commit is contained in:
Pavol Rusnak 2013-10-19 14:19:09 +02:00
parent 57151ce1b3
commit 2587eff8fd
2 changed files with 4 additions and 1 deletions

2
cmd.py
View File

@ -114,6 +114,8 @@ class Commands(object):
return self.client.load_device(seed, args.pin) return self.client.load_device(seed, args.pin)
def firmware_update(self, args): def firmware_update(self, args):
if not args.file:
raise Exception("Must provide firmware filename")
fp = open(args.file, 'r') fp = open(args.file, 'r')
if fp.read(4) != 'TRZR': if fp.read(4) != 'TRZR':
raise Exception("Trezor firmware header expected") raise Exception("Trezor firmware header expected")

View File

@ -40,7 +40,8 @@ class HidTransport(Transport):
def _open(self): def _open(self):
self.buffer = '' self.buffer = ''
path = self.device.split(':') path = self.device.split(':')
self.hid = hid.device(int(path[0], 16), int(path[1], 16))#, path[2]) self.hid = hid.device()
self.hid.open(int(path[0], 16), int(path[1], 16))
self.hid.set_nonblocking(True) self.hid.set_nonblocking(True)
self.hid.send_feature_report([0x41, 0x01]) # enable UART self.hid.send_feature_report([0x41, 0x01]) # enable UART
self.hid.send_feature_report([0x43, 0x03]) # purge TX/RX FIFOs self.hid.send_feature_report([0x43, 0x03]) # purge TX/RX FIFOs