qtbarcodehidapi

HIDAPI hid_open_path() how to determine which path to use



Solution

    1. You should use 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 function.

    2. Check permissions on the corresponding device. I've seen people recommend adding udev rules to change them to 666 on various forums (Ubuntu, Arch). However, I think this is incorrect. Instead, check what group the device belongs to and add yourself to that group. It could be usb or plugdev or something else.