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

Add support to parse request data objects #18

Merged
merged 4 commits into from
Jun 15, 2024

Conversation

sjoerdsimons
Copy link
Contributor

No description provided.

si::u16::ElectricPotential::new::<_20millivolts>(self.raw_output_voltage())
}

pub fn operating_current_ma(&self) -> si::u16::ElectricCurrent {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ma suffix not needed given the return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (and the other comment as well) - Looks like i missed some changes when an earlier draft on the si changes commits

}
}

impl FixedVariableRequestDataObject {
pub fn to_bytes(&self, buf: &mut [u8]) {
LittleEndian::write_u32(buf, self.0);
}

pub fn operating_current_ma(&self) -> u16 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this and max_operating_current_ma use SI units in the return type?

Similar to what was done on the other pdo packets add utility functions
to get the real watts/power values from the raw values in the packet.
Add parser for Adjustable Voltage Supply requests; Also add an enum
covering the various supported request objects, similar to th PDO enum.
To be able to parse Request messages some state needs to be kept as the
request objects don't indicate their type only their position as per the
last source capabilities.

Add a simple trait for maintaining pdo state that current just
translates between the object position of the request type and the
matching type. This trait is for SourceCapabilities (potentially wrapped
in an Option) which allows implementations to maintain state simply by
saving the last SourceCapabilities message.
@fmckeogh
Copy link
Owner

@sjoerdsimons Thanks for your work!

@fmckeogh fmckeogh merged commit 010a6c2 into fmckeogh:main Jun 15, 2024
2 checks passed
okhsunrog added a commit to okhsunrog/usb-pd-rs that referenced this pull request Jun 18, 2024
Add support to parse request data objects
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.

2 participants