keepkey/python-keepkey

HidTransport.enumerate() Exception: Unknown USB interface number: -1

Closed this issue · 11 comments

I tried to keepkeyctl list

Traceback (most recent call last):
  File "C:/Python27/Scripts/keepkeyctl", line 4, in <module>
    __import__('pkg_resources').run_script('keepkey==6.0.2', 'keepkeyctl')
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 743, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "C:\python27\lib\site-packages\pkg_resources\__init__.py", line 1498, in run_script
    exec(code, namespace, namespace)
  File "c:\python27\lib\site-packages\keepkey-6.0.2-py2.7.egg\EGG-INFO\scripts\keepkeyctl", line 581, in <module>
    main()
  File "c:\python27\lib\site-packages\keepkey-6.0.2-py2.7.egg\EGG-INFO\scripts\keepkeyctl", line 554, in main
    devices = list_usb()
  File "c:\python27\lib\site-packages\keepkey-6.0.2-py2.7.egg\EGG-INFO\scripts\keepkeyctl", line 548, in list_usb
    return HidTransport.enumerate()
  File "C:\python27\lib\site-packages\keepkey-6.0.2-py2.7.egg\keepkeylib\transport_hid.py", line 70, in enumerate
    raise Exception("Unknown USB interface number: %d" % interface_number)
Exception: Unknown USB interface number: -1

Here is the code. Looking on branch conditions, the interface number = -1 is kind of expected but it appears that the path is not appropriate (?)
image

https://github.com/keepkey/python-keepkey/blob/master/keepkeylib/transport_hid.py#L61-L68

I print path and it is:
\\?\hid#vid_2b24&pid_0001#6&2d4594d8&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Is the path wrong?
So the vendorId and productId is correct, so it actually can see the device, can't it? I am on Windows 7.

I just wanted to update firmware through cli as it didn't work through KeepKey Client App. In the chrome dev console it prints that the firmware was successfully uploaded but the firmware version number stays the same.

firmware 5.10.2

On Windows 7, you may have to install the 'libusb0 (v1.2.6.0) winusb driver via zadig.

That said, the code there makes some assumptions about the structure of the path that appear not to be the case on all platforms (i.e. it works on Mac, but not elsewhere).

Mind pasting the KeepKey-specific entries from this?

from pprint import pprint
import hid
pprint(hid.enumerate())

Edit: the zadig driver thing is only relevant if you are on WebUsb firmware, which happened at v6.0.0.

the firmware was successfully uploaded but the firmware version number stays the same... v5.10.2

If you're on the prod client, this is expected. If you want the newer WebUsb firmware, you'll need to use the beta client.

Another option is to use https://github.com/solipsis/go-keepkey

many thanks
output from pprint(hid.enumerate())

[{'interface_number': 0,
  'manufacturer_string': u'\u0409',
  'path': '\\\\?\\hid#vid_04d9&pid_fb01&mi_00#8&156b0b9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 64257,
  'product_string': u'USB Laser Game Mouse',
  'release_number': 768,
  'serial_number': u'\u0409',
  'usage': 2,
  'usage_page': 1,
  'vendor_id': 1241},
 {'interface_number': 1,
  'manufacturer_string': u'\u0409',
  'path': '\\\\?\\hid#vid_04d9&pid_fb01&mi_01#8&252dee7b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 64257,
  'product_string': u'USB Laser Game Mouse',
  'release_number': 768,
  'serial_number': u'\u0409',
  'usage': 6,
  'usage_page': 1,
  'vendor_id': 1241},
 {'interface_number': 2,
  'manufacturer_string': u'\u0409',
  'path': '\\\\?\\hid#vid_04d9&pid_fb01&mi_02&col01#8&d6a6236&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 64257,
  'product_string': u'USB Laser Game Mouse',
  'release_number': 768,
  'serial_number': u'\u0409',
  'usage': 1,
  'usage_page': 12,
  'vendor_id': 1241},
 {'interface_number': 2,
  'manufacturer_string': u'\u0409',
  'path': '\\\\?\\hid#vid_04d9&pid_fb01&mi_02&col02#8&d6a6236&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 64257,
  'product_string': u'USB Laser Game Mouse',
  'release_number': 768,
  'serial_number': u'\u0409',
  'usage': 1,
  'usage_page': 65440,
  'vendor_id': 1241},
 {'interface_number': 0,
  'manufacturer_string': u'Razer',
  'path': '\\\\?\\hid#vid_1532&pid_010f&mi_00#8&269ca7d1&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 271,
  'product_string': u'Razer Anansi',
  'release_number': 512,
  'serial_number': u'\u0409',
  'usage': 6,
  'usage_page': 1,
  'vendor_id': 5426},
 {'interface_number': 1,
  'manufacturer_string': u'Razer',
  'path': '\\\\?\\hid#vid_1532&pid_010f&mi_01&col01#8&2c56a0f&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 271,
  'product_string': u'Razer Anansi',
  'release_number': 512,
  'serial_number': u'\u0409',
  'usage': 128,
  'usage_page': 1,
  'vendor_id': 5426},
 {'interface_number': 1,
  'manufacturer_string': u'Razer',
  'path': '\\\\?\\hid#vid_1532&pid_010f&mi_01&col02#8&2c56a0f&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 271,
  'product_string': u'Razer Anansi',
  'release_number': 512,
  'serial_number': u'\u0409',
  'usage': 1,
  'usage_page': 12,
  'vendor_id': 5426},
 {'interface_number': 2,
  'manufacturer_string': u'Razer',
  'path': '\\\\?\\hid#vid_1532&pid_010f&mi_02#8&1a88f654&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 271,
  'product_string': u'Razer Anansi',
  'release_number': 512,
  'serial_number': u'\u0409',
  'usage': 2,
  'usage_page': 1,
  'vendor_id': 5426},
 {'interface_number': -1,
  'manufacturer_string': u'KeepKey, LLC.',
  'path': '\\\\?\\hid#vid_2b24&pid_0001#6&2d4594d8&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}',
  'product_id': 1,
  'product_string': u'KeepKey',
  'release_number': 256,
  'serial_number': u'36343433104737312E001800',
  'usage': 1,
  'usage_page': 65280,
  'vendor_id': 11044}]

If you're on the prod client, this is expected. If you want the newer WebUsb firmware, you'll need to use the beta client.

I tried a beta client. But after the update is finished and I plug out the device and then plug in it is then didn't get recognized by any of KeepKey Client App and Mycelium. I wanted to create an issue about that but not sure where?

Edit: oh, for that this one, right?

On Windows 7, you may have to install the 'libusb0 (v1.2.6.0) winusb driver via zadig.

Yeah, you may need to install that driver in order to get anything to recognize your WebUsb KeepKey on Win7. If you're still having trouble, please feel free to file a support ticket at https://keepkey.com/support (please mention this github issue so our support team has the reference)

As for Mycelium, they haven't yet updated their app to support it: mycelium-com/wallet-android#497. For the time being, if you want Mycelium to work, you'll have to stay on v5.11.0 or earlier. As a heads up, downgrading will most likely wipe your device.

To downgrade, open up the prod client, and plug your device in while holding the button. It should be recognized, even if it doesn't get picked up in firmware mode (different device-side USB stack).

@agneslovelace would you mind trying out this patch? #53 I don't have a Win7 machine to try it on, but I think it might fix the issue you're seeing.

yes, thanks, I will report

This issue affects Windows 10 as well not just 7. Probably all modern Windows.
I have tested #53, that fixes it.

This affects Electrum spesmilo/electrum#5165 (comment)
as we are packaging 6.0.2 since spesmilo/electrum#4993

It would be really great if you could relatively quickly tag and release a new version on PyPI (even if branched off from master).

@keepkeyjon Oh wow, that was fast. Thanks!

@SomberNight if there's anything else you need to make KeepKey+Electrum better, feel free to ask... I'll see what I can do.