LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-21-2013, 08:22 AM   #1
niekvanagt
LQ Newbie
 
Registered: Jan 2013
Posts: 2

Rep: Reputation: Disabled
usb_control_msg send extra '0x00' bytes


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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
usb_control msg sends extra '0x00' bytes niekvanagt Linux - General 1 01-21-2013 12:56 PM
What is this -> SRC=0.0.0.0 DST=255.255.255.255 LEN=328 TOS=0x00 PREC=0x00 TTL=128 ID carves Linux - Networking 5 08-17-2008 09:26 PM
why I can only send two bytes data to HID device? wch_zj Programming 0 01-05-2006 12:04 AM
IPC msgrcv - writing overflows memory extra 4 bytes tara Programming 1 11-08-2005 11:40 PM


All times are GMT -5. The time now is 05:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration