Hello,
I am developing a Linux USB driver for a Video capture device.
By initializing this device I have to set some settings. To do that I call the usb_control_msg function. This function seems to work correctly but when I look at the USB packets with the USB sniffer of wireshark the data that is send is not my data but only '0x00'.
When I set the 'size' parameter of that function to 17, my first data byte is showing up in the sniffed packets. When I set it to 18, my first two bytes, and so on.
I also tried to set the 'data' parameter to &mydata+16. &mydata+1 results in 16 '0x00' bytes followed by the second byte of my data buffer.
Also tried to alloc my data buffer with the kmalloc(x, GFP_KERNEL) call in stead of just initialize on the stack, but that doesn't make any difference. No matter what I try, I cant get the 16 '0x00' bytes out of the URB packet.
My code is:
Code:
int rc, i;
unsigned char data[13];
data[0] = 0x0b;
data[1] = 0x4a;
data[2] = 0xc0;
data[3] = 0x01;
data[4] = 0x01;
data[5] = reg;
data[6] = val;
data[7] = 0xFF;
data[8] = 0x06;
data[9] = 0x00;
data[10] = 0x00;
data[11] = 0x00;
data[12] = 0x00;
rc = usb_control_msg(somagic->dev,
usb_sndctrlpipe(somagic->dev, 0x00),
SOMAGIC_USB_STD_REQUEST,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0B, // VALUE
0x00, // INDEX
data,
sizeof(data)+16, // + 16 for the extra '0x00' bytes
1000);
And what's in a sniffed packet is the following:
40 03 0b 00 00 00 1d 00 // header
00 00 00 00 00 00 00 00 // where data should be
00 00 00 00 00 00 00 00 // where data should be
0b 4a c0 01 01 0c 40 ff // my data
06 00 00 00 00 // my data
The first row are metadatabytes / header / requesttype
The second row should be my data but there (and on the third row) are the 16 '0x00' bytes. On the fourth row my data buffer is shown...
The question is: What are those 16 bytes and how can I get rid of them? Can anyone help me with this?