HIDAPI hid_open_path() 如何确定使用哪个路径

HIDAPI hid_open_path() how to determine which path to use

  1. 你应该使用hid_enumerate(<vid>, <pid>), which will return linked list of hid_device_info structures. hid_device_info has a member variable called path, which is the device path you are looking for. The path may change depending on the pc or on even on the same pc, if you have other devices plugged in. To distinguish between different devices, you can check their serial number using hid_get_serial_number_string函数。

  2. 检查相应设备的权限。我在各种论坛(Ubuntu、Arch)上看到有人建议添加 udev 规则以将其更改为 666。但是,我认为这是不正确的。相反,检查设备属于哪个组并将您自己添加到该组。它可能是 usbplugdev 或其他。