64位Windows环境下HID设备通讯问题的研究
2015-05-30崔阳
崔阳

摘 要:针对64位Windows操作系统对HID设备与主机应用程序的通讯造成的新问题,首先简要介绍了Windows环境下HID设备的性能特点和通讯机制,以此为基础提出一个面向64位Windows的HID设备通讯接口,并在Wave Panel上进行了编程实验。结果证明该接口的通用性较强,能够较好地实现64位Windows下HID设备与主机应用程序的通讯功能。
关键词:HID;通讯接口;中断传输;64位Windows
中图分类号:TP319 文献标识码:A
Abstract:To solve the new problems of communication between human interface devices (HID) and the computer applications caused by 64-bit Windows,characteristics and the communication mechanism of HID in Windows environment are introduced first,based on which a communication interface for 64-bit Windows is designed and programmed on Wave Panel.Results show that communication function in 64-bit Windows environment can be better achieved through the interface.
Keywords:HID;communication interface;interrupt transmission;64-bit Windows
1 引言(Introduction)
HID(Human Interface Device,人机接口设备)是一类低速USB设备,具有使用方便、响应迅速、成本低廉等优点。典型的有键盘、鼠标、游戏杆等。
HID设备研发和使用中面临的重要问题之一是设备与主机应用程序的通讯。Windows 7的发布标志着Windows操作系统开始从32位向64位过渡,因此有必要对64位Windows环境下HID设备通讯程序的一些新问题进行研究。
2 HID设备的性能特点(Performance characteristics of HID)
HID设备虽然也属于USB设备,但还具备一些自身特点,主要有:
(1)单次传输的数据量小,且以设备状态信息和控制信息为主。单次传输数据通常在8字节到1024字节。数据存储在报表(Report)结构内[1]。
(2)使用轮询方式。HID设备会在一个设定的时间间隔内检测一次设备,若发现设备状态有变化则会生成输入报表,并发送到主机[2]。
(3)多数采用中断方式通讯。这种方式适用于周期性、延迟低的数据[3],符合HID设备的应用特点。
3 HID设备的通讯过程(Communication process of HID)
Windows 98及之后的各版本Windows已包含HID驱动程序[4,5],应用程序可直接调用相关API函数实现HID设备的通讯。该过程可分为以下四个模块:
(1)设备识别和打开。一台主机有可能同时连接多台HID设备,因此在通讯前必须确定要进行通讯的设备并打开。……
