Closed Qbicz closed 5 years ago
The version on pypi is outdated - it doesn't include the fixes for correct operation on Windows, which I finally merged today. Can you try with the code from master and see if that works?
I use the git master version with merged #12 which is functionally the same as #13. The problem is not that I cannot locate the DLL, but that the DLL does not work the same in Python as it does when used by C code. I'll check my hidapi.dll
twice, maybe there's something wrong with it.
Was guessing based on the file path in your error message - I guess you installed it system wide from a git clone.
Double check that the correct hidapi.dll is actually being loaded, you may have a stray version of hidapi.dll somewhere on your path that is higher in the search order.
Also, fwiw, prior to #12/#13 it will still locate and load hidapi.dll on Windows, it just uses the incorrect calling convention and nothing works.
I have Python2.7 [MSC v.1500 32 bit (Intel)] on win32 so I compiled the hidapi.dll
with Visual Studio 2008. However, it didn't work with opening the device. When I compiled it with Visual Studio 2017, it works!
Since we are at it, there is no conversion of arrays from Python to C for calls like write()
or send_feature_report()
. Should I just import ctypes
and do something like
arr = (ctypes.c_int * len(pyarr))(*pyarr)
You are expected to pass strings for calls to write or send_feature_report. If you have some structured report you need to build up, the struct module that ships with python is your friend.
I just want to pass an array of bytes. When passing a python string, I get hid.HIDException: <exception str() failed>
.
Ended up with ctypes.c_ubyte
which works fine for sending reports.
Thanks for help!
Hi, I'm trying to use pyhidapi to send feature reports. This is a device normally claimed by the Windows operating system (HID mouse). I needed to apply that patch to the HIDAPI C library: https://github.com/signal11/hidapi/pull/335 With it, I can open the device with C code and send feature reports, however with
pyhidapi
I can enumerate devices, but trying to create ahid.Device(vid, pid)
results inI use the DLL with the mentioned patch. Any ideas?