Libusbpp icon indicating copy to clipboard operation
Libusbpp copied to clipboard

Bidirectional endpoints not supported

Open mmmspatz opened this issue 4 years ago • 1 comments

I have a device that has two bulk endpoints with addresses 0x05 and 0x85. Libusbcpp ignores the latter completely for the following reason.

In InterfaceImpl::CreateEndpoints(), a new std::shared_ptr<Endpoint> named pEndpoint is created and then inserted into a std::map like so:

https://github.com/zarthcode/Libusbpp/blob/389ceea9bc974f1c2b1cf3151a32795c04832288/src/InterfaceImpl.cpp#L424

The map key being generated by Endpoint::Number, which is implemented like so: https://github.com/zarthcode/Libusbpp/blob/389ceea9bc974f1c2b1cf3151a32795c04832288/src/EndpointImpl.cpp#L57

Since the key omits the upper nibble of the address, it's impossible to store a pair of endpoints with opposite directions but the same endpoint number. The second insert has no effect (because the key already exits), and the newly created Endpoint is deleted.

A subsequent call to Interface::getEPNumberByIndex() throws std::logic_error(LibUSB::InterfaceImpl::getEPNumberByIndex(): Endpoint not found.)

mmmspatz avatar Dec 28 '20 01:12 mmmspatz

Made a PR: #13

mmmspatz avatar Dec 28 '20 02:12 mmmspatz