Skip to content
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

Revise the descriptor API #126

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

martinling
Copy link
Member

@martinling martinling commented Nov 12, 2024

An attempt to fix #125.

The key change here is the new include_in_config property of USBDescriptor, which specifies whether the descriptor should be included in a GET_CONFIGURATION response.

Descriptors with this property set to True will appear following their parent in the GET_CONFIGURATION response, in the same order in which they were added with the add_descriptor() method. They will not be fetchable with a GET_DESCRIPTOR request, and do not require the number property to be set.

Descriptors with this property set to False will not be included in a GET_CONFIGURATION response. They can be fetched with a GET_DESCRIPTOR request, and must have the number property set to an integer value, so that they can be retrieved by the identifying tuple of (type_number, number).

The USBClassDescriptor class is deprecated, but retained for backwards compatibility. It now simply sets include_in_config to True.

Stacked on #122 for now.

@martinling martinling force-pushed the arbitrary-descriptors branch from 7453315 to 4f9d760 Compare November 14, 2024 10:13
@martinling martinling force-pushed the arbitrary-descriptors branch from 4f9d760 to 2bbe8d2 Compare November 22, 2024 11:34
@martinling
Copy link
Member Author

This is dependent on #122 but otherwise ready to go.

@martinling martinling marked this pull request as ready for review November 22, 2024 11:38
@martinling martinling requested a review from antoinevg November 22, 2024 11:38
The bMaxPower value is stored in units of 2mA, per USB 2.0 Table 9-10.
The key change here is the `include_in_config` property of
USBDescriptor, which specifies whether the descriptor should be included
in a GET_CONFIGURATION response.

Descriptors with this property set to True will appear following their
parent in the GET_CONFIGURATION response, in the same order in which
they were added with the add_descriptor() method. They will not be
fetchable with a GET_DESCRIPTOR request, and do not require the
`number` property to be set.

Descriptors with this property set to False will not be included in a
GET_CONFIGURATION response. They can be fetched with a GET_DESCRIPTOR
request, and must have the `number` property set to an integer value, so
that they can be retrieved by the identifying tuple of
(type_number, number).

The USBClassDescriptor class is deprecated, but retained for backwards
compatibility. It now simply sets `include_in_config` to True.
@martinling martinling force-pushed the arbitrary-descriptors branch from 2bbe8d2 to bd38f7f Compare November 22, 2024 11:43
@martinling
Copy link
Member Author

Rebased now that #122 is merged.

@antoinevg antoinevg merged commit 2293d69 into greatscottgadgets:main Nov 22, 2024
1 check was pending
@martinling martinling mentioned this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Descriptor data model / API design issues
2 participants