0

So, I tried to send idle request to my device, it successfully send by looking into wireshark usbcap the device did get set_idle request and the device did send response back. My problem is my code pop up an error and stop, but I need to send a bunch of data after the idle request. enter image description here

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]
    idle=[0]*33
    idle[0]=0x21
    idle[1]=0x0A
    idle[2]=0x200
    idle[3]=0x00
    device.send_output_report(idle)
    # device.set_raw_data(idle)
    # device.send(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)

I have tried send function and send_output_report, both have error happend, but

device.send_output_report(data_2_list)

work fine, what's wrong with my code, is the format wrong or something else

JayLin1119
  • 49
  • 7

0 Answers0