我试图在Windows下为Flyfish FF32 USB-HID IO板(http://www.flyfish-tech.com/FF32/index.php)创建python库。我正在使用pywinusb库,Python 2.7,Windows 7。
设备本身可以使用flyfish GUI提供。在运行" show_hids"来自pywinusb设备的演示是可见的:
HID device (vID=0x04d8, pID=0xf8b9, v=0x0032); FLYFISH TECHNOLOGIES; FF32, Path: \\?\hid#vid_04d8&pid_f8b9#a&135de629&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Path: \\?\hid#vid_04d8&pid_f8b9#a&135de629&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Instance: HID\VID_04D8&PID_F8B9\A&135DE629&1&0000
Port (ID): 2460
Port (str):USB\VID_04D8&PID_F8B9\9&815F95E&0&3
HID device documentation report
===============================
Top Level Details
-----------------
Manufacturer String: FLYFISH TECHNOLOGIES
Product Sting: FF32
Serial Number: ?
Vendor ID: 0x04d8
Product ID: 0xf8b9
Version number: 0x0032
Device Path: \\?\hid#vid_04d8&pid_f8b9#a&135de629&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Device Instance Id: HID\VID_04D8&PID_F8B9\A&135DE629&1&0000
Parent Instance Id: 2460
Top level usage: Page=0xff00, Usage=0x01
Usage identification: Unknown Page/usage
Link collections: 1 collection(s)
Reports
-------
Input Report
~~~~~~~~~~~~
Length: 65 byte(s)
Buttons: 1 button(s)
Values: 0 value(s)
Output Report
~~~~~~~~~~~~~
length: 65 byte(s)
Buttons: 1 button(s)
Values: 0 value(s)
Feature Report
~~~~~~~~~~~~~
Length: 0 byte(s)
Buttons: 0 button(s)
Values: 0 value(s)
*** Input Caps ***
Usage Range 1~64 (0x1~0x40), Page 0xff00 (Vendor-defined)
bit_field: 0
data_index_max: 63
data_index_min: 0
designator_max: 0
designator_min: 0
is_absolute: 1
is_alias: 0
is_button: True
is_designator_range: 0
is_range: 1
is_string_range: 0
is_value: False
link_collection: 0
link_usage: 1 (0x1)
link_usage_page: 65280 (0xff00)
report_id: 0
string_max: 0
string_min: 0
*** Output Caps ***
Usage Range 1~64 (0x1~0x40), Page 0xff00 (Vendor-defined)
bit_field: 0
data_index_max: 63
data_index_min: 0
designator_max: 0
designator_min: 0
is_absolute: 1
is_alias: 0
is_button: True
is_designator_range: 0
is_range: 1
is_string_range: 0
is_value: False
link_collection: 0
link_usage: 1 (0x1)
link_usage_page: 65280 (0xff00)
report_id: 0
string_max: 0
string_min: 0
但是在运行以下时,修改了演示:
import pywinusb.hid as hid
from time import sleep
def sample_handler(data):
print("Raw data: {0}".format(data))
filter = hid.HidDeviceFilter(vendor_id = 0x04d8, product_id = 0xf8b9)
hid_device = filter.get_devices()
device = hid_device[0]
device.open()
target_usage = hid.get_full_usage_id(0xff00, 1)
device.set_raw_data_handler(sample_handler)
report = device.find_output_reports()
print(report[0])
buffer = [0x00]*65
buffer[0] = 0
buffer[1] = 0x13
report[0].set_raw_data(buffer)
report[0].send()
sleep(1)
device.close()
执行输出: HID报告对象(输出报告
t, id=0x00), 63 items included
Raw data: [0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
我没有获得预期的供应商信息。我安装了USB嗅探软件,结果发现无论我放入缓冲区,FF32总是得到0的数组。
供参考。从GUI嗅探包:
80 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 f1 6d 0b 80 fa ff ff
02 00 00 00 40 00 00 00 75 9f b6 0b 80 f8 ff ff
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*13* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
我的剧本中有一个:
80 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 18 f1 6d 0b 80 fa ff ff
02 00 00 00 40 00 00 00 41 57 87 05 80 f8 ff ff
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
有谁知道这里有什么问题?
答案 0 :(得分:0)
这个设备很奇怪,报告不会有65个字节,因为这通常受端点大小的限制。
无论如何,intersection
预计将被用作"一次性的模板" HID使用设置,因此它将验证您提供有效的报告ID和可解析信息(解析由Windows API完成)。
在您的情况下,如果您想发送"任何"只要报告ID列在HID描述符(第一个字节)中,就可以使用:
到您的设备set_raw_data()
在这两种情况下,您都绕过了报表解析逻辑,这些是最有效的数据发送方式,可以对您发送的内容进行较少的验证。