On Wed, Jul 8, 2009 at 10:53 PM, Xiaofan Chen<xiaof...@gmail.com> wrote:
> On Wed, Jul 8, 2009 at 12:43 PM, Xiaofan Chen<xiaof...@gmail.com> wrote:
>> I will ask in the libusb mailing list why it still works under Linux
>> and Mac OS X.
>
> Here is the answer from Alan Stern in the libusb mailing list.
>
>>> Apparently the code is not correct.
>>> After this one, the usb_handle should not be valid any more.
>>>                               usb_reset(result->usb_handle);
>>>
>>> So it will fail the next two.
>>>                               /* usb_set_configuration required under win32 
>>> */
>>>                               usb_set_configuration(result->usb_handle,
>>> dev->config[0].bConfigurationValue);
>>>                               usb_claim_interface(result->usb_handle, 0);
>>>
>>> But in reality, the above "wrong codes" seem to work under Linux
>>> and Mac OS X even though it failed under Windows.
>>>
>>> Why does it work under Linux and Mac OS X?
>>> Does the usb_handle survive the usb_reset() under Linux and Mac OS X?
>>
>> Under Linux, sometimes it does and sometimes it doesn't.  It depends on
>> whether any of the descriptors have changed and on what version of the
>> kernel you are using; with 2.6.27 or later the handle won't survive.
>>
>>> Is this something related to the following?
>>> http://kerneltrap.org/mailarchive/linux-usb/2008/11/28/4259024
>>
>> No; it is related to this:
>>
>>        http://marc.info/?l=linux-usb&m=121425133223338&w=2
>>
>> Alan Stern
>>
>>
>
> So the code is apparently wrong. It will not work in the later version
> of the Linux kernel. So we need to find a better patch even under Linux.
>

This is also in line with the libusb 0.1 documentation.
http://libusb.sourceforge.net/doc/function.usbreset.html
****************
Name
usb_reset -- Resets a device
Description

int usb_reset(usb_dev_handle *dev);

usb_reset resets the specified device by sending a RESET down the port
it is connected to. Returns 0 on success or < 0 on error.

    Causes re-enumeration: After calling usb_reset, the device will need
to re-enumerate and thusly, requires you to find the new device and open
a new handle. The handle used to call usb_reset will no longer work.
******************


-- 
Xiaofan http://mcuee.blogspot.com
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to