|
From: Tim R. <ti...@pr...> - 2011-01-24 18:00:21
|
Jef Driesen wrote: > The second question is related to reading some data where the total amount of > data is not known in advance. What is the best way to do this? Allocating a > fixed buffer and keep reading until I get fewer bytes back than requested? Does > this work similar compared to normal I/O (e.g. read returning 0 on EOF)? Or is > it more similar to serial or socket I/O where you have to specify a timeout to > avoid blocking forever if no more data arrives? A single USB "transfer", which can be larger than a packet, is terminated when the device sends a packet that is smaller than the max packet size. So, if you send down a transfer of 30 packets (15,360 bytes), the transfer will continue as long as the device sends back full 512-byte packets. When the device is out of data, it should send back a short packet. At that point, the transfer is complete and will be returned to the application, regardless of how much data had been transferred. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |