HID设备(USB)详细说明

发布于 2024-09-23 23:49:14 字数 631 浏览 2 评论 0原文

我将条码扫描仪连接到 USB 端口。我需要将模式从 HID 键盘更改为串行端口仿真(系统知道读卡器被视为常规 HID 设备,而不是 HID 系统键盘),以将扫描仪中的数据直接获取到我的应用程序中。到目前为止,一切都运行良好。

问题是我需要知道 VID 和 PID 号才能找到我的设备。我知道这些值,但我想通过名称找到我的设备。

我找到了一个名为SimpleHIDWrite的程序:

http://www.lvr.com/hidpage.htm

当我在我的设备上启动该程序时有一个很好的描述“符号条形码扫描仪”。

我试图自己达到这个名字 - 我使用了结构:

HIDD_ATTRIBUTES
HIDP_CAPS
SP_DEVICE_INTERFACE_DATA
SP_DEVICE_INTERFACE_DETAIL_DATA
SP_DEVINFO_DATA

但是我在结构中找不到允许我访问此描述的字段。

不幸的是,我找不到 SimpleHIDWrite 源代码来学习如何执行此操作。

你能帮助我吗?

I connected my barcode scanner to a USB port. I needed to change the mode from HID keyboard to serial port emulation (the reader is know seen by the system as regular HID device and not a HID system keyboard) to get data from scanner directly into my app. So far it's all working great.

The problem is that I need to know the VID and PID numbers to find my device. I know these values but I want to find my device by name.

I found a program called SimpleHIDWrite:

http://www.lvr.com/hidpage.htm

When I launch the program my device has a nice description "Symbol Bar Code Scanner".

I tried to reach this name by my self - I used structures:

HIDD_ATTRIBUTES
HIDP_CAPS
SP_DEVICE_INTERFACE_DATA
SP_DEVICE_INTERFACE_DETAIL_DATA
SP_DEVINFO_DATA

However I couldn't find a field in structure that allows me to gain access to this description.

Unfortunately I can't find SimpleHIDWrite source code to learn how to do this.

Can you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稀香 2024-09-30 23:49:14

在该页面的同一部分,有一个带有源代码的 HidTest 程序。该程序显然使用了通过名为“Delphi 的 HID 控制器组件套件”的链接找到的 HID 控制器代码。也许这可以给你你正在寻找的东西? (至少如果你能从所有 Delphi 代码中挑选出相关的部分的话。)


我最近一直在研究确切的事情,但我还没有时间实际尝试其中的任何一个。所以接下来的内容有点推测。

我相信您需要做的是打开与 USB 设备的设备连接。 HID 级别的函数似乎没有提供您想要的描述。 这里< /a> 是一个关于从 USB 设备获取 VendorID 和 ProductID 的不同 SO 问题。我认为您可以使用非常类似的技术来阅读 USB_DEVICE_DESCRIPTOR,从而访问 iProduct 字段,我相信这应该是您想要的描述。

我遇到过一个名为 USBView 的程序,它显然可以与 USB 设备进行这种通信(除其他外)。我在此处找到了它的编译版本。然而,该源代码据称包含在 Windows 驱动程序开发工具包中。这可能是 C 或 C++ 源代码,但我还没有时间从 Microsoft 下载 DDK 并确认实际存在的内容。


编辑:

我有时间更深入地研究这个问题。以及您对 HidD_GetProductString 的发现也很有帮助。我还找到了此页来自英特尔的示例。那里的“Display HID”程序展示了使用该功能的一种方法。

根据该函数的文档和该示例,我的印象是它正在从设备读取相同的iProduct,显然是从 HID 级别而不是 USB 级别执行此操作。或者类似的东西。我唯一确定的是,到目前为止它正在我自己的测试程序中运行。

In the same section of that page, there is a HidTest program with source. That program apparently uses HID controller code found through a link called "HID Controller component suite for Delphi". Perhaps that could give you what you're looking for? (At least if you can pick the relevant pieces out of all that Delphi code.)


I have been researching the exact kind of thing recently, but I haven't had the time to actually try any of it yet. So what follows here is a bit speculative.

I believe what you need to do is open connection to the device as USB device. Functions at the HID level don't appear to give the description you want. Here is a different SO question about getting the VendorID and ProductID from a USB device. I think you could use a very similar technique to read the USB_DEVICE_DESCRIPTOR and thus get access to the iProduct field, which I believe should be the description you want.

I have come across a program called USBView that apparently does this kind of communication (among other things) with USB devices. I found a compiled version of it here. However the source is supposedly included in the Windows Driver Development Kit. That would likely be C or C++ source, but I have not yet had time to download the DDK from Microsoft and confirm what's actually there.


EDIT:

I've had time to dig into this deeper. And what you found out about HidD_GetProductString was helpful too. I've also found this page of examples from Intel. The "Display HID" program there shows one way to use that function.

Based on that function's documentation and that example, I get the impression that it is reading the same iProduct from the device, apparently doing so from the HID level instead of the USB level. Or something like that. All I know for sure is that it is working in my own test program so far.

仄言 2024-09-30 23:49:14

我在 lvr.com 论坛上找到了问题的答案:

HID 设备 (USB) 详细说明 (lvr.com/forums)

I found the answer to my question here on the lvr.com forums:

Detailed description of HID device (USB) (lvr.com/forums)

不甘平庸 2024-09-30 23:49:14

嗯...iProduct 的问题是,首先我必须向设备发送描述设备的字符串请求,然后接收数据。条形码扫描仪是只读的,因此我无法向设备发送数据(请求)。

我发现在 SimpleHID 中有我的扫描仪的描述“Symbol bar ocde Scanner”,它与我在控制面板(设备和打印机)中看到的名称完全相同。所以我的问题是如何获取该设备的名称?

Hmm...the problem with iProduct is that first I have to send request for this Strings describing device to the device and then recive data. Bar code scanners are read only so I can't send data (request) to device.

I discovered that in SimpleHID there is a description of my scanner "Symbol bar ocde scanner" and it's exactly the same name that I see i control panel (devices and printers). So my question is how to get this name of device?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文