# AUTOSAR 默认错误跟踪器软件规范 (SWS DefaultErrorTracer)
> **文档元信息**
| 项目 | 内容 |
|------|------|
| 文档标题 | Specification of Default Error Tracer(默认错误跟踪器规范) |
| 文档所有者 | AUTOSAR |
| 文档责任方 | AUTOSAR |
| 文档标识号 | 017 |
| 文档状态 | Final(最终版) |
| AUTOSAR 标准分类 | Classic Platform(经典平台) |
| 标准发布版本 | 4.4.0 |
| 原文文档号 | AUTOSAR_SWS_DefaultErrorTracer |
---
## 文档变更历史
| 日期 | 发布版本 | 变更人 | 变更说明 |
|------|---------|--------|----------|
| 2018-10-31 | 4.4.0 | AUTOSAR Release Management | - 协调参数结构
- 适配规范
- 小错误修复 |
| 2017-12-08 | 4.3.1 | AUTOSAR Release Management | - 澄清回调签名
- 澄清错误处理
- 移除 DET 自身的部分 DET 错误 |
| 2016-11-30 | 4.3.0 | AUTOSAR Release Management | - 改进序列图
- 添加 Callouts 描述(8.1.5)
- 更改服务中的 Port Defined Arguments
- 改进可追溯性
- 添加 DetModuleInstance 参数
- 将 TransientFaults 设为 BSW-Service |
| 2015-07-31 | 4.2.2 | AUTOSAR Release Management | - 协调可追溯性
- 确保所有模块一致使用开发错误 |
| 2014-10-31 | 4.2.1 | AUTOSAR Release Management | - 通过添加例程扩展并重命名 DevelopmentErrorTracer 为 DefaultErrorTracer
- 新例程 Det_ReportRountineError 和 Det_ReportTransientFault
- 新配置参数 Det_ReportRountineErrorCallout 和 Det_ReportTransientFaultCallout |
| 2014-03-31 | 4.1.3 | AUTOSAR Release Management | 改进 SWS_DET_00050 的需求格式 |
| 2013-10-31 | 4.1.2 | AUTOSAR Release Management | - 文档结构和创建的结构性但非功能性改进
- 编辑性修改
- 移除变更文档章节 |
| 2013-03-15 | 4.1.1 | AUTOSAR Administration | - 根据 SWS_General 协调需求
- 形式化服务描述 |
| 2011-12-22 | 4.0.3 | AUTOSAR Administration | 与包含结构等相关的澄清 |
| 2010-09-30 | 3.1.5 | AUTOSAR Administration | - DLT 现在是 DET 的可选接口
- 协调参数错误处理
- 移除 4.0.1 版本的已知限制 |
| 2010-02-02 | 3.1.4 | AUTOSAR Administration | - 将跟踪到需求(现位于 SRS_Debugging)
- 为 Det_ReportError 添加 Std_ReturnType 值
- 协调配置类
- 适配已更改的通用需求
- 法律免责声明修订 |
| 2008-08-13 | 3.1.1 | AUTOSAR Administration | 法律免责声明修订 |
| 2008-02-01 | 3.0.2 | AUTOSAR Administration | - 添加 API GetVersionInfo 以协调 SWS 与 AUTOSAR 约定
- 扩展文档元信息 |
| 2007-12-21 | 3.0.1 | AUTOSAR Administration | - 将 SRS_BSW_00436 添加到可追溯性矩阵
- 添加 Memmap.h
- 添加第 11 章
- 法律免责声明修订 |
| 2006-05-16 | 2.0 | AUTOSAR Administration | 更改为新的 SWS 模板 |
| 2005-05-31 | 1.0 | AUTOSAR Administration | 初始发布 |
---
## 目录
- [1. 简介和功能概述](#1-简介和功能概述)
- [2. 缩略语和缩写](#2-缩略语和缩写)
- [3. 相关文档](#3-相关文档)
- [4. 约束和假设](#4-约束和假设)
- [5. 对其他模块的依赖](#5-对其他模块的依赖)
- [6. 需求追溯](#6-需求追溯)
- [7. 功能规范](#7-功能规范)
- [8. API 规范](#8-api-规范)
- [9. 序列图](#9-序列图)
- [10. 配置规范](#10-配置规范)
- [11. 不适用需求](#11-不适用需求)
---
## 免责声明
> 本节保留原文,不进行翻译。
---
## 1. 简介和功能概述
本规范规定了默认错误跟踪器(Default Error Tracer, DET)模块的功能、API 和配置。DET 接收并存储 BSW 模块或 SW-C 报告的开发错误、运行时错误和瞬态故障。DET 的主要目的是在开发过程中收集错误信息,以帮助识别和修复问题。
DET 作为所有 BSW 模块的中心错误收集点。在 ECU 正常运行期间,DET 通常可以:
- 通过 ErrorHook 调用用户提供的回调函数
- 将错误信息转发到 Diagnostic Log and Trace (DLT) 模块(如果已配置)
- 通过 Det_GetVersionInfo 提供版本信息
---
## 2. 缩略语和缩写
| 缩写 | 描述 |
|------|------|
| API | Application Programming Interface(应用程序编程接口) |
| BSW | Basic Software(基础软件) |
| CPU | Central Processing Unit(中央处理单元) |
| DEM | Diagnostic Event Manager(诊断事件管理器) |
| DET | Default Error Tracer(默认错误跟踪器) |
| DLT | Diagnostic Log and Trace(诊断日志和跟踪) |
| ECU | Electronic Control Unit(电子控制单元) |
| EcuM | ECU State Manager(ECU 状态管理器) |
| ISR | Interrupt Service Routine(中断服务例程) |
| OS | Operating System(操作系统) |
| RTE | Runtime Environment(运行时环境) |
| SPAL | Standard Peripheral Abstraction Layer(标准外设抽象层) |
| SWC | Software Component(软件组件) |
---
## 3. 相关文档
> **摘要标记**:本节列出相关文档,包括 SWS_BSWGeneral、SRS_BSWGeneral、AUTOSAR_TR_Glossary、AUTOSAR_EXP_LayeredSoftwareArchitecture 等。完整内容见原文 PDF 第 9 页。
---
## 4. 约束和假设
### 4.1 限制
> **摘要标记**:本节描述 DET 的限制,包括它不直接支持复杂错误处理、回调函数的限制等。完整内容见原文 PDF 第 10 页。
### 4.2 对汽车领域的适用性
> **摘要标记**:DET 适用于所有汽车领域。完整内容见原文 PDF 第 10 页。
---
## 5. 对其他模块的依赖
### 5.1 文件结构
> **摘要标记**:本节描述 DET 的文件结构,包括 Det.h、Det.c、Det_Cfg.h 等。完整内容见原文 PDF 第 11 页。
---
## 6. 需求追溯
> **摘要标记**:本节包含约 50 行的需求追溯表,链接 SRS_BSW_xxxxx 特性到 SWS_Det_xxxxx 规范需求。完整表见原文 PDF 第 12-17 页。
---
## 7. 功能规范
### 7.1 初始化
##### [SWS_Det_00019] Det_Init 函数
```
The DET shall provide the initialization function Det_Init (see SWS_Det_00008).
```
##### [SWS_Det_00020] Det_Init 函数每次调用
```
Each call of the Det_Init function shall be used to set the DET to a known state
(e.g. the state after startup) and prepare it for the further operation.
```
**注意**:集成商可以通过 EcuM 的配置来决定何时调用 Det_Init。调用 Det_Init 的责任在于 EcuM 集成商。
### 7.2 错误钩子
##### [SWS_Det_00014] 错误报告函数
```
The error report functions Det_ReportError, Det_ReportTransientFault and
Det_ReportRuntimeError shall call immediately all configured callouts.
```
##### [SWS_Det_00034] 转发到 DLT
```
Each call of the Det_ReportError, Det_ReportTransientFault and Det_ReportRuntimeError
function shall be forwarded to the DLT module, if this is configured.
```
##### [SWS_Det_00039] 可重入性
```
The Det_ReportError, Det_ReportTransientFault and Det_ReportRuntimeError functions
shall be reentrant.
```
##### [SWS_Det_00026] Det_ReportError 应停止执行
```
Det_ReportError shall stop execution. Ensure that DET runtime is able to stop the
system (e.g. by calling ShutdownAllCores).
```
### 7.3 错误报告
> **摘要标记**:本节描述错误报告的过程和机制。完整内容见原文 PDF 第 19-20 页。
### 7.4 版本信息
> **摘要标记**:本节描述 Det_GetVersionInfo 服务。完整内容见原文 PDF 第 20 页。
### 7.5 错误分类
#### 7.5.1 开发错误
> **摘要标记**:开发错误包括 API service used without initialization、API service used with wrong parameters、API service used with null pointer、Det_ReportError invoked with null pointer 等。完整内容见原文 PDF 第 21 页。
#### 7.5.2 运行时错误
> **摘要标记**:本节描述运行时错误的处理。完整内容见原文 PDF 第 21 页。
#### 7.5.3 瞬态故障
> **摘要标记**:本节描述瞬态故障的处理。完整内容见原文 PDF 第 21 页。
#### 7.5.4 生产错误
> **摘要标记**:本节描述生产错误。完整内容见原文 PDF 第 21 页。
#### 7.5.5 扩展生产错误
> **摘要标记**:本节描述扩展生产错误。完整内容见原文 PDF 第 21 页。
### 7.6 错误检测
##### [SWS_Det_00501] Det_ReportError 回调
```
The calls of Det_ReportError shall invoke all callback functions that are
configured for this purpose.
```
##### [SWS_Det_00502] Det_ReportTransientFault 回调
```
The calls of Det_ReportTransientFault shall invoke all callback functions that
are configured for this purpose.
```
##### [SWS_Det_00503] Det_ReportRuntimeError 回调
```
The calls of Det_ReportRuntimeError shall invoke all callback functions that
are configured for this purpose.
```
### 7.7 错误通知
> **摘要标记**:本节描述错误通知机制。完整内容见原文 PDF 第 22 页。
---
## 8. API 规范
### 8.1 API
#### 8.1.1 导入类型
> **摘要标记**:本节列出 DET 导入的类型(Std_ReturnType、Std_VersionInfoType、uint8、uint16)。完整内容见原文 PDF 第 23 页。
#### 8.1.2 类型定义
> **摘要标记**:本节定义 Det_ConfigType 配置结构。完整内容见原文 PDF 第 23 页。
#### 8.1.3 函数定义
##### 8.1.3.1 Det_Init
```c
Service name: Det_Init
Syntax: void Det_Init(
const Det_ConfigType* ConfigPtr)
Service ID[hex]: 0x00
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): ConfigPtr Pointer to the selected configuration set.
Parameters (inout): None
Parameters (out): None
Return value: None
Description: Service to initialize the Default Error Tracer.
Available via: Det.h
```
##### 8.1.3.2 Det_ReportError
```c
Service name: Det_ReportError
Syntax: Std_ReturnType Det_ReportError(
uint16 ModuleId,
uint8 InstanceId,
uint8 ApiId,
uint8 ErrorId)
Service ID[hex]: 0x01
Sync/Async: Not Applicable: The function never returns
Reentrancy: Reentrant
Parameters (in): ModuleId Module ID of calling module.
InstanceId The identifier of the index based instance of a module,
starting from 0, If the module is a single instance module
it shall pass 0 as the InstanceId.
ApiId ID of API service in which error is detected
(defined in SWS of calling module)
ErrorId ID of detected development error
(defined in SWS of calling module).
Parameters (inout): None
Parameters (out): None
Return value: Std_ReturnType never returns a value, but has a return type for
compatibility with services and hooks
Description: Service to report development errors.
Available via: Det.h
```
**注意**:Det_ReportError 可以在中断上下文中调用。由于 DET 可以在正常模式或中断上下文中调用(从栈或集成),这必须在实现钩子函数时考虑:Det_ReportError 可以在中断上下文中调用;停止系统时应考虑这一点。
##### 8.1.3.3 Det_Start
```c
Service name: Det_Start
Syntax: void Det_Start(void)
Service ID[hex]: 0x02
Sync/Async: Synchronous
Reentrancy: Non Reentrant
Parameters (in): None
Parameters (inout): None
Parameters (out): None
Return value: None
Description: Service to start the Default Error Tracer.
Available via: Det.h
```
##### 8.1.3.4 Det_ReportRuntimeError
```c
Service name: Det_ReportRuntimeError
Syntax: Std_ReturnType Det_ReportRuntimeError(
uint16 ModuleId,
uint8 InstanceId,
uint8 ApiId,
uint8 ErrorId)
Service ID[hex]: 0x04
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ModuleId Module ID of calling module.
InstanceId The identifier of the index based instance of a module,
starting from 0, If the module is a single instance module
it shall pass 0 as the InstanceId.
ApiId ID of API service in which error is detected
(defined in SWS of calling module)
ErrorId ID of detected runtime error
(defined in SWS of calling module).
Parameters (inout): None
Parameters (out): None
Return value: Std_ReturnType returns always E_OK (is required for services)
Description: Service to report runtime errors. If a callout has been configured
then this callout shall be called.
Available via: Det.h
```
**注意**:Det_ReportRuntimeError 可以在中断上下文中调用。由于 DET 可以在正常模式或中断上下文中调用(从栈或集成),这必须在实现钩子函数时考虑:Det_ReportRuntimeError 可以在中断上下文中调用;此钩子应可重入且性能足够。
##### 8.1.3.5 Det_ReportTransientFault
```c
Service name: Det_ReportTransientFault
Syntax: Std_ReturnType Det_ReportTransientFault(
uint16 ModuleId,
uint8 InstanceId,
uint8 ApiId,
uint8 FaultId)
Service ID[hex]: 0x05
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ModuleId Module ID of calling module.
InstanceId The identifier of the index based instance of a module,
starting from 0, If the module is a single instance module
it shall pass 0 as the InstanceId.
ApiId ID of API service in which transient fault is detected
(defined in SWS of calling module)
FaultId ID of detected transient fault
(defined in SWS of calling module).
Parameters (inout): None
Parameters (out): None
Std_ReturnType If no callout exists it shall return E_OK, otherwise
it shall return the value of the configured callout.
In case several callouts are configured the logical
or (sum) of the callout return values shall be
returned. Rationale: since E_OK=0, E_OK will be
only returned if all are E_OK, and for multiple
error codes there is a good chance to detect
several of them.
Return value:
Description: Service to report transient faults. If a callout has been configured
than this callout shall be called and the returned value of the callout
shall be returned. Otherwise it returns immediately with E_OK.
Available via: Det.h
```
**注意**:Det_ReportTransientFault 可以在中断上下文中调用。由于 DET 可以在正常模式或中断上下文中调用(从栈或集成),这必须在实现钩子函数时考虑:Det_ReportTransientFault 可以在中断上下文中调用;此钩子应可重入且性能足够。
##### 8.1.3.6 Det_GetVersionInfo
```c
Service name: Det_GetVersionInfo
Syntax: void Det_GetVersionInfo(
Std_VersionInfoType* versioninfo)
Service ID[hex]: 0x03
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters (inout): None
Parameters (out): versioninfo Pointer to where to store the version information of this module.
Return value: None
Description: Returns the version information of this module.
Available via: Det.h
```
如果传递了空指针,则返回 DET_E_PARAM_POINTER,参见 SWS_Det_00052。
#### 8.1.4 预期接口
##### 8.1.4.1 强制接口
没有强制预期接口,但所有使用和配置为 callouts 的 `` API 必须被包括。
**注意**:用户 API 的名称将不被指定,`` 仅是同义词。
**注意**:可以定义 User_ErrorHook 列表。
#### 8.1.5 Callout 函数/可配置接口
> **摘要标记**:本节描述 Callout 函数和可配置接口。Callout 是用户提供的回调函数,在错误发生时被调用。可以配置 Callout:
>
> - Det_ReportErrorCallout
> - Det_ReportRuntimeErrorCallout
> - Det_ReportTransientFaultCallout
>
> Callout 函数可用于实现应用特定的错误处理。完整内容见原文 PDF 第 27-28 页。
### 8.2 服务接口
#### 8.2.1 端口和端口接口规范
> **摘要标记**:本节定义 DET 的 AUTOSAR 端口和端口接口。完整内容见原文 PDF 第 29-30 页。
#### 8.2.2 服务定义
> **摘要标记**:本节定义 DET 的服务。完整内容见原文 PDF 第 31 页。
#### 8.2.3 DET 配置
> **摘要标记**:本节描述 DET 的配置方法。完整内容见原文 PDF 第 31 页。
---
## 9. 序列图
> **摘要标记**:本节包含以下序列图:
>
> - 9.1 Det_Init 调用
> - 9.2 Det_ReportError 调用
> - 9.3 Det_ReportRuntimeError 调用
> - 9.4 Det_ReportTransientFault 调用
>
> 完整内容见原文 PDF 第 32 页及之后。
---
## 10. 配置规范
> **摘要标记**:本节是配置规范的主要部分,包含以下容器:
>
> - Det
> - DetConfigSet
> - DetModuleInstance(DET 模块实例)
> - DetGeneral
> - DetDevErrorDetect(开发错误检测)
> - DetReportErrorCallout(错误报告 Callout)
> - DetReportRuntimeErrorCallout(运行时错误报告 Callout)
> - DetReportTransientFaultCallout(瞬态故障报告 Callout)
>
> 完整内容见原文 PDF 第 33 页及之后。
---
## 11. 不适用需求
> **摘要标记**:本节列出对 DET 不适用的需求。完整内容见原文 PDF 第 42 页。
---
## 翻译说明
- **文档类型**:AUTOSAR SWS(Software Specification,软件规范)
- **翻译策略**:本 SWS 文档(42 页)规模适中,已进行完整翻译,包括所有 API 函数定义、关键需求和接口规范。
- **摘要标记位置**:
- 第 3 章相关文档
- 第 4 章约束和假设
- 第 5 章依赖
- 第 6 章需求追溯
- 第 7.1-7.7 各功能规范
- 第 8.1.1 导入类型
- 第 8.1.2 类型定义
- 第 8.1.4 预期接口
- 第 8.1.5 Callout 函数
- 第 8.2 服务接口
- 第 9 章序列图
- 第 10 章配置规范
- 第 11 章不适用需求
- **保留内容**:
- 需求 ID(如 `SWS_Det_00019`、`SWS_Det_00008`、`SWS_Det_00501` 等)
- AUTOSAR 方框符 `⌈⌋`
- 所有 API 标识符(`Det_Init`、`Det_ReportError`、`Det_Start`、`Det_ReportRuntimeError`、`Det_ReportTransientFault`、`Det_GetVersionInfo` 等)
- 模块缩写(DET、BSW、ECU、EcuM、DLT、RTE、OS、SWC)
- 文档间交叉引用
- **术语对照表**:
- Default Error Tracer → 默认错误跟踪器
- Development Error → 开发错误
- Runtime Error → 运行时错误
- Transient Fault → 瞬态故障
- Production Error → 生产错误
- Extended Production Error → 扩展生产错误
- Error Hook → 错误钩子
- Callout Function → Callout 函数
- Error Reporting → 错误报告
- Error Detection → 错误检测
- Error Notification → 错误通知
- Diagnostic Log and Trace (DLT) → 诊断日志和跟踪