pywinusb在HID上发送一个LED OFF_HOOK(0x17)

时间:2014-04-24 09:26:37

标签: python pywinusb

我有以下定义:     电话设备页面:0x0B,         电话耳机:0x05,     LED页面:0x08,         LED OFF_HOOK:0x17

我想发送一个" LED OFF_HOOK = 0x17"使用pywinusb-0.3示例"简单发送"下面但是我收到了这个错误"找到了目标设备,但请求的用法不存在!"。我会恭喜任何帮助。感谢

import pywinusb.hid as hid

def click_signal(target_usage, target_vendor_id):
    all_devices = hid.HidDeviceFilter(vendor_id = target_vendor_id).get_devices()
    if not all_devices:
        print("Can't find target device (vendor_id = 0x%04x)!" % target_vendor_id)
    else:

        for device in all_devices:
            try:
                device.open()
                DD = device.find_output_reports()
                for report in DD:
                    c = target_usage in report
                    if target_usage in report:
                        report[target_usage] = 1 # yes, changing values is that easy
                       report.send()               
                        report[target_usage] = 0
                        report.send()
                        print("\nUsage clicked!\n")
                        return
            finally:
                device.close()
        print("The target device was found, but the requested usage does not exist!\n")
    #
if __name__ == '__main__':
    target_vendor_id = 0x1395 # just an example, change it to the actual vendor_id
    target_usage = hid.get_full_usage_id(0x0B, 0x17) # generic vendor page, usage_id = 2
     click_signal(target_usage, target_vendor_id)

1 个答案:

答案 0 :(得分:0)

LED OFF_HOOK预计将成为一个信号'返回'对主持人。

为了更改状态,您需要在电话页面上对HOOK_SWITCH使用情况进行更改。