Open mikics opened 4 years ago
write('\x00\x64\x00\x03\x00...')
is the correct way to call the API
versus what you currently have
write([0, 64, 0, 3, 0, ...])
IE, write
needs a binary string, not a list of numbers
Even with your suggestion, the error still remains. Other solutions?
without seeing the code in question and/or the resulting datatype being passed to write
at runtime it is hard to say - are you able to get trivial examples working?
write('hello')
or something
I have the same problem. here is my test code and the ERR message.
import hid
vid = 0xFEED# Change it for your device
pid = 0x6060# Change it for your device
h = hid.Device(vid, pid)
h.send_feature_report('\x66\x44')
ArgumentError Traceback (most recent call last)
can you try b"\x66\x44"
?
Here's an example:
byte_array = bytearray();
# 64 bytes of 0's as an example
for i in range(64):
byte_array.append(0)
with hid.Device(hid_vendor_id, hid_product_id) as h:
h.write(bytes(byte_array))
I think it would be helpful if something like this was added to the readme @apmorton
Thank you very much for all your answers, I was able to communicate in another way (without using pyhidapi).
I think that for the correct understanding of the functions, adding some examples to the readme like @tunstek suggested could be totally useful.
Hi, I'm trying to use pyhidapi for controlling a Digital Micromirror Device. I'm trying to send to the device its stop command, but I receive the following error:
CRITICAL:root:Unhandled exception:Traceback (most recent call last): File "C:\Users\OPT\anaconda3\envs\ScopeFoundry\lib\site-packages\ScopeFoundry\hardware.py", line 208, in enable_connection raise err File "C:\Users\OPT\anaconda3\envs\ScopeFoundry\lib\site-packages\ScopeFoundry\hardware.py", line 204, in enable_connection self.connect() File "D:\LabPrograms\ScopeFoundry_POLIMI\DMD_ScopeFoundry\DMDHardware.py", line 57, in connect self.dmd.stopsequence() File "D:\LabPrograms\ScopeFoundry_POLIMI\DMD_ScopeFoundry\DMDDeviceHID.py", line 171, in stopsequence self.command('w',0x00,0x1a,0x24,[0]) File "D:\LabPrograms\ScopeFoundry_POLIMI\DMD_ScopeFoundry\DMDDeviceHID.py", line 69, in command self.device.write(buffer) _File "C:\Users\OPT\anaconda3\envs\ScopeFoundry\lib\site-packages\hid__init.py", line 155, in write return self.hidcall(hidapi.hidwrite, self.dev, data, len(data)) File "C:\Users\OPT\anaconda3\envs\ScopeFoundry\lib\site-packages\hid\init.py", line 142, in hidcall ret = function(*args, **kwargs) ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
The arguments that I pass at ret = function(*args, *kwargs) are in this figure (args and **kwargs).
Why do I get this error? How can I solve it? Thank you.