from __future__ import print_functionimport hidimport time# enumerate USB devicesfor d in hid.enumerate():keys = list(d.keys())keys.sort()for key in keys:print("%s : %s" % (key, d[key]))print()# try opening a device, then perform write and readh = hid.device()try:print("Opening the device")h.open(0x17ef, 0xa080) # TREZOR VendorID/ProductIDprint("Manufacturer: %s" % h.get_manufacturer_string())print("Product: %s" % h.get_product_string())print("Serial No: %s" % h.get_serial_number_string())# enable non-blocking modeh.set_nonblocking(1)# muteprint("Write the data")h.write([2, 3, 0, 0] + [0] * 61)# waittime.sleep(1)# unmuteprint("Write the data")h.write([2, 1, 0, 0] + [0] * 61)# waittime.sleep(1)# read back the answerprint("Read the data")while True:d = h.read(64)if d:print(d)else:breakprint("Closing the device")h.close()except IOError as ex:print(ex)print("hid error:")print(h.error())print("")print("You probably don't have the hard-coded device.")print("Update the h.open() line in this script with the one")print("from the enumeration list output above and try again.")print("Done")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。