-
Notifications
You must be signed in to change notification settings - Fork 7
Add types for Discover Identity structured VDMs #64
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
Merged
asasine
merged 26 commits into
OpenDevicePartnership:main
from
asasine:discover-identity
Apr 28, 2026
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
67ca4d1
Add SVID constants
asasine 7370000
Remove USB4 SVID
asasine b6aa096
Add Discover Identity types
asasine acd080e
Add tests for enum parsing
asasine e8ba3ed
Make header module public
asasine d7409fd
Make CommandType deserialization infallible
asasine ca56e4e
Add sop::IdHeaderVdo parsing
asasine ef35b78
add sop_prime::IdHeaderVdo parsing
asasine febbd19
Add parsing for ProductVdo
asasine f99f971
Add docs to Raw methods
asasine b8e18c3
Remove Header from response
asasine 8476d64
Fix incorrect parsing for SOP' product type
asasine e7bbc29
Change ResponseVdos to be fully parsed
asasine 5a4efa4
Fix clippy lint
asasine aa7515b
Fix typo
asasine d4b121f
Fix broken rustdoc links
asasine b20ac80
Add comment about clippy lint
asasine 74b1b16
Fix off-by-one in header::Raw
asasine 9b2d287
Added BCD and ProductId newtypes
asasine 2424c93
Add method to get response-specific ID Header VDO objects
asasine 18a2e39
cargo fmt
asasine 2397f74
cargo +nightly fmt
asasine 9202ebb
Fix comment
asasine d5be185
Add doc comment and derives for error type
asasine 8aad60a
Fix jjmn implementation and add tests
asasine 66387a8
Add doc comment to field
asasine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| //! Universal Serial Bus (USB) related types and traits from the USB 2.0 and 3.2 | ||
| //! specifications. | ||
|
|
||
| /// A Binary-Coded Decimal (BCD) format as defined by the USB 2.0 specification. | ||
| #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| pub struct Bcd(pub u16); | ||
|
|
||
| impl Bcd { | ||
| /// Parse the BCD value into its major, minor, and subminor components in the | ||
| /// format `jj.m.n` where | ||
| /// - `jj` is the major version (2 nibbles) | ||
| /// - `m` is the minor version (1 nibble) | ||
| /// - `n` is the subminor version (1 nibble) | ||
| pub const fn jjmn(&self) -> (u8, u8, u8) { | ||
| let jj = (self.0 >> 8) as u8; | ||
| let m = ((self.0 >> 4) & 0xF) as u8; | ||
| let n = (self.0 & 0xF) as u8; | ||
| (jj, m, n) | ||
| } | ||
| } | ||
|
|
||
| /// The USB Product ID as assigned by the USB-IF. | ||
| #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | ||
| #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| pub struct ProductId(pub u16); | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn bcd_jjmn() { | ||
| assert_eq!(Bcd(0x1234).jjmn(), (0x12, 0x3, 0x4)); | ||
| assert_eq!(Bcd(0xFEDC).jjmn(), (0xFE, 0xD, 0xC)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.