USB PD: extended Alert event 5 is rejected although it is defined

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

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

2026年10月26日 から。

評価

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

調査の方向性

src/ado.rsの124~130行付近にあるextended alertの変換と、220~279行付近にあるtest_ado_try_from_standard_alertsテストを読んでください。提案されているとおり、イベント5とそのエンコード経路のサポートを追加し、関連するテストを実行してイベントが受け入れられることを確認してください。また、後続コードの網羅的なmatchに対する、指摘されている互換性への影響も考慮してください。

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

説明

bug conformance

Summary

The extended alert parser handles events 1 through 4 only. Event 5 is defined by the current PD specification and is rejected.

What the specification requires

USB PD R3.2 V1.2 S6.4.5, Table 6.25 (Extended Alert Event Type):

5 - Source is about to reduce Source Capabilities

What the code does

src/ado.rs#L124-L130:

0x80 => match raw.extended_alert_type() {
    0x01 => Ok(Ado::PowerStateChange),
    0x02 => Ok(Ado::PowerButtonPress),
    0x03 => Ok(Ado::PowerButtonRelease),
    0x04 => Ok(Ado::ControllerInitiatedWake),
    _ => Err(InvalidType(raw.0)),
},

A conforming 0x80000005 alert is rejected rather than reporting impending capability reduction.

Failing test

test_ado_try_from_standard_alerts on branch audit. The test previously asserted that event 5 is invalid; that assertion is now inverted:

    raw.set_extended_alert_type(0x04);
    assert_eq!(Ado::try_from(raw).unwrap(), Ado::ControllerInitiatedWake);

    // USB PD R3.2 V1.2 Table 6.25 (Extended Alert Event Type) defines:
    //   "5 - Source is about to reduce Source Capabilities"
    // A conforming extended alert carrying event 5 must not be rejected.
    raw.set_extended_alert_type(0x05);
    assert!(
        Ado::try_from(raw).is_ok(),
        "extended alert event 5 (Source about to reduce Source Capabilities) is defined by \
         USB PD R3.2 V1.2 Table 6.25 and must be accepted"
    );
}

Suggested fix

Add the variant and its encode path. Adding an enum variant is breaking for downstream exhaustive matches.

主要言語
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 を短くまとめたダイジェスト。