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

Fix rust-analyzer error test #20

Closed
wants to merge 112 commits into from
Closed

Conversation

okhsunrog
Copy link
Contributor

When adding this project to RustRover IDE or VS Code rust-analyzer runs on project sync. It fails with this message:

error[E0308]: mismatched types
   --> /home/okhsunrog/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/test_result.rs:102:18
    |
101 |         None => match status.signal() {
    |                       --------------- this expression has type `Option<i32>`
102 |             Some(libc::SIGABRT) => TestResult::TrFailed,
    |                  ^^^^^^^^^^^^^ expected `i32`, found `usize`

I suggest adding harness = false to disable these checks.
You can take a look here, for example:
rust-lang/rust#125714
esp-rs/esp-idf-template@d084765

The commit in my branch fixes the issue.

Avoid panicing when receiving PDO's with either an unknown kind or an
unknown supply in the Augmented PDO's.

Signed-off-by: Sjoerd Simons <[email protected]>
Even though the SourceCapabilities message is just a list of 32 bit
pdos, some properties are encoded in the first pdo (aka the mandatory
vsafe 5v one). Moving to a newtype allows adding some utility functions
to get the whole message capabilities directly on it.

Signed-off-by: Sjoerd Simons <[email protected]>
Gracefully handle unknown pdo aspects when parsing
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.
The voltage/current/power values in the various pdos require
translations to real numbers; Add utility functions for this and rename
the field to raw_ to avoid accidentally using the wrong function.

For clarity also suffix the function by the returned unit if it's not
the standard unit.

Also for consistency use max instead of maximum everywhere

Signed-off-by: Sjoerd Simons <[email protected]>
Add utility functions to access various part of source capabilities
Allow pretty printing of the various top-level types

Signed-off-by: Sjoerd Simons <[email protected]>
Add parser for Adjustable Voltage Supply requests; Also add an enum
covering the various supported request objects, similar to th PDO enum.
Using e.g. si::u8::ElectricPotential with a base unit of decivolts can
not be converted to milivolts (which is the obvious conversion) as the
u8 milivolts range is only 0 - 255mv.. Same for current. Expand the
storage to 16 bits so the full range can be exposes as milivolt/miliamp

Signed-off-by: Sjoerd Simons <[email protected]>
There are over 20 different control messages specified in specification
version 3.2. Rather then adding them all to the Message enum one-by-one,
add a catch-all for control message (as per definition they have no
extra information).
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.
pdo: expand storage types to cover common units
VendorDefined messages need at least 4 bytes of payload to be valid
Add support to parse request data objects
@okhsunrog okhsunrog closed this Jun 18, 2024
@okhsunrog okhsunrog deleted the fix-analyzer branch June 18, 2024 13:17
@okhsunrog okhsunrog restored the fix-analyzer branch June 18, 2024 13:17
@okhsunrog okhsunrog deleted the fix-analyzer branch June 18, 2024 13:19
@okhsunrog
Copy link
Contributor Author

Sorry, messed up with git commands, wanted to change username in my last commit

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.

1 participant