LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Closed Thread
 
Search this Thread
Old 01-18-2013, 09:10 AM   #1
niekvanagt
LQ Newbie
 
Registered: Jan 2013
Posts: 2

Rep: Reputation: Disabled
usb_control msg sends 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?
 
Old 01-21-2013, 12:56 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,856

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Continue here: http://www.linuxquestions.org/questi...es-4175446585/
 
  


Closed Thread


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
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
"Extra bytes at the end of class file" when installing WTK2.2 eikeland Linux - Software 1 03-06-2007 08:59 PM
IPC msgrcv - writing overflows memory extra 4 bytes tara Programming 1 11-08-2005 11:40 PM
slooze error: validateInputs(); $msg = $mySlooze->renderPage($vars); echo $msg; ?> rioguia Linux - Software 0 01-26-2003 08:59 PM


All times are GMT -5. The time now is 07:00 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