API Reference
relic_usb_host_descriptor_parser
Helper to parse USB descriptors
Author(s): Cooper Dalrymple
Implementation Notes
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s USB Host Descriptors library: https://github.com/adafruit/Adafruit_CircuitPython_USB_Host_Descriptors
- class relic_usb_host_descriptor_parser.ConfigurationDescriptor(device: usb.core.Device, configuration: int = 0)
Fetch and parse the specified configuration descriptor and its interface and endpoint descriptors from a device.
- Parameters:
device (
usb.core.Device) – The USB device to fetch descriptors from.configuration (
int, optional) – The zero-based index of the device configuration to fetch. Defaults to 0.
- get_class_identifier(interface: int = 0)
A
tuplecontaining the class and subclass of an interface within this configuration.- Parameters:
interface (
int, optional) – The index of the desired interface. Defaults to 0.
- class relic_usb_host_descriptor_parser.Descriptor(descriptor: bytearray, length: int = None, descriptor_type: int = None)
The base class of a descriptor parser. Validates descriptor data length and type. The constructor will throw a
ValueErrorexception if the data is invalid.
- class relic_usb_host_descriptor_parser.DeviceDescriptor(device: usb.core.Device)
Fetch and parse all device, configuration, interface, and endpoint descriptors.
- Parameters:
device (
usb.core.Device) – The USB device to fetch descriptors from.
- property configurations: tuple
A
tupleof the descriptors for the configurations asConfigurationDescriptorobjects offered by this device.
- get_class_identifier(configuration: int = 0, interface: int = 0) tuple
A
tupleof 4intelements containing the class and subclass of this device as well as the class and subclass of the designated configuration and interface.
- class relic_usb_host_descriptor_parser.EndpointDescriptor(descriptor: bytearray)
Parse the provided endpoint descriptor. This class should only be instantiated by
ConfigurationDescriptor.- Parameters:
descriptor (
bytearray) – The endpoint descriptor data to parse.
- property interval: int
The expected polling interval of an endpoint. If the device is low-speed or full-speed, the interval is in increments of 1ms. If the device is high-speed, the interval can be calculated using the formula: “2^(interval-1) * 125 µs”.
- class relic_usb_host_descriptor_parser.HIDDescriptor(descriptor: bytearray, device: usb.core.Device, interface: int = 0)
Parse the provided HID descriptor. This class should only be instantiated by
ConfigurationDescriptor.- Parameters:
descriptor (
bytearray) – The HID descriptor data to parse.
- class relic_usb_host_descriptor_parser.InterfaceDescriptor(descriptor: bytearray)
Parse the provided interface descriptor. This class should only be instantiated by
ConfigurationDescriptor.- Parameters:
descriptor (
bytearray) – The interface descriptor data to parse.
- property hid_descriptor: HIDDescriptor
The HID descriptor of the interface if it is an HID-compliant interface. Otherwise, this property will be
None.
- property in_endpoint: EndpointDescriptor
The first endpoint designated as an input within the interface.
- property out_endpoint: EndpointDescriptor
The first endpoint designated as an output within the interface.