trezor / cython-hidapi

:snake: Python wrapper for the HIDAPI
Other
283 stars 109 forks source link

open failed - Error File "hid.pyx" #145

Closed staebchen0 closed 2 years ago

staebchen0 commented 2 years ago

Hi, I'm trying to control a USB relay with the Pi.

I have carried out all installation steps (on raspberry pi 4). Rules add an:

udevadm control --reload-rules to reload the rules.

The import hid works in Python 3.9 :

>>> import hid
>>> 

is ok!

Test.py gives the following result:

Testing started at 18:14 ... Ran 1 test in 0.013s

OK

However, when I open the release, I get an error: Code:

dev = hid.device()
dev.open(VID, PID)
dev.set_nonblocking(1)
idx = 1

Error message:

dev.open(VID, PID)

File "hid.pyx", line 127, in hid.device.open OSError: open failed FATAL: exception not thrown back

Thanks in advance for the help :-)

prusnak commented 2 years ago

Does it work when you run as root? Try sudo ...

staebchen0 commented 2 years ago

that's interesting, logged in with root it works

>>> import hid
>>> dev = hid.device()
>>> dev.open(5824,1503)
>>> dev.set_nonblocking(1)
0
>>> idx = 1
>>> 

I have the program running in PyCharm, what do I have to do?

Thanks!

prusnak commented 2 years ago

It means you did not correctly install the udev rules for your device.

staebchen0 commented 2 years ago

OK, I have stored the rules with root rights, otherwise I could not save

staebchen0 commented 2 years ago

do you have any advice on how to do it right?