1

我试图弄清楚如何为 Microsoft LifeCam 打开“TrueColor”。我有几个来自 USBSniffer 的大 USB 日志,以及当我单击 Microsoft 软件中的复选框时始终显示的一些序列。这是启用序列开头的请求和设备响应(如果我误解了此数据,请纠正我):

[156918643 ms] UsbSnoop - FilterDispatchAny(ac56afd2) : IRP_MJ_INTERNAL_DEVICE_CONTROL
[156918643 ms] UsbSnoop - FdoHookDispatchInternalIoctl(ac56b1ea) : fdo=88b25448, Irp=889911d8, IRQL=0
[156918643 ms]  >>>  URB 1482 going down  >>> 
-- URB_FUNCTION_CLASS_INTERFACE:
  TransferFlags          = 00000001 (USBD_TRANSFER_DIRECTION_IN, ~USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 00000002
  TransferBuffer       = abb04b86
  TransferBufferMDL    = 00000000
  UrbLink                 = 00000000
  RequestTypeReservedBits = 00000000
  Request                 = 00000085
  Value                   = 00001600
  Index                   = 00000500
[156918644 ms] UsbSnoop - MyInternalIOCTLCompletion(ac56b126) : fido=00000000, Irp=889911d8, Context=894d6c98, IRQL=2
[156918644 ms]  <<<  URB 1482 coming back  <<< 
-- URB_FUNCTION_CONTROL_TRANSFER:
  PipeHandle           = 885639a0
  TransferFlags        = 0000000b (USBD_TRANSFER_DIRECTION_IN, USBD_SHORT_TRANSFER_OK)
  TransferBufferLength = 00000002
  TransferBuffer       = abb04b86
  TransferBufferMDL    = 8837fee0
    00000000: 40 00
  UrbLink              = 00000000
  SetupPacket          =
    00000000: a1 85 00 16 00 05 02 00

现在,我想通过 PyUSB 发送我看到的请求序列,但是当我发送第一个请求时,我得到:

>>> ret = dev.ctrl_transfer(0x80, 0x85, 0x1600, 0x0500, 8)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\Python24\Lib\site-packages\usb\core.py", line 702, in ctrl_transfer
    self.__get_timeout(timeout)
  File "c:\Python24\Lib\site-packages\usb\backend\libusb0.py", line 539, in ctrl_transfer
    timeout
  File "c:\Python24\Lib\site-packages\usb\backend\libusb0.py", line 387, in _check
    raise USBError(errmsg, ret)
usb.core.USBError: (None, 'usb_control_msg: invalid request 0x85')

对于它的价值,一个简单的 GET_STATUS 似乎工作:

>>> ret = dev.ctrl_transfer(0x80, 0, 0, 0, 8)
>>> print ret
array('B', [0, 0])

为什么在一种情况下得到答复的请求在另一种情况下无效?句法?设备状态?

4

1 回答 1

2

从非常有用的USB Made Simple中,请求类型的最高 3 位格式如下:

D7 Data direction
0 - Host-to-device
1 - Device-to-host
D6:5 Type
0 = Standard
1 = Class
2 = Vendor
3 = Reserved

日志说我正在使用 USB 的类接口(参见“URB_FUNCTION_CLASS_INTERFACE”),因此 RequestType 特定于设备类(音频、物理......在这种情况下是视频)。GET_STATUS 命令有效,因为它是标准类型。

所以更正确的命令是

ret = dev.ctrl_transfer(0xa0, 0x85, 0x1600, 0x0500, 8)

我说的正确,因为命令返回数据,但它仍然不是我期望的数据!

编辑:为了完全逼真,我需要根据 USB Made Simple 的请求类型表的其余部分将接收者指定为接口:

D4:0 Recipient
0 = Device
1 = Interface
2 = Endpoint
3 = Other
4-31 = Reserved

...并将长度设置为与嗅探请求相同,因此该命令的真实版本是:

ret = dev.ctrl_transfer(0xa1, 0x85, 0x1600, 0x0500, 2)
于 2012-11-15T05:40:35.023 回答