|
From: Bertrik S. <be...@si...> - 2007-06-12 17:49:25
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Adam Kropelin wrote: > On Mon, Jun 11, 2007 at 03:47:31PM +0100, Dave Higton wrote: >>> -----Original Message----- >>> From: lib...@li... >>> [mailto:lib...@li...] On >>> Behalf Of Adam Kropelin >>> Sent: 2007 June 11 15:43 >>> To: lib...@li... >>> Subject: Re: [Libusb-win32-devel] Everything but >>> usb_bulk_read works... >>> >>> On Mon, Jun 11, 2007 at 03:23:38PM +0100, Dave Higton wrote: >>>> Error 22 is an invalid parameter. Input endpoint addresses >>>> have to have the top bit set - this is incompatible with the >>>> Linux version. >>> It's not incompatible at all. Not setting that bit is a bug on any >>> platform. It just so happens that Linux lets you get away with it. >> It depends on your POV. When you talk to somebody, do you refer to >> endpoint 0x81 or endpoint 1? I refer to 1, and I bet you do too. >> Linux has explicit code to set the top bit so that either is equally >> valid. > > There is an argument to made for the API to be forgiving; you're > performing a read, so obviously you must have meant to provide an input > endpoint address. Since you didn't, the library will fix it up for > you. That type of API makes me uncomfortable; I don't like an API that > thinks it knows more about what I want to do than me...but some > people like to program that way. There's also an argument to be made > for consistency; not every API call can easily do such a fixup for you. > See usb_resetep(), for example. That one is even explicitly documented. > > Personally I prefer consistency and exactness: Supply the actual > endpoint address, as specified in bEndpointAddress. Since we have to do > that for some API calls already, its best to do it for all of them. I agree completely. The libusb API is not exact on what is meant with the 'ep' parameter. The USB2.0 specification differentiates between an *endpoint number* and an *endpoint address*, where the endpoint number is a simple 4-bit number and the endpoint address is the endpoint number combined with the direction bit. USB2.0 specification suggests that it is possible for a device to have both a 0x01 and 0x81 endpoint address (see for example paragraph 5.3.1.2: "Full-speed devices can have additional endpoints only limited by the protocol definition (i.e., a maximum of 15 additional input endpoints and 15 additional output endpoints).") In that case, having libusb setting or clearing the top bit would amount to converting the endpoint into a different and possibly unrelated endpoint address, which is not acceptable. IMO, the Linux implementation is wrong because it allows people to be sloppy about this. Regards, Bertrik -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGbtyYETD6mlrWxPURAkD1AJ4qwJaQxIcOQ/xB7sa9rpeG4DmZ7wCgvMN0 Bf7kLCiO9cMY8bPJBlbjvZs= =dh9I -----END PGP SIGNATURE----- |