我用wireshark捕获了一个URB数据包:
219774 438.775555000 host 31.0 USBVIDEO 66 SET CUR Request [Brightness]
和 Wireshark 显示以下偏移十六进制文本:
0000 c0 f6 0b a3 00 88 ff ff 53 02 00 1f 01 00 00 00 ........S.......
0010 2c a1 51 53 00 00 00 00 57 5e 0b 00 8d ff ff ff ,.QS....W^......
0020 02 00 00 00 02 00 00 00 21 01 00 02 00 02 02 00 ........!.......
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 ..
现在我正在尝试通过以下方式使用 PyUSB 重播此数据包:\
device = usb.core.find(idVendor=0x04f2, idProduct=0xb2ea)
device.detach_kernel_driver(0)
cfg = device.get_active_configuration()
intf = cfg[(0,0)]
ep = intf[0]
data = 'c03998300288ffff5302000401000000d78f51530000000084ad08008dffffff02000000020000002101000200020200000000000000000000000000000000003200'
data = [ int(''.join([data[i], data[i+1]]), base=16) for i in range(0, len(data), 2)]
print '%d/%d written' %(ep.write(object_to_write), len(object_to_write))
输出:
11/66 written
这让我觉得我不明白 pyusb 为数据添加了多少元数据,wireshark 省略了多少元数据等。有什么想法可以解决这个问题吗?