DEENESPTFRRUARHIKOZHNL

命名空间 apext::diag::uds_transport

用户指南人工智能生成

用于在诊断管理中实现外部 UDS 传输协议的标准化连接与管理。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: ce8b113ec3f5 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

用于在诊断管理中实现外部 UDS 传输协议的标准化连接与管理。

命名空间 apext::diag::uds_transport 提供了 C++ 传输接口,用于将通用诊断管理与特定的 UDS 传输协议解耦 AUTOSAR_AP_SWS_Diagnostics §7.1 “UDS Transport Layer”。协议插件派生自基类 UdsTransportProtocolHandler,并经历由构造、初始化、启动和有序停止组成的严格生命周期 [SWS_DM_00329]。传入消息通过 IndicateMessage 进行通知,并在有空闲容量时获得一个内存托管的 UdsMessagePtr 以接收有效负载。一个核心约束条件是:在停止后,除确认消息外,不得向诊断管理发出其他调用。

上下文

命名空间 apext::diag::uds_transport 为 AUTOSAR Adaptive Platform 中的诊断管理(DM)定义了标准化 C++ 传输接口(Transport Protocol API)AUTOSAR_AP_SWS_Diagnostics §7.1 “UDS Transport Layer”。该架构在功能上将诊断管理的通用核心与具体的网络层和传输层分离开来。通过这种方式,标准化的协议(如 DoIP)以及未来或特定制造商的传输协议(例如用于 CAN、CAN-FD 或 FlexRay)均可作为模块化插件进行集成 AUTOSAR_AP_SWS_Diagnostics §7.1 “UDS Transport Layer”。

核心中介实例由类 UdsTransportProtocolMgr 构成,它协调 Diagnostic Server 实例与所连接传输协议之间的交互。具体的协议插件派生自抽象基类 UdsTransportProtocolHandler AUTOSAR_AP_SWS_Diagnostics §7.1.1 “Support of UDS Transport Layer” [SWS_DM_00315]。各个处理器实例通过 UdsTransportProtocolHandlerID 寻址 [SWS_DM_00336],而通信通道通过类型 ChannelID 标识 [SWS_DM_00337]。为了支持符合 ISO 服务 0x2A 的周期性数据查询,该接口还引入了类 UdsTransportProtocolPeriodicHandler。

生命周期

诊断管理按照固定指定的顺序控制每个 UdsTransportProtocolHandler 实例的生命周期 [SWS_DM_00329]:

  1. 创建:DM 通过构造函数 UdsTransportProtocolHandler::UdsTransportProtocolHandler 实例化协议插件 [SWS_DM_00329]。
  2. 初始化:DM 调用 UdsTransportProtocolHandler::Initialize [SWS_DM_00329]。除了查询 GetPeriodicHandler 之外,在成功返回 kInitializeOk 之前,DM 不得在处理器上调用其他方法 [SWS_DM_01746]。
  3. 启动与运行:成功初始化后,使用 UdsTransportProtocolHandler::Start 激活处理器。只有在此调用之后,DM 才会通过 UdsTransportProtocolMgr::ChannelReestablished 处理有关重新激活通道的消息 [SWS_DM_01744]。
  4. 终止:当 DM 切换到状态 ApplicationState.kTerminating 时,它会针对所有活动插件调用 UdsTransportProtocolHandler::Stop [SWS_DM_00333]。在此调用返回后,插件仅允许调用 UdsTransportProtocolMgr::HandlerStopped [SWS_DM_01741]。DM 会主动等待此确认 [SWS_DM_00340]。
handler_lifecycle NichtInitialisiert NichtInitialisiert Initialisierend Initialisierend NichtInitialisiert->Initialisierend Konstruktor Initialisiert Initialisiert Initialisierend->Initialisiert Initialize() -> kInitializeOk Fehlgeschlagen Fehlgeschlagen Initialisierend->Fehlgeschlagen Initialize() -> kInitializeFailed Gestartet Gestartet Initialisiert->Gestartet Start() Stoppend Stoppend Gestartet->Stoppend 处于 kTerminating 时调用 Stop() Gestoppt Gestoppt Stoppend->Gestoppt HandlerStopped()

状态图:传输协议处理器实现方案的生命周期阶段和转换条件。来源:[SWS_DM_00329]、[SWS_DM_00333]、[SWS_DM_00340]、[SWS_DM_01741]、[SWS_DM_01744]、[SWS_DM_01745]、[SWS_DM_01746]

使用路径

在运行过程中,传入诊断消息的转发通过处理器与管理器的协调交互来进行:

  1. 消息指示:当处理器在通道(ChannelID [SWS_DM_00337])上接收到数据时,它会调用 UdsTransportProtocolMgr::IndicateMessage。此时它可以在 payloadInfo 中传递预取有效负载;建议至少传递前两个字节,以便及早识别功能寻址请求 AUTOSAR_AP_SWS_Diagnostics §7.1 “UDS Transport Layer”。
  2. 缓冲区分配:如果 DM 处于就绪接收状态,IndicateMessage 会以一个包含 IndicationResult::kIndicationOk 和有效智能指针 UdsMessagePtr 的 std::pair 进行响应 [SWS_DM_00309] [SWS_DM_00385]。所引用的 UdsMessage 对象具有至少一个字节的容量 [SWS_DM_00385]。该缓冲区作为带有 DM 核心特定删除器的 std::unique_ptr 进行管理,且不是线程安全的 [SWS_DM_00303]。对于读取访问,存在常量等效项 UdsMessageConstPtr [SWS_DM_00304]。
  3. 数据传递:处理程序将接收到的诊断数据写入提供的缓冲区中,该缓冲区字节序列的类型由 ByteSpan(ara::core::Span<ara::core::Byte> [SWS_DM_00338] 的别名)定义。据推测,通过 GetPeriodicHandler 提供单独的类 UdsTransportProtocolPeriodicHandler 是为了将周期性传输服务 0x2A 与常规 UDS 报文路径解耦。 问题 Q-230ef0b7c384c594 (未决)
UDS 报文指示流程HandlerUdsTransportProtocolMgrDM-KernIndicateMessage(channelId, payloadInfo)检查服务器状态与资源altDM bereitAllokiere UdsMessagereturn pair(kIndicationOk, UdsMessagePtr)Kopiere Nutzdaten in ByteSpanDM belegtreturn pair(kIndicationOccupied, nullptr)

时序图:处理程序、管理器和 DM 核心之间的报文指示和缓冲区分配流程。来源:AUTOSAR_AP_SWS_Diagnostics §7.1 “UDS Transport Layer”、[SWS_DM_00303]、[SWS_DM_00309]、[SWS_DM_00385]、[SWS_DM_00386]

错误场景

规范定义了传输连接的具体错误状态和前提条件:

  • 初始化失败:如果 UdsTransportProtocolHandler::Initialize 返回结果 kInitializeFailed,DM 将立即中止该处理程序的初始化过程,且不再调用其上的任何其他方法 [SWS_DM_01745]。
  • 诊断核心占用时的拒绝:如果 DM 因同一 Tester-Present 会话正在进行的某项服务处理而处于阻塞状态,且该请求并非带有 payloadInfo 0x3E 0x80 的功能寻址 Tester-Present,则 IndicateMessage 返回结果 kIndicationOccupied 以及一个 nullptr,而不是报文缓冲区 [SWS_DM_00386]。
  • 终止后不允许的调用:如果插件在 Stop 返回后调用 UdsTransportProtocolMgr 中除 HandlerStopped 以外的方法,则违反了协议规定 [SWS_DM_01741]。同样,如果信号(如 ChannelReestablished)在成功调用 Start 之前到达,DM 也会予以忽略 [SWS_DM_01744]。

本指南仅基于 AUTOSAR Adaptive Platform Release R25-11 规范。

主题图

KI-gestützte Gruppierung auf Basis der Records und Spezifikationsauszüge; keine Gliederung aus der AUTOSAR-Spezifikation.

类图

Abgerundete Rahmen = Namespace- bzw. Klassen-Scopes; hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); graue Boxen = namespace-fremde bzw. externe Basisklassen. Klicken öffnet die jeweilige Klassen- bzw. cppreference-Seite.

G cluster_ns apext::diag::uds_transport napext__diag__uds_transport__UdsMessage UdsMessage napext__diag__uds_transport__UdsTransportProtocolHandler UdsTransportProtocolHandler napext__diag__uds_transport__UdsTransportProtocolMgr UdsTransportProtocolMgr napext__diag__uds_transport__UdsTransportProtocolPeriodicHandler UdsTransportProtocolPeriodicHandler

详细视图

请在大纲中选择一个条目。

Nachrichtendaten

class represents an UDS message exchanged between DM generic core (UdsTransport ProtocolMgr) and a specific implementation of UdsTransportPr

ByteSpan 类型别名

This is the type of ByteSpan.

using ByteSpan = ara::core::Span<ara::core::Byte>;
UdsMessageConstPtr 类型别名

This is the unique_ptr for constant UdsMessages containing a custom deleter as provided by the generic/core DM part towards the UdsTransportLayer-Plugin.

using UdsMessageConstPtr = std::unique_ptr<const UdsMessage, std::function<void(const UdsMessage*)>>;
UdsMessagePtr 类型别名

This is the unique_ptr for UdsMessages containing a custom deleter as provided by the generic/ core DM part towards the UdsTransportLayer-Plugin.

using UdsMessagePtr = std::unique_ptr<UdsMessage, std::function<void(UdsMessage*)>>;

Protokoll-Plugins

Abstract Class, which a specific UDS Transport Protocol (plugin) shall subclass.

UdsTransportProtocolPeriodicHandler class to support 0x2A service from ISO.

UdsTransportProtocolHandler are flexible "plugins", which need an identification.

using UdsTransportProtocolHandlerID = std::uint8_t;

Protokollverwaltung

The UdsTransportProtocolMgr class manages the interaction between the Diagnostic Server instance(s) and various UDS Transport Protocols (e.g

ChannelID 类型别名

This is the identification of channel on which to transmit.

using ChannelID = std::uint32_t;

类型别名

类型别名 ByteSpan [SWS_DM_00338] Upstream: RS_Diag_04147

using ByteSpan = ara::core::Span<ara::core::Byte>;

This is the type of ByteSpan.

Header-Datei#include "apext/diag/uds_transport/protocol_types.h"
Scopenamespace apext::diag::uds_transport
SymbolByteSpan

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00338
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00338@rel:R25-11#76b9f0ad
Content hash
76b9f0ad
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00338
Status: valid/unmigrated Version: rel:R25-11#1a041728 Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00338@rel:R25-11#1a041728
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#3f6b4b552026-09-30
  • R19-11rel:R19-11#87b9aa052026-10-14
  • R20-11rel:R20-11#280ab9cb2026-10-14
  • R21-11rel:R21-11#280ab9cb2026-10-14
  • R22-11rel:R22-11#21aad9862026-10-14
  • R23-11rel:R23-11#a3af51d32026-10-14
  • R24-11rel:R24-11#1a0417282026-10-14
  • R25-11rel:R25-11#1a0417282026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

类型别名 ChannelID [SWS_DM_00337] Upstream: RS_Diag_04147

using ChannelID = std::uint32_t;

This is the identification of channel on which to transmit.

Header-Datei#include "apext/diag/uds_transport/protocol_types.h"
Scopenamespace apext::diag::uds_transport
SymbolChannelID

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00337
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00337@rel:R25-11#5a8b2c24
Content hash
5a8b2c24
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00337
Status: valid/unmigrated Version: rel:R25-11#1d8116d5 Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00337@rel:R25-11#1d8116d5
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#a89726192026-09-30
  • R19-11rel:R19-11#a09308352026-10-14
  • R20-11rel:R20-11#6bf394982026-10-14
  • R21-11rel:R21-11#6bf394982026-10-14
  • R22-11rel:R22-11#1855826a2026-10-14
  • R23-11rel:R23-11#3d08977c2026-10-14
  • R24-11rel:R24-11#1d8116d52026-10-14
  • R25-11rel:R25-11#1d8116d52026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

类型别名 UdsMessageConstPtr [SWS_DM_00304] Upstream: RS_Diag_04147

using UdsMessageConstPtr = std::unique_ptr<const UdsMessage, std::function<void(const UdsMessage*)>>;

This is the unique_ptr for constant UdsMessages containing a custom deleter as provided by the generic/core DM part towards the UdsTransportLayer-Plugin.

Header-Datei#include "apext/diag/uds_transport/uds_message.h"
Scopenamespace apext::diag::uds_transport
SymbolUdsMessageConstPtr
Thread-Sicherheitnot thread-safe
Hinweise: How the exact typedef for UdsMessageConstPtr looks like, is up to the DM product vendor. I.e. how f.i. the deleter signature looks like ... basically the minimal agreement is: UdsMessage ConstPtr shall behave like a std::unique_ptr<const UdsMessage>!

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00304
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00304@rel:R25-11#fc62d443
Content hash
fc62d443
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00304
Status: valid/unmigrated Version: rel:R25-11#cbe7d8ab Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00304@rel:R25-11#cbe7d8ab
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#8e4075282026-09-30
  • R19-11rel:R19-11#f70a6f152026-10-14
  • R20-11rel:R20-11#70977a452026-10-14
  • R21-11rel:R21-11#70977a452026-10-14
  • R22-11rel:R22-11#3632365b2026-10-14
  • R23-11rel:R23-11#ee76163c2026-10-14
  • R24-11rel:R24-11#6389682c2026-10-14
  • R25-11rel:R25-11#cbe7d8ab2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

类型别名 UdsMessagePtr [SWS_DM_00303] Upstream: RS_Diag_04147

using UdsMessagePtr = std::unique_ptr<UdsMessage, std::function<void(UdsMessage*)>>;

This is the unique_ptr for UdsMessages containing a custom deleter as provided by the generic/ core DM part towards the UdsTransportLayer-Plugin.

Header-Datei#include "apext/diag/uds_transport/uds_message.h"
Scopenamespace apext::diag::uds_transport
SymbolUdsMessagePtr
Thread-Sicherheitnot thread-safe
Hinweise: How the exact typedef for UdsMessagePtr looks like, is up to the DM product vendor. I.e. how f.i. the deleter signature looks like ... basically the minimal agreement is: UdsMessagePtr shall behave like a std::unique_ptr<UdsMessage>!

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00303
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00303@rel:R25-11#2aab8ab8
Content hash
2aab8ab8
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00303
Status: valid/unmigrated Version: rel:R25-11#6be645e6 Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00303@rel:R25-11#6be645e6
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#b75a0d132026-09-30
  • R19-11rel:R19-11#401203282026-10-14
  • R20-11rel:R20-11#a5dd04072026-10-14
  • R21-11rel:R21-11#a5dd04072026-10-14
  • R22-11rel:R22-11#812335462026-10-14
  • R23-11rel:R23-11#057e29102026-10-14
  • R24-11rel:R24-11#fb6c8d462026-10-14
  • R25-11rel:R25-11#6be645e62026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

类型别名 UdsTransportProtocolHandlerID [SWS_DM_00336] Upstream: RS_Diag_04147, RS_Diag_04168

using UdsTransportProtocolHandlerID = std::uint8_t;

UdsTransportProtocolHandler are flexible "plugins", which need an identification.

Header-Datei#include "apext/diag/uds_transport/protocol_types.h"
Scopenamespace apext::diag::uds_transport
SymbolUdsTransportProtocolHandlerID

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00336
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00336@rel:R25-11#7503f873
Content hash
7503f873
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00336
Status: valid/unmigrated Version: rel:R25-11#dbbb3100 Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00336@rel:R25-11#dbbb3100
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#44559d542026-09-30
  • R19-11rel:R19-11#d727dd482026-10-14
  • R20-11rel:R20-11#7d7439fe2026-10-14
  • R21-11rel:R21-11#7d7439fe2026-10-14
  • R22-11rel:R22-11#c079e14d2026-10-14
  • R23-11rel:R23-11#d98d683b2026-10-14
  • R24-11rel:R24-11#dbbb31002026-10-14
  • R25-11rel:R25-11#dbbb31002026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill