USB PD: deprecated and invalid Passive Cable VDO encodings are rejected instead of normalized

Open Beginner friendly
#91 1 comment 0 reactions 1 assignee View on GitHub

@RobertZ2011 is already working on this.

Since Oct 26, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
embedded-iot

Research direction

Read src/vdm/structured/command/discover_identity/passive_cable_vdo.rs, especially the two try_from implementations and the named failing tests. Run the tests for this file to confirm the current behavior, then apply Table 6.42’s specified receive-side fallbacks at the parse boundary. Done means the invalid current encodings normalize to 3A and deprecated voltage encodings normalize to 20V, with the valid-variant test updated accordingly.

Written by the indexing model from the issue text.

Description

bug conformance

Summary

Table 6.42 specifies receive-side fallbacks for four encodings. The parser treats all four as errors, so conforming cables are rejected.

What the specification requires

USB PD R3.2 V1.2 S6.4.12.3.8, Table 6.42 (Passive Cable VDO).

Maximum VBUS Voltage:

00b - 20V

01b..10b - Deprecated, receiver Shall assume 00b (20V).

11b - 50V

VBUS Current Handling Capability:

00b - Invalid; receiver Shall assume 01b (3A).

01b - 3A

10b - 5A

11b - Invalid; receiver Shall assume 01b (3A).

These are mandated normalizations (Shall assume), not parse errors.

What the code does

VbusCurrentHandlingCapability::try_from returns Err(()) for 00b and 11b. MaximumVbusVoltage maps 01b/10b to ThirtyVolt/FortyVolt, which are not reportable values for a passive cable at all.

Failing tests

On branch audit:

/// USB PD R3.2 V1.2 Table 6.42 (Passive Cable VDO), VBUS Current Handling Capability:
///   "00b - Invalid; receiver Shall assume 01b (3A)."
///   "11b - Invalid; receiver Shall assume 01b (3A)."
///
/// These are specified receive-side fallbacks, not parse errors. A conforming
/// receiver normalizes both to 3A rather than rejecting the cable.
#[test]
fn invalid_values_fall_back_to_three_amps() {
    for v in [0u8, 3] {
        assert_eq!(
            VbusCurrentHandlingCapability::try_from(v),
            Ok(VbusCurrentHandlingCapability::ThreeAmps),
            "raw={v} must be normalized to 3A per USB PD R3.2 V1.2 Table 6.42"
        );
    }
}

/// USB PD R3.2 V1.2 Table 6.42 (Passive Cable VDO), Maximum VBUS Voltage:
///   "01b..10b - Deprecated, receiver Shall assume 00b (20V)."
///
/// Encodings 01b and 10b are deprecated, not alternative voltages. A conforming
/// receiver reports 20V for both rather than 30V/40V.
#[test]
fn deprecated_values_fall_back_to_twenty_volts() {
    for v in [0b01u8, 0b10] {
        assert_eq!(
            MaximumVbusVoltage::try_from(v),
            Ok(MaximumVbusVoltage::TwentyVolt),
            "raw={v} is deprecated and must be reported as 20V per USB PD R3.2 V1.2 Table 6.42"
        );
    }
}

The companion all_valid_variants was also corrected: it previously asserted 01b -> 30V and 10b -> 40V.

Suggested fix

Apply the specified fallbacks at the parse boundary. Consider whether ThirtyVolt/FortyVolt should remain inhabitants of MaximumVbusVoltage at all, since no conforming passive cable can report them. Note Table 6.45 specifies a different mapping for VPDs (encodings 1..3 all become 20V) and Table 6.43 repeats the cable mapping for active cables; both are out of scope here.

Dominant language
Rust
Stars
2
Forks
8
Avg merge
1d 10h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenDevicePartnership/embedded-usb-pd

All issues in OpenDevicePartnership/embedded-usb-pd

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.