如何调试人机界面设备? [英] How to debug Human Interface Device?

查看:125
本文介绍了如何调试人机界面设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台带有USB接口的条形码扫描仪,因此它显示为HID。

I have a bar-code scanner with USB interface, so it appears as an HID.

必须断点是有原因的

这使我的Delphi IDE排在最前面,它在断点处停止,其余的条形码就像插入到我的代码中一样可以在键盘前面输入(以某种方式,因为USB扫描仪只是另一个HID)。

That brings my Delphi IDE to the front, it stops on the breakpoint and the rest of the bar-code is injected into my code as if it had been typed front the keyboard (which, in a way it has, as the USB scanner is just another HID).

有什么办法可以避免这种情况?还是要对输入源进行初步检查?

Is there any way to avoid this? Or to add an initial check as to the source of the input?

这让我非常烦恼,以至于我现在正在寻找带有RS232接口的扫描仪。

It annoys me so much that I am now looking for a scanner with an RS232 interface.

推荐答案

问题是HID设备以称为 <报告>的数据包将信息发送回计算机。 。

对于磁刷或条形码扫描仪,报告 包含整个数字。

The problem is that HID "devices" send information back to the computer in packets known as "reports".
In the case of a mag-swipe, or bar-code scanner, the "report" contains the entire number.

这就是说,您不会收到每个字符的报告,而是一次收到整个字符串。 (如果是磁刷,则您将在同一报告中收到全部两个或三个轨道。)

Which is to say, you don't receive reports character-by-character, but the entire string at once. (In the case of a mag-swipe, you will receive all two, or three, tracks in the same report).

因此,您的代码不会破坏在第一个字符上 ,它会在 <整个报告上断开 。剩下的角色就在那里,您可以认为这是一个奖励(如果您不想看这些角色,则不必这样做)。但是您将不会再收到后续字符的报告

So your code doesn't break "on the first character", it breaks "on the entire report". The fact that the remaining characters are there you can think of as a bonus (if you don't want to look at them you don't have to). But you won't be receiving any more "reports" for subsequent characters.

我无法想象您会'的任何原因t 想立即知道条形码。但是大多数磁悬浮扫描和条形码扫描仪都可以配置为模拟键盘,而不是通用的HID设备。在这种情况下,您将收到多条 WM_KEYDOWN 消息。

i cannot imagine any reason why you wouldn't want to know the bar-code at once. But most mag-swipe and bar-code scanners can be configured to emulate a keyboard, rather than a generic HID device. In that case you will receive multiple WM_KEYDOWN messages.

这篇关于如何调试人机界面设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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