On 22/09/2010 10:36, Toby Gray wrote:
  ...
>>> but then discovered that if a usb error had been
>>> seen then Socket::Close would hang on wait_pop while trying to receive
>>> data, so I made DefaultRead return immediately if a usb error has been
>>> seen (a41446a2ac3d9f96d859).
>> In DoRead()...
>>
>> +               if( data.GetSize() == 0 )
>> +                       // Reading 0 bytes indicates an error such as
>> +                       // USB port reset.
>> +                       //
>> +                       // Any further attempts to read or write to
>> +                       // the USB device will just hang.
>> +                       throw Usb::Error(-EIO, "Read zero bytes from USB 
>> port");
>>
>> I think this is the wrong place to handle USB errors, and the entire
>> way to fix this depends on whether a zero read is always an error or not.
>> I'm not sure that it is, but if so, then we can safely add a new exception,
>> which would solve some of the Close() logic too.
>>
>> I'll ask on the libusb list.
> Good point. I was thinking in terms of what a zero byte read on a socket
> would means, but obviously this isn't a socket.
I've seen the reply on the libusb list saying that it's perfectly valid 
for a bulk read to return 0, thanks for checking that. I'll have a 
further look into the problem, but I think I might have to ask on the 
libusb list about how to determine when a port has been reset.

I would hope that there is some way to, as it seems that when Barry next 
tries to use the USB interface after the zero read that the generic USB 
kernel driver complains about trying to use an interface without having 
claimed it.

Regards,

Toby

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Barry-devel mailing list
Barry-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/barry-devel

Reply via email to