Ticket #50 (new enhancement)

Opened 6 years ago

Last modified 4 years ago

Add libusb_reset_endpoint()

Reported by: stuge Owned by:
Milestone: Component: libusb-1.0
Keywords: endpoint reset toggle Cc:
Blocked By: Blocks:


Change History

comment:1 Changed 5 years ago by xiaofan

Any new updates on this? Not so sure if this is possible to be implemented across different platform.

comment:2 Changed 4 years ago by hjelmn

This would be easy to implement for both Darwin and Linux. Question is would it be better to provide a clear toggle or clear halt/stall?

comment:3 Changed 4 years ago by xiaofan


libusb has already clear hat/stall. But it does not have the reset data toggle feature, not explicitly anyway. I think this should be implemented as a best-case-it-will-work-but-not-guaranteed thingy as per Alan Stern's comment. As per Alan, under Linux, if a usb_clear_halt call is successful, it anyway will call usb_reset_endpoint. But whether it will successful reset the data toggle will depend on USB host controller implementation as per Alan.

Last edited 4 years ago by xiaofan (previous) (diff)

comment:4 Changed 4 years ago by hjelmn

We don't have a per endpoint (or pipe) clear halt/stall. But I agree it would probably be best to provide a clear toggle (that is all I really have under OSX to work with anyway). I can do the clear using ClearPipeStallBothEnds? or ClearPipeStall?. Descriptions below.

@function ClearPipeStall?
@abstract Clears the halted bit and the data toggle bit on the pipe's endpoint in the controller.
@discussion This function also returns any outstanding transactions on the pipe with status kIOUSBTransactionReturned.

If there are outstanding asynchronous transactions on the pipe, the callbacks will happen. The data
toggle may need to be resynchronized. The driver may handle this by sending a ClearFeature?(ENDPOINT_HALT)
to the default control pipe, specifying the device's endpoint for this pipe. See also
@link apple_ref/C/instm/IOUSBInterfaceInterface190/ClearPipeStallBothEnds/ ClearPipeStallBothEnds? @/link.

@function ClearPipeStallBothEnds?
@abstract Equivalent to ClearPipeStall?.
@discussion This function is equivalent to ClearPipeStall? except that it also attempts to clear the halt and

toggle bits on the device's endpoint for the pipe by sending a ClearFeature?(ENDPOINT_HALT) to the
default control pipe in the device, specifying the endpoint for the pipe represented by pipeRef. For
most devices, this resynchronizes the data toggle between the two endpoints to ensure that there is
no loss of data.

Anyway, this is a simple enough feature that, if we can agree on the semantics it should provide, it can easily be included in the 1.0.16 release IMHO. Would have to convince Pete or someone to write one for Windows though or just leave it as not supported.

Note: See TracTickets for help on using tickets.