From: Alan S. <st...@ro...> - 2010-01-28 17:45:01
|
On Wed, 27 Jan 2010, Pete Batard wrote: > /usr/src/libusb-pbatard# examples/xusb -k > Opening device... > > Reading device descriptor: > length: 18 > device class: 0 > S/N: 3 > VID:PID: 0BDA:0156 > bcdDevice: 5195 > iMan:iProd:iSer: 1:2:3 > nb confs: 1 > > Reading configuration descriptors: > nb interfaces: 1 > interface[0].altsetting[0]: num endpoints = 2 > Class.SubClass.Protocol: 08.06.50 > endpoint[0].address: 01 > max packet size: 0200 > polling interval: 00 > endpoint[1].address: 82 > max packet size: 0200 > polling interval: 00 > > Claiming interface 0... > Failed. Trying to detach driver... > Claiming interface again... > > Reading string descriptors: > String (1/3): "Generic" > String (2/3): "USB2.0-CRW" > String (3/3): "20060413092100000" > Reading Max LUN: > Max LUN = 0 > Sending Inquiry: > sent 6 CDB bytes > Pipe error > Input/output error Okay, there are two problems. First, I was wrong to say that the transfer length should be sizeof(cbw). I had forgotten that the structure would be padded to a 4-byte boundary. The transfer length must always be exactly 31 bytes. Second, when reading the INQUIRY data you have to be prepared to handle a STALL. (In fact, you should be prepared for this during any IN data transfer, but it's more likely to occur during an INQUIRY than during other commands.) The device may present a Unit Attention, telling you that it was just reset, for example. When this happens you have to clear the STALL and go straight ahead to the status phase of the transfer. In the case of INQUIRY you might then want to try repeating the command. Alan Stern |