罗技F710手柄描述符数据抓包 - 以及stm32读取usb-hid数据程序_stm32 usb 抓包-程序员宅基地

技术标签: 移动机器人  stm32  通讯协议  

  • 硬件: 罗技F710游戏手柄、一台笔记本电脑
  • 软件: USBlyzer分析仪(下载地址

大家都知道,罗技F710上有D模式和X模式,D模式是普通模式,每帧数据传输8个字节;X模式是xbox手柄模式,有更多的信息,每帧传输15个字节(因为有陀螺仪数据)。

D模式

  • 先看8个字节的通讯协议
    图片
  • 以下是抓包内容,各种描述符分类清晰,在stm32的usb驱动程序中可以按照命名轻易找到对应的接口来修改。
Connection Status Device connected
Current Configuration 1
Speed Full (12 Mbit/s)
Device Address 14
Number Of Open Pipes 2

Device Descriptor Logitech Cordless RumblePad 2

Offset Field Size Value Description
0 bLength 1 12h
1 bDescriptorType 1 01h Device
2 bcdUSB 2 0200h USB Spec 2.0
4 bDeviceClass 1 00h Class info in Ifc Descriptors
5 bDeviceSubClass 1 00h
6 bDeviceProtocol 1 00h
7 bMaxPacketSize0 1 08h 8 bytes
8 idVendor 2 046Dh Logitech, Inc.
10 idProduct 2 C219h
12 bcdDevice 2 0305h 3.05
14 iManufacturer 1 01h “Logitech”
15 iProduct 1 02h “Logitech Cordless RumblePad 2”
16 iSerialNumber 1 00h
17 bNumConfigurations 1 01h

Configuration Descriptor 1 Bus Powered, 98 mA

Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 0029h
4 bNumInterfaces 1 01h
5 bConfigurationValue 1 01h
6 iConfiguration 1 04h “PACER-X03.05_A”
7 bmAttributes 1 80h Bus Powered
4…0: Reserved …00000
5: Remote Wakeup …0… No
6: Self Powered .0… No, Bus Powered
7: Reserved (set to one)(bus-powered for 1.0) 1…
8 bMaxPower 1 31h 98 mA

Interface Descriptor 0/0 HID, 2 Endpoints

Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 02h
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 00h
7 bInterfaceProtocol 1 00h
8 iInterface 1 00h

HID Descriptor

Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 21h HID
2 bcdHID 2 0111h 1.11
4 bCountryCode 1 00h
5 bNumDescriptors 1 01h
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 0077h 119 bytes

Endpoint Descriptor 81 1 In, Interrupt, 4 ms

Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
1…0: Transfer Type …11 Interrupt
7…2: Reserved 000000…
4 wMaxPacketSize 2 0020h 32 bytes
6 bInterval 1 04h 4 ms

Endpoint Descriptor 01 1 Out, Interrupt, 8 ms

Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 01h 1 Out
3 bmAttributes 1 03h Interrupt
1…0: Transfer Type …11 Interrupt
7…2: Reserved 000000…
4 wMaxPacketSize 2 0020h 32 bytes
6 bInterval 1 08h 8 ms

Interface 0 HID Report Descriptor Game Pad

结合通讯协议,以及报告描述符,可以轻易写joystick驱动代码(用stm32的usb主机模式,读取usb-hid类设备驱动程序即可)

Item Tag (Value) Raw Data
Usage Page (Generic Desktop) 05 01
Usage (Game Pad) 09 05
Collection (Application) A1 01
Collection (Logical) A1 02
Report ID (1) 85 01
Report Size (8) 75 08
Report Count (4) 95 04
Logical Minimum (0) 15 00
Logical Maximum (255) 26 FF 00
Physical Minimum (0) 35 00
Physical Maximum (255) 46 FF 00
Usage (X) 09 30
Usage (Y) 09 31
Usage (Z) 09 32
Usage (Rz) 09 35
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Size (4) 75 04
Report Count (1) 95 01
Logical Maximum (7) 25 07
Physical Maximum (315) 46 3B 01
Unit (Eng Rot: Degree) 66 14 00
Usage (Hat Switch) 09 39
Input (Data,Var,Abs,NWrp,Lin,Pref,Null,Bit) 81 42
Unit (None) 66 00 00
Report Size (1) 75 01
Report Count (12) 95 0C
Logical Maximum (1) 25 01
Physical Maximum (1) 45 01
Usage Page (Button) 05 09
Usage Minimum (Button 1) 19 01
Usage Maximum (Button 12) 29 0C
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Count (1) 95 01
Report Size (8) 75 08
Usage Page (Vendor-Defined 1) 06 00 FF
Logical Maximum (255) 26 FF 00
Physical Maximum (255) 46 FF 00
Usage (Undefined) 09 00
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
End Collection C0
Collection (Logical) A1 02
Report ID (2) 85 02
Report Count (7) 95 07
Report Size (8) 75 08
Logical Maximum (255) 26 FF 00
Physical Maximum (255) 46 FF 00
Usage Page (Vendor-Defined 1) 06 00 FF
Usage (Vendor-Defined 3) 09 03
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
End Collection C0
Collection (Logical) A1 02
Report ID (3) 85 03
Usage (Vendor-Defined 4) 09 04
Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02
End Collection C0
End Collection C0

X模式

  • 协议解析
字节 0 1 2 3 4 5 6,7 8,9 10,11 12,13 14
定义 ID 0x14 Buttons Buttons LT RT Left X Axis Left Y Axis Right X Axis Right Y Axis Mode

图片

Connection Status Device connected
Current Configuration 1
Speed Full (12 Mbit/s)
Device Address 15
Number Of Open Pipes 2

Device Descriptor Wireless Gamepad F710

Offset Field Size Value Description
0 bLength 1 12h
1 bDescriptorType 1 01h Device
2 bcdUSB 2 0200h USB Spec 2.0
4 bDeviceClass 1 FFh Vendor-Specific
5 bDeviceSubClass 1 FFh
6 bDeviceProtocol 1 FFh
7 bMaxPacketSize0 1 08h 8 bytes
8 idVendor 2 046Dh Logitech, Inc.
10 idProduct 2 C21Fh
12 bcdDevice 2 0305h 3.05
14 iManufacturer 1 01h “Logitech”
15 iProduct 1 02h “Wireless Gamepad F710”
16 iSerialNumber 1 03h “8F699F3C”
17 bNumConfigurations 1 01h

Configuration Descriptor 1 Bus Powered, 98 mA

Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 0030h
4 bNumInterfaces 1 01h
5 bConfigurationValue 1 01h
6 iConfiguration 1 00h
7 bmAttributes 1 80h Bus Powered
4…0: Reserved …00000
5: Remote Wakeup …0… No
6: Self Powered .0… No, Bus Powered
7: Reserved (set to one)(bus-powered for 1.0) 1…
8 bMaxPower 1 31h 98 mA

Interface Descriptor 0/0 Vendor-Specific, 2 Endpoints

Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 02h
5 bInterfaceClass 1 FFh Vendor-Specific
6 bInterfaceSubClass 1 5Dh
7 bInterfaceProtocol 1 01h
8 iInterface 1 00h

Unrecognized Class-Specific Descriptor

Offset Field Size Value Description
0 bLength 1 10h
1 bDescriptorType 1 21h
2 14 10 01 01 24 81 14 03 00 03 13 02 00 03 00

Endpoint Descriptor 81 1 In, Interrupt, 4 ms

Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
1…0: Transfer Type …11 Interrupt
7…2: Reserved 000000…
4 wMaxPacketSize 2 0020h 32 bytes
6 bInterval 1 04h 4 ms

Endpoint Descriptor 02 2 Out, Interrupt, 8 ms

Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 02h 2 Out
3 bmAttributes 1 03h Interrupt
1…0: Transfer Type …11 Interrupt
7…2: Reserved 000000…
4 wMaxPacketSize 2 0020h 32 bytes
6 bInterval 1 08h 8 ms

手柄完整的数据协议:https://blog.csdn.net/liudijiang/article/details/86693435#Logitech_Wireless_Gamepad_F710_2

程序

顺便放一个我的程序,裸机读取usb手柄数据并发给串口,基于stm32h743,使用意法半导体官方IDEstm32cubeide生成并修改了部分驱动内容。

蓝奏云:https://www.lanzoui.com/i8wf6de

PS: 后续有时间更新一下生成和修改的过程,并移植到freertos中官方ide直接生成的freertos + usb-host代码有bug,会直接内存泄露)。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m0_37340621/article/details/104103027

智能推荐

laravel ajax提交登陆存储session,并输出-程序员宅基地

文章浏览阅读495次。前端输出session{{ Session::get('username') }}ajax提交<div>{{ Session::get('username') }}</div><meta name="csrf-token" content="{{ csrf_token() }}"><!-- ajax提交必写验证 --> ..._auth::login larvavel 登录之后打印存储的session

R相关知识-程序员宅基地

文章浏览阅读7.1k次。1.R语言基础知识https://www.runoob.com/r/r-tutorial.html2.环境和工具下载https://cran.r-project.org/ R 语言官方网站https://www.rstudio.org/download/daily/desktop/windows/ RStudio下载3.R开发工具下载安装教程

一文会用 github 新利器——github ci-程序员宅基地

文章浏览阅读5.3k次。github ci 是什么  github ci 是 github 提供的一个依据 git 相关事件触发的自动化脚本服务。简单的说,当触发github的事件(push/pull request等)后,github官方会提供一个服务器环境,自动的运行先前配置的脚本,差不多近似于 gitlab 的 ci。为项目创建 github ci  github 来检测项目是否存在 github ci 就是查看该项目根目录下的.github/workflows是否存在yml的配置文件。因此可以通过在根目录下创建 .g_github ci

网络故障和网络诊断工具(1.0)_网络诊断工具支持从公网向私网的网络诊断工具发起诊断测试-程序员宅基地

文章浏览阅读8.3k次,点赞6次,收藏41次。网络故障概述在信息化社会里,各企事业单位对网络的依赖程度越来越高,网络随时都可能发生故障,影响正常工作。所以,必须掌握相应的技术及时排除故障。有些单位如电信、电子商务公司、游戏运营商等使用的网络一旦发生故障,若不能及时排除,会产生很大的损失。这些单位一般会安装网络故障管理软件,通过软件来管理和排除网络的故障。从网络故障本身来说,经常会遇到的故障有:物理层故障数据链路层故障网络层故障以太网络故障广域..._网络诊断工具支持从公网向私网的网络诊断工具发起诊断测试

Pixhawk原生固件PX4之日期时间的确定_px4日志日期未知-程序员宅基地

文章浏览阅读2.5k次。19701.1 00:00:00年到2000.1.1 00:00:00有多少秒?软件中哪里给的默认时间2000年的?_px4日志日期未知

Ogre射线精确查询_ogre射线准确求交-程序员宅基地

文章浏览阅读736次。bool PickEntity(Ogre::RaySceneQuery* mRaySceneQuery, Ogre::Ray &ray, Ogre::Entity **result, Ogre::uint32 mask ,Ogre::Vector3 &hitpoint, bool excludeInVisible,const Ogre::String& excludeobject, Ogre::R_ogre射线准确求交

随便推点

webpack plugin源码解析(二) copy-webpack-plugin_copywebpackplugin-程序员宅基地

文章浏览阅读1k次。用于创建文件系统的快照。快照是文件系统状态的一份副本,包含了文件的元数据以及每个文件的最后修改时间戳。_copywebpackplugin

HTML 表单制作_表单输入元素 课堂练习:请编写html代码-程序员宅基地

文章浏览阅读2.5w次,点赞76次,收藏435次。HTML 表单用于收集不同类型的用户输入。表单是一个包含表单元素的区域表单元素是允许用户在表单中输入内容,比如:文本域(textarea)、下拉列表、单选框(radio-buttons)、复选框(checkboxes)等等表单使用表单标签 来设置HTML 表单-输入元素多数情况下被用到的表单标签是输入标签()。输入类型是由类型属性(type)定义的。文本域(Text Fie..._表单输入元素 课堂练习:请编写html代码

终端美化微软官方解决方案——Windows Terminal_mintty美化-程序员宅基地

文章浏览阅读699次。本文目录介绍下载方式终端美化介绍参考微软官方的介绍文档 An overview on Windows Terminal | Microsoft Docs:Windows Terminal 是一个面向命令行工具和 shell(如命令提示符Command Prompt、PowerShell 和适用于 Linux 的 Windows 子系统 (WSL))用户的新式终端应用程序。 它的主要功能包括多个选项卡、窗格、Unicode 和 UTF-8 字符支持、GPU 加速文本呈现引擎,你还可用它来创建你自己的主题_mintty美化

【Java SE】一文详解next和nextLine的区别-程序员宅基地

文章浏览阅读7.4k次,点赞2次,收藏9次。了解如何处理用户输入是编程中的一个基本任务。在Java中,我们经常用到的一个类就是Scanner,它提供了许多方法来读取和解析不同类型的输入。然而,即使是这样的基础概念,也存在着让人混淆的地方。例如,next()和nextLine()两个方法,它们在使用上有何区别?为何我们在某些情况下需要使用next(),而在其他情况下需要使用nextLine()?在这篇文章中,我们将详细地探讨这两个方法的不同,让我们一起开始吧!_next和nextline

从最佳并发用户数和最大并发用户数看性能测试_激活用户数,最大并发-程序员宅基地

文章浏览阅读5k次,点赞2次,收藏9次。从最佳并发用户数和最大并发用户数看性能测试原文地址:http://www.cnblogs.com/jackei/archive/2006/11/20/565527.html文章中介绍一个理发店理论,然后引出最佳并发用户数和最大并发用户数的概念 背景:理发店共有3名理发师,每名理发师完成一次理发都耗时1小时,店里有还有一些位子供客人等位,每个客人在_激活用户数,最大并发

linux中crontab定时执行脚本_cron 每周日凌晨6点执行-程序员宅基地

文章浏览阅读6.4k次。阅读目录1. cron服务【Ubuntu环境】 2. crontab用法 3. 编辑crontab文件 4. 流程举例 5. 几个例子Linux中,周期执行的任务一般由cron这个守护进程来处理。cron读取一个或多个配置文件,这些配置文件中包含了命令行及其调用时间。cron的配置文件称为“crontab”,是“cron table”的简写。回到顶部1. cron服务【Ubu..._cron 每周日凌晨6点执行