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

オープン 初心者向け
#91 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@RobertZ2011 がすでに取り組んでいます。

2026年10月26日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
embedded-iot

調査の方向性

src/vdm/structured/command/discover_identity/passive_cable_vdo.rsを読み、特に2つのtry_from実装と、名前が挙げられている失敗するテストを確認してください。このファイルのテストを実行して現在の動作を確認し、その後、Table 6.42で指定されている受信側のフォールバックを解析境界で適用してください。無効な現行エンコーディングが3Aに正規化され、非推奨の電圧エンコーディングが20Vに正規化され、有効なバリアントのテストもそれに応じて更新されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
2
フォーク
8
平均マージ
1日 10時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenDevicePartnership/embedded-usb-pd のほかの issue

OpenDevicePartnership/embedded-usb-pd の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。