15 KiB
PDU 路由器规范 (Specification of PDU Router)
AUTOSAR CP Release 4.4.0 文档 ID 035: AUTOSAR_SWS_PDURouter
元信息
| 项目 | 内容 |
|---|---|
| 文档标题 | PDU 路由器规范 (Specification of PDU Router) |
| 文档所有者 | AUTOSAR |
| 文档责任方 | AUTOSAR |
| 文档标识号 | 035 |
| 文档状态 | Final |
| 所属 AUTOSAR 标准 | Classic Platform |
| 所属标准版本 | 4.4.0 |
文档变更历史
| 日期 | 版本 | 变更方 | 变更说明 |
|---|---|---|---|
| 2018-10-31 | 4.4.0 | AUTOSAR Release Management | API 通用化;增加 LIN Slave 支持;细微更正 |
| 2017-12-08 | 4.3.1 | AUTOSAR Release Management | 修正/澄清 |
| 2016-11-30 | 4.3.0 | AUTOSAR Release Management | MetaData 处理增强 |
| 2015-07-31 | 4.2.2 | AUTOSAR Release Management | 编辑修正 |
| 2014-10-31 | 4.2.1 | AUTOSAR Release Management | 增强 LDCom 接口 |
| 2014-03-31 | 4.1.3 | AUTOSAR Release Management | 添加 J1939Tp 支持 |
| 2013-10-31 | 4.1.2 | AUTOSAR Release Management | 增强多播能力 |
| 2013-03-15 | 4.1.1 | AUTOSAR Administration | 后构建支持改进 |
| 2011-12-22 | 4.0.3 | AUTOSAR Administration | API 重新设计 |
| 2010-09-30 | 3.1.5 | AUTOSAR Administration | 配置统一 |
| 2010-02-02 | 3.1.4 | AUTOSAR Administration | 增强路由能力 |
| 2008-08-13 | 3.1.1 | AUTOSAR Administration | 法律声明 |
| 2007-12-21 | 3.0.1 | AUTOSAR Administration | 新增 ChangeParameter、CancelTransmit |
| 2007-01-24 | 2.1.15 | AUTOSAR Administration | 澄清和修正 |
| 2006-05-16 | 2.0 | AUTOSAR Administration | 重大架构调整 |
| 2005-05-31 | 1.0 | AUTOSAR Administration | 初始发布 |
目录
- 1. 介绍与功能概述
- 2. 缩略语
- 3. 相关文档
- 4. 约束与假设
- 5. 与其他模块的依赖
- 6. 需求可追溯性
- 7. 功能规范
- 8. API 规范
- 9. 时序图
- 10. 配置规范
- 11. PDU 路由器模块设计注释
- 12. 不适用需求
1. 介绍与功能概述
本规范描述 AUTOSAR PDU 路由器(PduR)模块的功能和 API。
PDU 路由器模块为下列模块类型提供 I-PDU(交互层协议数据单元)路由服务:
- 通信接口模块:使用
<Provider:Up>或<Provider:Lo>API 的模块,如 Com、IPduM、LinIf、CanIf、CanNm、FrIf、FrNm - 传输协议模块:使用
<Provider:UpTp>或<Provider:LoTp>API 的模块,如 J1939Tp、LinTp(LinIf 的一部分)、CanTp、FrTp、COM、DCM
I-PDU 路由基于静态定义的 I-PDU 标识符。运行时不动态路由 I-PDU(例如不依赖载荷)。
相关模块的位置可以是 "上层"(如 DLT、DCM、COM、IpduM)和/或 "下层"(CanIf、FrIf、LinTp、IpduM、CanNm、FrNm)。注意 IpduM 同时在两层(上层:COM↔IpduM,下层:IpduM↔CanIf 等)。
最常见的上下层配对:
- AUTOSAR 诊断通信管理器(DCM) ↔ 传输协议模块
- AUTOSAR COM ↔ 通信接口模块/传输协议模块/I-PDU 复用器
- I-PDU 复用器 ↔ 通信接口模块
1.1 AUTOSAR 架构
PDU 路由器是 AUTOSAR 通信结构 [1] 中的核心模块。
1.2 PDU 路由器模块功能概述
PDU 路由器提供以下服务:
- 路由 I-PDU:从一个模块到另一个模块。
- 网关 I-PDU:从一个总线/通道到另一个。
- 多播:一个 I-PDU 路由到多个目标。
- 取消传输/接收:取消进行中的 TP 操作。
- 变更参数:运行时参数变更。
- 路由路径组:启用/禁用路由路径。
1.3 I-PDU 处理
PDU 路由器处理通信接口模块的 I-PDU 和传输协议模块的 I-PDU。
通信接口模块通常处理 I-PDU 的简单 RX/TX 通知。 传输协议模块基于 SDU 分段重组传输。
2. 缩略语
| 缩略语 | 描述 |
|---|---|
| API | Application Programming Interface |
| AUTOSAR | Automotive Open System Architecture |
| BSW | Basic Software |
| CAN | Controller Area Network |
| CanIf | CAN Interface |
| CanNm | CAN Network Management |
| CanTp | CAN Transport Protocol |
| CDD | Complex Device Driver |
| COM | Communication |
| DET | Default Error Tracer |
| DCM | Diagnostic Communication Manager |
| DLT | Diagnostic Log and Trace |
| ECU | Electronic Control Unit |
| FlexRay | FlexRay Communication System |
| FrIf | FlexRay Interface |
| FrNm | FlexRay Network Management |
| FrTp | FlexRay Transport Protocol |
| I-PDU | Interaction Layer PDU |
| IpduM | I-PDU Multiplexer |
| L-PDU | Data Link Layer PDU |
| LdCom | Large Data COM |
| LinIf | LIN Interface |
| LinTp | LIN Transport Protocol |
| N-PDU | Network Layer PDU |
| PDU | Protocol Data Unit |
| PduR | PDU Router |
| RX | Reception |
| SDU | Service Data Unit |
| TP | Transport Protocol |
| TX | Transmission |
3. 相关文档
3.1 输入文档
- [1] Layered Software Architecture
- [2] General Requirements on Basic Software Modules
- [3] Specification of Communication
- [4] Specification of Communication Stack Types
- [5] Specification of ECU Configuration
- [6] List of Basic Software Modules
- [7] Specification of CAN Interface
- [8] Specification of LIN Interface
- [9] Specification of FlexRay Interface
- [10] Specification of CAN Transport Protocol
- [11] Specification of FlexRay Transport Protocol
- [12] Specification of Default Error Tracer
- [13] Specification of I-PDU Multiplexer
- [14] Specification of Diagnostic Communication Manager
- [15] Basic Software Module Description Template
- [16] General Specification of Basic Software Modules
- [17] Specification of J1939 Transport Protocol
3.2 相关规范
AUTOSAR SWS BSW General [16] 适用。
4. 约束与假设
4.1 限制
4.1.1 支持的功能限制
PDU 路由器支持的功能限制:
- 不支持动态路由
- 不支持运行时改变路由表
- 数据复用由 IpduM 处理
4.2 适用车域
适用于所有车域。
5. 与其他模块的依赖
5.1 文件结构
5.1.1 代码文件结构
PduR 提供以下源文件:PduR.c、PduR_Cfg.c 等。
5.1.2 头文件结构
- PduR.h:核心头文件
- PduR_.h:为每个上层模块提供的头文件
- PduR_.h:为每个下层模块提供的头文件
- PduR_Cfg.h:配置头文件
5.2 版本检查
PduR 应支持版本检查机制。
6. 需求可追溯性
| 需求 ID | 描述 | 满足者 |
|---|---|---|
| SRS_PduR_06000 | 路由 I-PDU | SWS_PduR_00109 |
| SRS_PduR_06010 | 路由通信接口 I-PDU | SWS_PduR_00109 |
| SRS_PduR_06037 | 多播 | SWS_PduR_00115 |
| SRS_PduR_06090 | 取消传输 | SWS_PduR_00307 |
| SRS_PduR_06091 | 取消接收 | SWS_PduR_00308 |
| SRS_PduR_06092 | 变更参数 | SWS_PduR_00404 |
| SRS_BSW_00101 | 初始化 | SWS_PduR_00197 |
| SRS_BSW_00407 | 版本信息 | SWS_PduR_00227 |
[摘要] 完整需求追溯表见原文 PDF 第 22-28 页。
7. 功能规范
7.1 I-PDU 处理
7.1.1 上层模块的 I-PDU 接收
PduR 接收来自下层模块的 RxIndication,根据 I-PDU ID 查找路由路径,并转发给配置的上层模块。
- [SWS_PduR_00109] ⌈PduR 应根据接收路径转发 I-PDU。⌋
7.1.2 上层模块的 I-PDU 传输
上层模块调用 PduR_<UpperModule>Transmit,PduR 转发到对应下层模块。
- [SWS_PduR_00121] ⌈PduR 应接收上层 Transmit 请求并路由到下层。⌋
7.1.3 I-PDU 网关
PduR 支持 I-PDU 从一个下层模块直接路由到另一个下层模块,无需经过上层模块。
7.1.3.1 通信接口路由
- CanIf → CanIf (CAN-CAN 网关)
- CanIf → FrIf (CAN-FlexRay 网关)
- CanIf → LinIf (CAN-LIN 网关)
7.1.3.2 传输协议路由
- CanTp → CanTp
- 多播:1 个源到多个 TP 目标
7.2 取消传输
- [SWS_PduR_00307] ⌈PduR_CancelTransmit 取消 TP 传输。⌋
7.3 取消接收
- [SWS_PduR_00308] ⌈PduR_CancelReceive 取消 TP 接收。⌋
7.4 Zero Cost Operation
零成本操作意味着当配置中只有一个目标时,实现可优化为直接调用,无需查找。
7.5 状态管理
PduR 支持启用/禁用模块或路由路径组。
- [SWS_PduR_00405] ⌈PduR_EnableRouting / PduR_DisableRouting 控制路由路径组。⌋
7.6 路由路径组
路由路径组允许动态启用/禁用一组路由路径。
7.7 复杂驱动交互
CDD 可作为 PduR 的上层或下层模块。
7.8 错误分类
7.8.1 开发错误
| 错误名 | 错误码 | 含义 |
|---|---|---|
| PDUR_E_CONFIG_PTR_INVALID | 0x05 | 配置指针无效 |
| PDUR_E_INVALID_REQUEST | 0x02 | 无效请求 |
| PDUR_E_PDU_ID_INVALID | 0x03 | 无效 PDU ID |
| PDUR_E_PARAM_POINTER | 0x06 | NULL 指针 |
| PDUR_E_DATA_PTR_INVALID | 0x09 | 数据指针无效 |
| PDUR_E_UNINIT | 0x04 | 未初始化 |
| PDUR_E_INIT_FAILED | 0x0A | 初始化失败 |
| PDUR_E_ROUTING_PATH_GROUP_ID_INVALID | 0x07 | 无效路由路径组 ID |
| PDUR_E_BSWMD_VARIANT_ERROR | 0x08 | 变体错误 |
7.8.2 运行时错误
| 错误名 | 含义 |
|---|---|
| PDUR_E_TP_TX_REQ_REJECTED | TP 发送请求被拒绝 |
7.9 错误检测
PduR 应检测开发错误。
7.10 API 参数检查
所有 API 应检查参数合法性。
8. API 规范
8.1 导入类型
| 模块 | 头文件 | 导入类型 |
|---|---|---|
| ComStack_Types | ComStack_Types.h | PduIdType, PduInfoType, PduLengthType, RetryInfoType, BufReq_ReturnType, TPParameterType |
| Std_Types | Std_Types.h | Std_ReturnType, Std_VersionInfoType |
8.2 类型定义
8.2.1 PduR_PBConfigType
typedef struct PduR_PBConfigType PduR_PBConfigType;
8.2.2 PduR_PBConfigIdType
typedef uint16 PduR_PBConfigIdType;
8.2.3 PduR_RoutingPathGroupIdType
typedef uint16 PduR_RoutingPathGroupIdType;
8.2.4 PduR_StateType
typedef enum {
PDUR_UNINIT = 0x00,
PDUR_ONLINE = 0x01
} PduR_StateType;
8.3 函数定义
8.3.1 PDU 路由器提供的通用函数
8.3.1.1 PduR_Init
void PduR_Init(const PduR_PBConfigType* ConfigPtr)
| Service ID | 0xF0 |
|---|---|
| 描述 | 初始化 PduR |
8.3.1.2 PduR_GetVersionInfo
void PduR_GetVersionInfo(Std_VersionInfoType* versionInfo)
8.3.1.3 PduR_GetConfigurationId
PduR_PBConfigIdType PduR_GetConfigurationId(void)
8.3.1.4 PduR_EnableRouting
void PduR_EnableRouting(PduR_RoutingPathGroupIdType id)
8.3.1.5 PduR_DisableRouting
void PduR_DisableRouting(PduR_RoutingPathGroupIdType id)
8.3.2 上层模块的可配置接口
每个上层模块得到一组特定的函数:
Transmit
Std_ReturnType PduR_<UpperModule>Transmit(
PduIdType TxPduId,
const PduInfoType* PduInfoPtr
)
CancelTransmit
Std_ReturnType PduR_<UpperModule>CancelTransmit(PduIdType TxPduId)
CancelReceive
Std_ReturnType PduR_<UpperModule>CancelReceive(PduIdType RxPduId)
ChangeParameter
Std_ReturnType PduR_<UpperModule>ChangeParameter(
PduIdType id,
TPParameterType parameter,
uint16 value
)
8.3.3 下层通信接口模块的可配置接口
RxIndication
void PduR_<LowerLayerModule>RxIndication(
PduIdType RxPduId,
const PduInfoType* PduInfoPtr
)
TxConfirmation
void PduR_<LowerLayerModule>TxConfirmation(PduIdType TxPduId)
TriggerTransmit
Std_ReturnType PduR_<LowerLayerModule>TriggerTransmit(
PduIdType TxPduId,
PduInfoType* PduInfoPtr
)
8.3.4 下层传输协议模块的可配置接口
StartOfReception
BufReq_ReturnType PduR_<LowerLayerTpModule>StartOfReception(
PduIdType id,
const PduInfoType* info,
PduLengthType TpSduLength,
PduLengthType* bufferSizePtr
)
CopyRxData
BufReq_ReturnType PduR_<LowerLayerTpModule>CopyRxData(
PduIdType id,
const PduInfoType* info,
PduLengthType* bufferSizePtr
)
TpRxIndication
void PduR_<LowerLayerTpModule>RxIndication(
PduIdType id,
Std_ReturnType result
)
CopyTxData
BufReq_ReturnType PduR_<LowerLayerTpModule>CopyTxData(
PduIdType id,
const PduInfoType* info,
const RetryInfoType* retry,
PduLengthType* availableDataPtr
)
TpTxConfirmation
void PduR_<LowerLayerTpModule>TxConfirmation(
PduIdType id,
Std_ReturnType result
)
8.4 调度函数
PduR 一般无 main 函数。
8.5 期望接口
8.5.1 强制接口
- Det_ReportError
8.5.2 可选接口
- 各通信接口模块和传输协议模块的 Transmit、CancelTransmit、ChangeParameter 等
9. 时序图
9.1 I-PDU 接收
9.1.1 CanIf 接收 I-PDU
9.1.2 FrIf 接收 I-PDU
9.1.3 LinIf 接收 I-PDU
9.1.4 CanTp 接收 I-PDU
9.2 I-PDU 发送
9.2.1 CanIf 发送 I-PDU
9.2.2 FrIf 发送 I-PDU
9.2.3 LinIf 发送 I-PDU
9.2.4 CanTp 发送 I-PDU
9.2.5 多播 I-PDU on TP modules
9.3 I-PDU 网关
9.3.1 两个 CanIf 之间网关
9.3.2 CAN 到 FlexRay 网关
9.3.3 CAN 到 LIN 网关
9.3.4 CAN 到 CAN 并由 COM 接收
9.3.5 单播网关使用 TP 模块
9.3.6 多播网关使用 TP 模块
9.3.7 单帧 I-PDU 从 CAN1 到 DCM 和 CAN2
9.3.8 多帧 I-PDU 从 J1939Tp 到 DCM、CAN、LIN
[摘要] 详细时序图见原文 PDF 第 71-89 页。
10. 配置规范
10.1 如何阅读本章
10.1.1 变体
支持 Pre-compile, Link, Post-build 时间配置。
10.2 容器与配置参数
10.2.1 PduR
根容器。
10.2.2 PduRBswModules
| 参数 | 类型 | 说明 |
|---|---|---|
| PduRBswModuleRef | ref | 引用 BSW 模块 |
| PduRTransmit | bool | 是否启用 Transmit |
| PduRTxConfirmation | bool | 是否启用 TxConfirmation |
| PduRRxIndication | bool | 是否启用 RxIndication |
| PduRCancelTransmit | bool | 是否支持 CancelTransmit |
10.2.3 PduRGeneral
| 参数 | 类型 | 说明 |
|---|---|---|
| PduRDevErrorDetect | bool | DET 启用 |
| PduRVersionInfoApi | bool | 版本信息 API |
| PduRZeroCostOperation | bool | 零成本操作启用 |
| PduRConfigurationId | uint16 | 配置 ID |
10.2.4 PduRRoutingPathGroup
| 参数 | 类型 | 说明 |
|---|---|---|
| PduRRoutingPathGroupId | uint16 | 路径组 ID |
| PduRIsEnabledAtInit | bool | 初始化时是否启用 |
10.2.5 PduRRoutingPaths
所有路由路径容器。
10.2.6 PduRRoutingPath
单个路由路径配置。
10.2.7 PduRDestPdu
目的 PDU 配置(目标模块、目的 ID)。
10.2.8 PduRSrcPdu
源 PDU 配置(源模块、源 ID)。
10.2.9 PduRDefaultValue, PduRDefaultValueElement
默认值配置(用于网关丢失值)。
10.2.10 PduRTxBuffer
发送缓冲区配置(用于网关)。
[摘要] 完整配置参数详见原文 PDF 第 92-112 页。
10.3 已发布信息
按 BSW General 提供。
11. PDU 路由器模块设计注释
11.1 配置参数考虑
11.2 通用接口概念
PDU 路由器使用通用接口,允许配置任意上下层模块。
11.3 路由表示例结构
11.3.1 通信接口模块的发送和多播
11.3.2 通信接口模块的接收和网关
11.4 配置生成器
11.4.1 CanIf 和 COM 路由路径示例
11.5 后构建考虑
12. 不适用需求
详见原文 PDF 第 120 页。
翻译说明
- 本译本基于 AUTOSAR CP 4.4.0 的 PDU 路由器规范 (Document ID 035,共 120 页)
- 摘要标记位置:第 6 章需求追溯、第 9 章时序图、第 10 章配置参数、第 12 章不适用需求