hid usb通信_如何使用HID协议与其USB设备通信

本文介绍如何在Windows环境下,不依赖DLL,通过简单的应用实现与USB设备的HID通信。文章涵盖警告、介绍、背景和使用代码四个部分,提供了相关函数的详细说明,帮助开发者进行USB/HID数据的读写操作。
摘要由CSDN通过智能技术生成

hid usb通信

(You need Visual Studio.)

(您需要Visual Studio。)

警告 (Warning)

This USB sniffer, because of its user mode method access to hardware, cannot read HID packets with RID at 0, it's due to Windows protection level to prevent keyloggers/spying software.

此USB嗅探器由于其用户模式方法可访问硬件,因此无法读取RID为0的HID数据包,这是由于Windows的保护级别所致,以防止键盘记录器/间谍软件。

Example of use:

使用示例:

DEVICE_VID  = 1A2C;
DEVICE_PID  = 0001;
USAGE_PAGE  = FF00;
USAGE       = 0000;
REPORT_ID   = FF;

Do not add 0x, else the application will crash (I haven't added 0x prefix support)

不要添加0x,否则应用程序将崩溃(我还没有添加0x前缀支持)

Image 1

Image 2

Unfortunately, the write function can only send 1 byte (+ Report ID byte), it's because I was too lazy to add a fully functional text parse function ^^.

不幸的是, write函数只能发送1个字节(+报告ID字节),这是因为我懒得添加一个功能齐全的文本解析函数^^。

But it's working, the most important thing, you can verify it via any USB sniffer (use your own values for that).

但这是有效的,最重要的是,您可以通过任何USB嗅探器对其进行验证(为此使用您自己的值)。

介绍 (Introduction)

This article shows you how to using the USB/HID protocol under Windows to be able to send/receive USB packets from any USB devices connected to the PC.

本文向您展示如何在Windows下使用USB / HID协议,以便能够从连接到PC的任何USB设备发送/接收USB数据包。

And without using DLL, just an application is needed.

而且,无需使用DLL,仅需要一个应用程序即可。

背景 (Background)

This article was possible with this WDK sample:

使用此WDK示例可以实现本文:

Basically, it's just a rewrite of this sample, but in a simple form.

基本上,这只是对该示例的重写,但是形式很简单。

使用代码 (Using the Code)

Declaration of variables, WinAPI functions and using: https://pastebin.com/MSRAYJ5b

变量声明,WinAPI函数和使用: https : //pastebin.com/MSRAYJ5b

All that you need is those functions:

您所需要做的就是这些功能:

HidD_Get
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值