[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libusb-devel
Subject:    Re: [Libusb-devel] How to send/receive data using gadgetfs bulk
From:       Alan Stern <stern () rowland ! harvard ! edu>
Date:       2011-12-15 19:09:21
Message-ID: Pine.LNX.4.44L0.1112151400370.1644-100000 () iolanthe ! rowland ! org
[Download RAW message or body]

libusb-devel is not the appropriate mailing list for this discussion, 
as gadgetfs has no connection with libusb.  If you have further 
questions, please send them to <linux-usb@vger.kernel.org>.

On Thu, 15 Dec 2011, Winson Yung wrote:

> Thanks Alan, indeed I re-used the file handles (for en1in-bulk and
> en1out-bulk) opened by ep_config, but first write to source_fd just
> got stucked forever.

It won't return until the host reads the data you are trying to send.

> Also, in the ep_config(), the comment says 1 for fs or hs, 2 for fs +
> hs like the following code:
> 
> 	/* one (fs or ls) or two (fs + hs) sets of config descriptors */

Read it more closely.  It doesn't say "1 for fs or hs, 2 for fs + hs".  
It says one set of descriptors for fs or ls, and two sets of 
descriptors for fs + hs.

> 	*(__u32 *)buf = 1;	/* tag for this format */
> 	memcpy(buf + 4, fs, USB_DT_ENDPOINT_SIZE);
> 
> 	if (HIGHSPEED)
> 		memcpy(buf + 4 + USB_DT_ENDPOINT_SIZE, hs, USB_DT_ENDPOINT_SIZE);
> 
> 	status = write(fd, buf, 4 + USB_DT_ENDPOINT_SIZE
> 			+ (HIGHSPEED ? USB_DT_ENDPOINT_SIZE : 0));
> 
> Should the code be written like this?
> 
> 	if (HIGHSPEED) {
> 		*(__u32 *)buf = 2;	/* tag for this format */
> 		memcpy(buf + 4 + USB_DT_ENDPOINT_SIZE, hs, USB_DT_ENDPOINT_SIZE);
> 	}

No, it shouldn't; it should be written the way it _is_ written.  If you
want to run at high speed, you must provide two sets of descriptors:
one for full speed and one for high speed.  This is required by the
USB-2.0 spec: Any device capable of connecting at high speed must also
be capable of connecting at full speed.

> Since I was trying to use the highspeed bulk xfer, I tried changing
> tag format to 2, and I got this error:
> 
> simple_source_thread config ep1in-bulk error 22 (Invalid argument)
> simple_sink_thread config ep1out-bulk error 22 (Invalid argument)

That's not surprising, since 2 is not a valid tag value.

Alan Stern


------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity 
while improving strategic productivity.  Learn More! 
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
Libusb-devel mailing list
Libusb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic