WinUsb API调用Composite设备 [英] WinUsb API calls for Composite device

查看:114
本文介绍了WinUsb API调用Composite设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Winusb应用程序访问复合设备时遇到了一些问题。

I am facing some problem in accessing composite device using Winusb application.

我创建了两个复合设备接口(HID + BULK)。当我将复合设备连接到Windows 10主机并通过设备管理器查看时,在通用串行总线设备下我可以看到我的设备名称。但HID设备未显示在设备管理器中的Human
接口设备下。我能够通过批量端点发送/接收数据,但我无法通过HID端点发送数据。我想使用WinUsb API访问这两个函数(Bulk和Hid)。我是否需要在WinUsb上配置任何使用复合设备
的东西?

I have created composite device with two interfaces (HID + BULK). When I connect the composite device to windows 10 host and see through Device manager, under Universal Serial Bus device I could see my device name. But HID device is not shown under Human Interface Device in device manager. I am able to send/receive data over Bulk endpoint but I am not able to send data over HID endpoint. I want to access both functions (Bulk and Hid) using WinUsb API. Do I need to configure anything to use composite device on WinUsb?

有任何解决上述问题的建议吗?

Any suggestion to solve the above issue?

问候,

Rane

推荐答案

如果您要使用自定义驱动程序处理它们,那么为什么要使用两个接口? 只需将两个端点放在一个接口中,映射到WinUSB。 呈现真正的HID界面的唯一优势是,如果您要让
标准HID驱动程序处理它。 如果您没有这样做,请跳过HID界面。

If you're going to handle them both with a custom driver, then why use two interfaces at all?  Just put both endpoints in a single interface, mapped to WinUSB.  The only advantage in presenting a genuine HID interface is if you are going to let the standard HID drivers handle it.  If you're not doing that, then skip the HID interface.

您遇到的具体问题是Windows枚举USB设备的方式导致的问题。 假设你的VID是1234,你的PID是5678. 然后,您的第一次尝试将匹配硬件ID USB \VID_1234& PID_5678。 
您将在注册表中的Enum键中找到它。

The specific problem you're seeing is an icky issue caused by the way Windows enumerates USB devices.  Let's say your VID is 1234 and your PID is 5678.  Then, your very first attempts would have matched the hardware ID USB\VID_1234&PID_5678.  You'll find that in the Enum key in the registry.

现在让我们假设您重做描述符以提供两个接口。 在新安装的系统中,复合设备USB \VID_1234& PID_5678将分配给标准的usbccgp.sys驱动程序,该驱动程序将枚举您的接口并创建两个
新设备:USB \VID_1234& PID_5678& MI_00和USB \ VID_1234& PID_5678& MI_01,每个都有自己的驱动程序。

Now let's say you redo your descriptors to offer two interfaces.  In a freshly installed system, your composite device USB\VID_1234&PID_5678 would be assigned to the standard usbccgp.sys driver, which would enumerate your interfaces and create two new devices: USB\VID_1234&PID_5678&MI_00 and USB\VID_1234&PID_5678&MI_01, each of which would get its own driver.

但由于您的注册表已经匹配USB \ VID_1234& PID_5678,复合设备将是分配给您的WinUSB驱动程序,它将接收两个接口。  usbccgp.sys不参与,因此没有人创建单独的特定于接口的
硬件ID。

But because your registry already has a match for USB\VID_1234&PID_5678, the composite device will be assigned to your WinUSB driver, which will receive both interfaces.  Usbccgp.sys is not involved, so no one created the separate interface-specific hardware IDs.

如果你真的需要这样做,你需要卸载原始复合材料设备管理器中的设备应该删除该注册表项,然后再次枚举。

If you really need to do this, you will need to uninstall the original composite device from Device Manager, which should delete that registry entry, and let it enumerate again.


这篇关于WinUsb API调用Composite设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆