On Tue, 12 Jul 2005, Jayaprakash Shanmugam wrote:

> Hello All,
> 
>   I use control transfer to read some bytes of data from a device. 
> But I dont know how much data it is going to give me.

Do you know an upper bound?

> If I give less number of bytes as size, the usb_control_msg() function
> skips data (returns when the size number of bytes is read).  If I give
> more number of bytes as size, the usb_control_msg() function returns
> timeout error.

The timeout error should not happen.  The device should send as much data 
as it can, finishing with a short packet if the amount of data is less 
than what you asked for.  Seeing the short packet, the computer will know 
that the transfer is complete, won't try to wait for any more data, and 
won't timeout.

> Is there any way to read n number of bytes from the device (using
> control transfer) when n is not known apriori ?

You should ask for the maximum amount of data that can be sent.  If the
device fails to reply at all because the requested size is too large, or
if it fails to terminate its reply with a short packet, then it is not
behaving properly.

> Note: If I use usb_bulk_msg() with size = 1024, it always returns even
> if there is less number of data.

That's how usb_control_msg() should work, too.

Alan Stern



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to