0

I am trying to copy the behaviour of a software which control a device using HID interface, the work flow is send an idle request then send a bunch of data to the device, I can send the data, but I don't know how to send the idle request. I found the HID document online and saw this enter image description here and I can find similar question using Pyusb, but I can't use Pyusb due to the driver issue.

    import pywinusb.hid as HID
    import time
    import datetime


    v_id = 0x047a
    p_id = 0x1004
    i=0
    count_line=0
    data_2_list=[]
    all_devices = HID.HidDeviceFilter(vendor_id = v_id).get_devices()
    target_usage = HID.get_full_usage_id(0xFF00, 0x01)
    print(all_devices)
    device = all_devices[0]
    device.open()

    data=[0]*64
    # print(data)

    my_file=open("demofile2.txt","r")
    data_lines=my_file.readlines()
    for data_line in data_lines:
        count_line+=1
        data=data_line.replace("\n","")
        data_2_str_list=data.split(",")
        while i<len(data_2_str_list):
            data_2_list.append(int(data_2_str_list[i],16))
            i+=1
        print(data_2_list)
        device.send_output_report(data_2_list)
        time.sleep(0.05)
    print(count_line)

Is there a way to send Idle request using pywinusb?

JayLin1119
  • 49
  • 7

1 Answers1

0

I found out that this is a dumb question I simply send the code below

idle=[0x21,0x0A,0x200]
device.send_output_report(idle)

enter image description here

but now it occur another question is that I can send idle request, but the code give me error 87

enter image description here

import pywinusb.hid as hid
import time
import datetime


v_id = 0x047a
p_id = 0x1004
i=0
count_line=0
data_2_list=[]
all_devices = hid.HidDeviceFilter(vendor_id = v_id).get_devices()
target_usage = hid.get_full_usage_id(0xFF00, 0x01)
print(all_devices)
device = all_devices[0]
device.open()

data=[0]*64
# print(data)

my_file=open("demofile2.txt","r")
data_lines=my_file.readlines()
idle=[0x21,0x0A,0x200]
device.send_output_report(idle)
time.sleep(0.05)
for data_line in data_lines:
    count_line+=1
    data=data_line.replace("\n","")
    data_2_str_list=data.split(",")
    while i<len(data_2_str_list):
        data_2_list.append(int(data_2_str_list[i],16))
        i+=1
    print(data_2_list)
    device.send_output_report(data_2_list)
    time.sleep(0.05)
print(count_line)
JayLin1119
  • 49
  • 7