简体   繁体   中英

pywinusb send a LED OFF_HOOK (0x17) on HID

I have the following definitions: Telephony Device Page: 0x0B, TELEPHONY HEADSET: 0x05, LED Page: 0x08, LED OFF_HOOK: 0x17

I want to send a "LED OFF_HOOK = 0x17" using pywinusb-0.3 example "simple send" below but am getting this error "The target device was found, but the requested usage does not exist!". I will appriciate any help. Thanks

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)

LED OFF_HOOK is expected to be a signal 'back' to the host.

In order to change the state, you'd need to issue a change in the HOOK_SWITCH usage on telephony page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM