|
From: Tim R. <ti...@pr...> - 2014-04-15 17:21:38
|
abdullah unutmaz wrote: > > I read you answers again, firstly thank you for your time. > > In the beginning I had no idea about USB communication, found > something in web including explanations about interrupt, > isochronous... modes. Then I followed tutorials, discussions, forms > etc. and then applied some examples. I had never heard something > related to "libusb_set_interface_alt_setting", I am going to check > that, because it might be neccessary later in another project. It is generally only used with isochronous and interrupt pipes. > By the way, might I ask how I could specify the length of a buffer, by > checking the length of desciriptor in bytes? Because I am still trying > to understand better. The length of the descriptor has nothing to do with your buffering. You have to decide your buffer sizes, based on a couple of things: 1. The maximum packet size in the endpoint descriptor (wMaxPacketSize). That's very different from the descriptor length, which will always be 7 bytes (OK, sometimes it's 9 bytes). Your buffers always need to be an integer multiple of the max packet size. The max packet size includes the "number of transactions" multiplier in high speed, and the burst multiplier in super speed. 2. Efficiency vs latency. For efficiency, you generally want to use a large buffer. If you send down a megabyte, the hardware will keep filling that buffer until it is done. If you send down 2,000 requests of 512 bytes, you'll get the same data, but you will have made 2,000 round trips through the kernel to handle completions and resubmissions. The tradeoff for that efficiency is increased latency. If you send down that megabyte buffer, you can't process any of the data until the whole thing is filled. There are some applications where that doesn't matter -- you have to know what you're doing with the data to make that decision. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |