-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endpoints addresses assumed to be consecutively assigned #3
Labels
Comments
There was an issue w/endpoint addresses - I had incorrectly made a few assumptions that gave me similar issues. This is probably one of them. Simply remove that logic_error and push, or I can do the same this afternoon. |
ghost
assigned zarthcode
Oct 29, 2012
rexut
added a commit
to rexut/libusbpp
that referenced
this issue
Nov 28, 2016
LibUSB::InterfaceImpl::getEndpoint() throws a logic_error exception if the index and endpoint number are not equal. This presents a problem communicating with a USB device, based on the Cypress CY7C68001 chip which only implements endpoint numbers 2, 4, 6 and 8 in addition to 0. Libusbpp had incorrectly made a assumption that all USB devices have linear endpoint numbering. The Libusbpp should be handled the linear and non linear numbering in same way. LibUSB::Interface{Impl}::getEndpoint() has been refectored to expect a number (not a index) explicitly. LibUSB::Interface{Impl}::getEPNumberByIndex() is a new public method to translate a given endpoint index to the corresponding endpoint number. This number can be used together with getEndpoint() to get the corresponding endpoint object in a fast way. Example: std::shared_ptr<LibUSB::Interface> pInterface = /* ... */ for (int epidx = 1; epidx <= pInterface->NumEndpoints(); epidx++) { std::shared_ptr<LibUSB::Endpoint> pEndpoint; pEndpoint = pInterface->getEndpoint( pInterface->getEPNumberByIndex(epidx) ); /* ... */ } A new use case for getEPNumberByIndex() is the creation of a map of endpoint numbers by it corresponding index as a key. Walk throught such a list gives access to all available endpoint numbers independent of a specific context. Example: typedef std::map<int, int> EndpointNumbers_t; EndpointNumbers_t mEndpointNumbers; std::shared_ptr<LibUSB::Interface> pInterface = /* ... */ for (int epidx = 1; epidx <= pInterface->NumEndpoints(); epidx++) { mEndpointNumbers.insert( std::make_pair( epidx, pInterface->getEPNumberByIndex( epidx ) ) ); } /* ... */ for (const auto &epnum : mEndpointNumbers) { std::shared_ptr<LibUSB::Endpoint> pEndpoint; pEndpoint =pInterface->getEndpoint(epnum.second); /* ... */ } Based on this concept the interface class provides the new public method LibUSB::Interface::getEndpointNumbers() to reduce the effort for the user. Example (the same as befor, but just simpler): std::shared_ptr<LibUSB::Interface> pInterface = /* ... */ LibUSB::Interface::EndpointNumbers_t mEndpointNumbers; mEndpointNumbers = pInterface->getEndpointNumbers(); /* ... */ for (const auto &epnum : mEndpointNumbers) { std::shared_ptr<LibUSB::Endpoint> pEndpoint; pEndpoint =pInterface->getEndpoint(epnum.second); /* ... */ } Related-to-issue: zarthcode#3 Signed-off-by: Stephan Linz <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LibUSB::InterfaceImpl::getEndpoint() throws a logic_error exception if the index and endpoint number are not equal. This presents a problem communicating with my USB device, based on the Cypress cy7c68001 chip which only implements endpoints 2,4,6 and 8 in addition to 0. Shouldn't this configuration be handled in Libusbpp?
The text was updated successfully, but these errors were encountered: