KopherBit
診斷通訊

AUTOSAR DEM / DCM / FiM:ECU 診斷模組架構

AUTOSAR Classic 的 DEM (Diagnostic Event Manager)、DCM (Diagnostic Communication Manager) 與 FiM (Function Inhibition Manager) 共同組成 ECU 診斷子系統。本文整理三者的職責、互動方式與 KopherSAR 對其完整實作。

Summary

AUTOSAR Classic ECU 的診斷子系統由三個核心模組組成:

  • DEM (Diagnostic Event Manager):管理事件、DTC 狀態機、Snapshot、Aging。
  • DCM (Diagnostic Communication Manager):處理 UDS (ISO 14229) 服務請求並路由至 DEM / SWC。
  • FiM (Function Inhibition Manager):依故障狀態抑制功能(防止有故障時持續運行的功能造成更大損壞)。

KopherSAR 完整實作三者,並透過 KopherConfig 統一配置 DTC 清單、Snapshot、Inhibition 條件、UDS Session 與 SecurityAccess。

Technical Role

DEM (Diagnostic Event Manager)

  • 接收應用層 SWC 或 BSW 透過 Dem_SetEventStatus 提交的事件狀態。
  • 依事件對應規則 (event-to-DTC mapping) 更新 DTC 狀態機 (test failed, confirmed, pending, healed, aged…)。
  • 維護 Snapshot Record (Freeze Frame) 與 Extended Data Record。
  • 持久化 DTC 至 NV Memory (NvM)。

DCM (Diagnostic Communication Manager)

  • 接收 ISO 14229 UDS 訊息(透過 PduR / CanTp / DoIP)。
  • 解析服務 ID、Sub-Function、參數,路由至 DEM、NvM、ECU State Manager 或應用 SWC。
  • 管理 Diagnostic Session (Default / Programming / Extended)、SecurityAccess、TesterPresent。
  • 回應正向 / 負向回應碼 (NRC)。

FiM (Function Inhibition Manager)

  • 依 DEM 提供的 DTC 狀態(如 confirmed),抑制特定 SWC 功能。
  • 應用層 SWC 在執行前先查詢 FiM (FiM_GetFunctionPermission),依結果決定是否執行。
  • 確保有故障時不誤觸發可能造成更大損壞的功能(例如電池過熱時關閉快充)。

Architecture

                   ┌─────────────────────────────┐
                   │    Tester / KopherUDS       │
                   └──────────────┬──────────────┘
                                  │ UDS over CAN / DoIP

                   ┌─────────────────────────────┐
                   │  PduR / CanTp / DoIP        │
                   └──────────────┬──────────────┘

                   ┌─────────────────────────────┐
                   │            DCM              │
                   │  (Service Routing,           │
                   │   Session Management)        │
                   └──┬───────────┬──────────────┘
                      │           │
              0x19/0x14│           │0x27/0x10/0x11/0x31...
                      ▼           ▼
              ┌──────────┐    ┌──────────┐
              │   DEM    │    │ Routine  │
              │ (DTC FSM)│    │ Handler  │
              └──┬───────┘    └──────────┘

                 │ Inhibition

              ┌──────────┐    ┌──────────┐
              │   FiM    │◀───│   SWC    │
              └──────────┘    └──────────┘

Key Capabilities

DEM

  • 事件至 DTC 對應、DTC 狀態機 (UDS DTC Status Byte 8 bit)。
  • Snapshot / Extended Data 配置。
  • Aging Cycle / Healing Cycle / Operation Cycle 管理。
  • DTC Severity / Priority。
  • OBD 兼容 DTC 編碼。
  • 持久化 DTC 至 NV Memory。

DCM

  • 完整 ISO 14229 服務集 (0x10、0x11、0x14、0x19、0x22、0x23、0x27、0x28、0x2E、0x2F、0x31、0x34/0x36/0x37、0x3D、0x3E、0x85、0x87)。
  • Session / Security 管理。
  • TesterPresent 心跳。
  • 路由至 SWC Routine、DEM、NvM。

FiM

  • 依 DTC 狀態抑制功能(黑名單機制)。
  • 整合 BswM 模式切換。
  • 支援多 DTC 條件組合。

Engineering Inputs Required

輸入用途
DTC 清單 + 描述DEM 配置基礎。
Snapshot / Extended Data 項目觸發時凍結哪些訊號、累積哪些統計。
Aging / Healing 規則何時自動解除 DTC。
UDS 服務範圍哪些服務需要在哪個 Session 下啟用、是否需要 SecurityAccess。
Routine 清單0x31 RoutineControl 對應的應用層 Routine 函式。
FiM 抑制規則哪些 SWC 功能在哪些 DTC 狀態下被抑制。
持久化策略DTC / Snapshot 寫入 NvM 的時機與區段配置。

How KopherBit Supports This

  • 完整 BSW:KopherSAR DEM / DCM / FiM 完整實作,符合 AUTOSAR Classic 規範。
  • 配置工具:KopherConfig 圖形化配置 DTC、Snapshot、UDS 服務、SecurityAccess、FiM 規則。
  • 上位機:KopherUDS 直接對接 DCM,方便驗證所有服務行為。
  • 整合:與 KopherBoot UDS Bootloader 共享 SecurityAccess 演算法與 Session 邏輯。

FAQ

DEM 的 DTC 狀態機有哪 8 個位元?

DTC Status Byte (ISO 14229):testFailed、testFailedThisOperationCycle、pendingDTC、confirmedDTC、testNotCompletedSinceLastClear、testFailedSinceLastClear、testNotCompletedThisOperationCycle、warningIndicatorRequested。

DCM 與 SWC 之間的 Routine 如何呼叫?

DCM 收到 0x31 RoutineControl 後,依 ARXML 配置路由到應用層 SWC 提供的 Routine 函式(透過 RTE)。SWC 完成 Routine 後回傳結果給 DCM,由 DCM 組裝 UDS 回應。

FiM 與 BswM 差異?

FiM 專注於依故障狀態抑制功能;BswM 處理通訊、ECU 模式切換等更大範圍的模式管理。兩者可互補:BswM 切換通訊模式,FiM 抑制特定功能。

是否所有 SWC 都需要查詢 FiM?

不是。僅有「故障時不應執行」的功能(例如安全相關功能)需查詢 FiM。配置時依安全分析決定。

DEM 是否支援 DEM 2.0?

KopherSAR DEM 對應 AUTOSAR Classic Platform 規範。如客戶有特定 DEM 2.0(含 multi-event memory、DTC priority 等高階功能)需求,可依專案配置範圍調整。

Snapshot 與 OBD Freeze Frame 差異?

UDS Snapshot 由 OEM 自行定義內容;OBD Freeze Frame 為法規標準化的訊號集。對 OBD 相關 ECU 需另實作 OBD-II 服務 (0x01–0x0A),KopherSAR DCM 提供 OBD 子模組。

JSON-LD

{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "AUTOSAR DEM / DCM / FiM:ECU 診斷模組架構",
  "description": "AUTOSAR Classic 的 DEM、DCM、FiM 三大診斷模組職責、互動方式與 KopherSAR 完整實作。",
  "url": "https://kopherbit.com/knowledge/autosar-dem-dcm-fim-diagnostics/",
  "datePublished": "2026-05-09",
  "dateModified": "2026-05-09",
  "inLanguage": "zh-TW",
  "keywords": ["DEM", "DCM", "FiM", "AUTOSAR", "Diagnostics", "UDS", "DTC"],
  "articleSection": "Diagnostics",
  "author": { "@type": "Organization", "name": "KopherBit", "url": "https://kopherbit.com" },
  "publisher": { "@type": "Organization", "name": "KopherBit", "logo": { "@type": "ImageObject", "url": "https://kopherbit.com/logo.png" } }
}