Windows下USB驱动SET_INTERFAC失败 bad pipe flags
2021-06-04
607
0
最近在调试一个UVC摄像头,由于项目的原因,需要在驱动下对UVC协议进行模拟,以实现在驱支层打下固件,从而读取数据的要求。本以为这是一个很简单的事,没想到还是耽搁了一点时间,花了一点小功夫。
打开USB摄像头,对UVC协议的模拟主要是是USB特定类请求的模拟,通过我们的基础知识可知道,上层应用或驱动要打开视频流,是需要对UVC视频流接口进行特定为清求。这些这特类请求无非就是GET_CUR,SET_CUR,GET_MIN,GET_MAX等,且对应的选择子是UVC 视频流接口控制请求的VS_PROBE_CONTROL 01 和VS_COMMIT_CONTROL 0x02。
更多参见:http://www.usbzh.com/article/detail-45.html
例如我们要打开视频格式为1,视频帧格式1的USB摄像头,一般的过程如下:
Device Length Phase Data Description
------ -------- ----- ----------------------------------------------------------------
43.0 CTL a1 81 00 01 02 00 22 00 GET CUR
43.0 34 IN 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 20 00 00 00 00 00 00 03 01 00 01
43.0 CTL 21 01 00 01 02 00 22 00 SET CUR
43.0 34 OUT 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 00 00 00 00 00 00 00 03 01 00 01
43.0 CTL a1 81 00 01 02 00 22 00 GET CUR
43.0 34 IN 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 20 00 00 00 00 00 00 03 01 00 01
43.0 CTL a1 83 00 01 02 00 22 00 GET MAX
43.0 34 IN 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 20 00 00 00 00 00 00 03 01 00 01
43.0 CTL a1 82 00 01 02 00 22 00 GET MIN
43.0 34 IN 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 20 00 00 00 00 00 00 03 01 00 01
43.0 CTL 21 01 00 02 02 00 22 00 SET CUR
43.0 34 OUT 01 00 01 01 15 16 05 00 00 00 00 00 00 00 00 00
00 00 00 00 50 00 00 20 00 00 00 00 00 00 03 01 00 01
43.0 CTL 01 0b 00 00 02 00 00 00 SET INTERFACE
具体的分析过程可点击:http://www.usbzh.com/article/detail-418.html
注意,这里面有一个SET_INTERFACE对于批量传输是可以根据情可省略掉的,不过对于同步传输是这个是必须的。但就是这一个简单的SET_INTERFACE出了问题。原文中,这个抓包是过程是没有问题的,但在实际过程中是出了问题的。
43.0 CTL 01 0b 00 00 02 00 00 00 SET INTERFACE
43.0 USTS c0005000 bad pipe flags
这里显示为 USTS c0005000
bad pipe flags.
最后经查是由于在选择接前,申请的URB内存空间未清空导致脏数据引起的。
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936