It's also what the standard says to do. > Now you can see the problem. Initially we _do not know_ the maximum > packet size for endpoint 0. It could be any power of 2 between 8 and 64. > So if we wanted to read an 18-byte descriptor, should we expect the device > to transfer two 8-byte packets followed by a 2-byte packet, or a 16-byte > packet followed by a 2-byte packet, or an 18-byte packet? If we guess > wrong the transfer will fail. > > The answer is to read just the first eight bytes of the descriptor. That > can always be done with a single packet transfer. Contained within those > eight bytes is the actual maxpacket size for endpoint 0. Once we know > that, we can go ahead and transfer the entire descriptor.
By the way Alan, maybe there should be a check that the maxpacket size is valid. I have a device that sometimes returns a maxpacket size of zero (in fact the whole 8 bytes read is zero - maybe nothing was read but the error reporting logic is wrong somewhere?). Given the number of bad USB devices out there, maybe it is wise to add a sanity check here, and fail (-EIO?) if a rubbish value is seen. What do you think? Ciao, Duncan. ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
