Using PyUSB to play a packet captured by Wireshark

I grabbed a URB package using wirehark:

219774  438.775555000   host    31.0    USBVIDEO    66  SET CUR Request  [Brightness]

and Wireshark displays the following hex offset text:

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                                            ..

Now I am trying to play this package using PyUSB as follows: \

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))

which outputs:

11/66 written

which makes me think that I don’t understand how much metadata pyusb uses for data, how many metadata omissions, etc. Any ideas how I can fix this?

+4
source share

Source: https://habr.com/ru/post/1537147/


All Articles