本帖最后由 lszisgood 于 2024-7-4 17:02 编辑
问题描述:
LPC55xx,RT10xx进入ISP模式后,在设备管理器里能够看到HID设备枚举成功。但使用blhost.exe无法打开HID设备。返回如下信息:
Microsoft Windows [版本 10.0.22631.3737]
(c) Microsoft Corporation。保留所有权利。
C:\test\blhost>blhost.exe -u 0x1fc9,0x0021 -- get-property 10
Error: UsbHidPeripheral() cannot open USB HID device (vid=0x1fc9, pid=0x0021, sn=).
Root cause原因分析:
在某些Windows 10 OS版本,系统进程会默认打开HID设备,share_mode模式是FILE_SHARE_READ|FILE_SHARE_WRITE。但blhost使用的HIDAPI调用CreateFile的share模式不正确,导致打开HID设备返回失败。
Thefirst application that opens a HID gets to determine its sharing settings. The second application can only access the HID permissions that areshared, and the specified permissions must exactly match those of what the first applicationspecified, or else the file open operation will fail.
To fix this, please recompile HIDAPI with a change of one line in hid.c (starting at line 222):
Before: DWORD share_mode = (enumerate)? FILE_SHARE_READ|FILE_SHARE_WRITE:FILE_SHARE_READ; After: DWORD share_mode = (enumerate)? FILE_SHARE_READ|FILE_SHARE_WRITE: FILE_SHARE_READ|FILE_SHARE_WRITE; |
修改方法: 到NXP 网站下载blhost源代码,修改libusbsio库文件hid.c,然后重新编译生成新的blhost.exe。附件是一个已经修改好的版本,供参考。
blhost.zip
(239.06 KB, 下载次数: 12)
|