I have USB realtime clock (RTC) which connects to an embedded linux device. The RTC is accessed over i2c, and the i2c is exposed over USB. I access the RTC via the PyMCP2221A module, which in turn uses the cython-hidapi module, which interfaces with the hidapi library. At least that is my understanding of how it all works.
But suddenly, on my new linux build, cython-hidapi is no longer showing devices. I can't think of anything I could have changed that would break this.
On my old build:
root@intel-corei7-64:~# python3 -c "import hid; print(hid.enumerate());"
[
{'path': b'1-5:1.2', 'vendor_id': 1240, 'product_id': 221, 'serial_number': '', 'release_number': 256, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 2},
{'path': b'1-2:1.0', 'vendor_id': 1008, 'product_id': 654, 'serial_number': '', 'release_number': 16644, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 0},
{'path': b'1-2:1.1', 'vendor_id': 1008, 'product_id': 654, 'serial_number': '', 'release_number': 16644, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 1},
{'path': b'1-2:1.2', 'vendor_id': 1008, 'product_id': 654, 'serial_number': '', 'release_number': 16644, 'manufacturer_string': '', 'product_string': '', 'usage_page': 0, 'usage': 0, 'interface_number': 2}
]
On my new build:
root@intel-corei7-64:~# python3 -c "import hid; print(hid.enumerate());"
[]
In both cases, the device is still seen by the OS without apparent issue:
root@intel-corei7-64:~# udevadm info /dev/ttyACM0
P: /devices/pci0000:00/0000:00:15.0/usb1/1-5/1-5:1.0/tty/ttyACM0
N: ttyACM0
S: serial/by-id/usb-Microchip_Technology_Inc._MCP2221_USB-I2C_UART_Combo-if00
S: serial/by-path/pci-0000:00:15.0-usb-0:5:1.0
E: DEVLINKS=/dev/serial/by-id/usb-Microchip_Technology_Inc._MCP2221_USB-I2C_UART_Combo-if00 /dev/serial/by-path/pci-0000:00:15.0-usb-0:5:1.0
E: DEVNAME=/dev/ttyACM0
E: DEVPATH=/devices/pci0000:00/0000:00:15.0/usb1/1-5/1-5:1.0/tty/ttyACM0
E: ID_BUS=usb
E: ID_MODEL=MCP2221_USB-I2C_UART_Combo
E: ID_MODEL_ENC=MCP2221\x20USB-I2C\x2fUART\x20Combo
E: ID_MODEL_FROM_DATABASE=Celeron N3350/Pentium N4200/Atom E3900 Series USB xHCI
E: ID_MODEL_ID=00dd
E: ID_PATH=pci-0000:00:15.0-usb-0:5:1.0
E: ID_PATH_TAG=pci-0000_00_15_0-usb-0_5_1_0
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_REVISION=0100
E: ID_SERIAL=Microchip_Technology_Inc._MCP2221_USB-I2C_UART_Combo
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Miscellaneous Device
E: ID_USB_DRIVER=cdc_acm
E: ID_USB_INTERFACES=:020201:0a0000:030000:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_PROTOCOL_FROM_DATABASE=Interface Association
E: ID_VENDOR=Microchip_Technology_Inc.
E: ID_VENDOR_ENC=Microchip\x20Technology\x20Inc.
E: ID_VENDOR_FROM_DATABASE=Microchip Technology, Inc.
E: ID_VENDOR_ID=04d8
E: MAJOR=166
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=2305363
I verified that the versions of PyMCP2221A and cython-hidapi haven't changed. So it seems like hidapi itself is the problem, but I can't be sure. Does anyone know what might be going wrong or how I could debug this issue?
Edit:
I found this hidapitester program and gave it a try. hidapitester --list
returns nothing on either of my linux builds, even the one where hid.enumerate()
shows devices.
It turns out the cython-hidapi module was not the same version on both systems. When I ran hid.version_str()
, I got 0.14.0
on both systems. But later I checked with pip freeze
and was able to see that the newer system was now actually using 0.14.0.post2
. I switched back to 0.14.0
and everything is working again.