pyhidapi icon indicating copy to clipboard operation
pyhidapi copied to clipboard

Please add examples

Open wadester opened this issue 8 years ago • 3 comments

If you like my example, please add an examples dir and the example Python script.

https://github.com/wadester/wh_test_py/blob/master/hid_test.py

wadester avatar Nov 06 '15 18:11 wadester

Thank for examples, I really needed them. I agree that is should be added to repo.

pktiuk avatar Feb 15 '20 15:02 pktiuk

if anyone has an example of how to use the write function would be great I'm having issues getting the types right this is what i have tryied and it seams right from what

a = ctypes.c_void_p(0)
b = ctypes.c_char_p(10)
c = ctypes.c_size_t(1)
h.write((a,b,c))
    a = ctypes.c_void_p(0)
    b = ctypes.c_char_p(10)
    c = ctypes.c_size_t(1)
    h.write([a,b,c])
    h.write((0x0,0x0,0x1))

and I'm not too sure what else to try any advice would be welcomed

CurtisPreston99 avatar Oct 30 '21 00:10 CurtisPreston99

This is how I got write working:

dev = hid.Device(vid, pid) # set vid and pid for your device
dev.write(b'\x01\x80\x33\x01\x00\x00\x00\x00') # writing 8 bytes to the device 
bytes = dev.read(8, 1000) # reading 8 bytes from the device with a 1s timeout
bytes.hex(' ') # format the result in a human readable format

danio avatar Sep 23 '22 16:09 danio