-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
usb-pd/src/messages/pdo.rs
Outdated
si::u16::ElectricPotential::new::<_20millivolts>(self.raw_output_voltage()) | ||
} | ||
|
||
pub fn operating_current_ma(&self) -> si::u16::ElectricCurrent { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
usb-pd/src/messages/pdo.rs
Outdated
} | ||
} | ||
|
||
impl FixedVariableRequestDataObject { | ||
pub fn to_bytes(&self, buf: &mut [u8]) { | ||
LittleEndian::write_u32(buf, self.0); | ||
} | ||
|
||
pub fn operating_current_ma(&self) -> u16 { |
There was a problem hiding this comment.
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.
53d488b
to
96948b9
Compare
@sjoerdsimons Thanks for your work! |
Add support to parse request data objects
No description provided.