5

I captured an URB packet with wireshark:

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

and Wireshark displays following offset hex 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 replay this packet using PyUSB in the following way:\

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 does pyusb prepend to data, how much metadata wireshark omits etc. Any ideas how could I fix this?

siemanko
  • 1,389
  • 1
  • 13
  • 26

1 Answers1

0

Looking quickly I notice that variable data is quite long. What you are sending with variable data probably is a packet but must be formatted. URB packet structure is formatted by different data, like _URB_HEADER , _URB_HEADER ...

Take a look at this link may explain better. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/usb/ns-usb-_urb