The usb
class contains several subclasses providing access to the interfaces, descriptors, and endpoints of the usb device. The subclasses included are:
USB descriptor report all of the device's attributes. An endpoint is a specific type of descriptor that describes the terminus of a communication flow between the host and the device.
The InterfaceList
class iterates over each Interface
within the usb device. Each Interface
then contains:
DescriptorList
through GetDescriptorList()
EndpointList
through GetEndpointList()
These methods allow access to all the descriptors and endpoints of the interface.
Note: Endpoints are still considered descriptors and therefore can also be accessible through the GetDescriptorList()
method.
The hierarchy of these subclasses can be seen in Figure 1.
Figure 1
These examples iterate through all the descriptors in a USB device. The example iterates through all of the USB Interfaces and then iterates through all the descriptors in each interface.
Note: To iterate through the endpoints instead, replace interface.getDescriptorList()
with interface.getEndpointList()
.
std::optional<InterfaceList> interface_list; status = InterfaceList::Create(my_client, true, &interface_list); if (status != ZX_OK) { ... } for (auto& interface : *interface_list) { for (auto& descriptor : interface.GetDescriptorList()) { ... } }
std::optional<InterfaceList> interface_list; status = InterfaceList::Create(my_client, true, &interface_list); if (status != ZX_OK) { ... } for (auto& interface : *interface_list) { auto dList_itr = interface.GetDescriptorList().begin(); // or cbegin(). do { ... } while (++dList_itr != interface.GetDescriptorList().end()); }