主页 > 开源代码  > 

【ISO14229-1:2023UDS诊断(ECU复位0x11服务)测试用例CAPL代码全解析⑧】

【ISO14229-1:2023UDS诊断(ECU复位0x11服务)测试用例CAPL代码全解析⑧】
ISO 14229-1:2023 UDS诊断【ECU复位0x11服务】_TestCase08

作者:车端域控测试工程师 更新日期:2025年02月17日 关键词:UDS诊断协议、ECU复位服务、0x11服务、ISO 14229-1:2023

TC11-008测试用例 用例ID测试场景验证要点参考条款预期结果TC11-008多复位请求冲突处理连续发送3次复位请求§8.4.1仅首次请求生效,后续返回NRC=0x78 以下是为TC11-008设计的增强型CAPL测试用例,包含时序控制与状态跟踪机制,包含执行流程图和工业级异常处理: /*---------------------------------------------------------- Title:TC11-008 多复位请求冲突处理验证 作者:车端域控测试工程师 日期:2025-02-17 ------------------------------------------------------------*/ variables { // 通信参数 const long DiagReqID = 0x732; // 诊断请求标识符 const long DiagResID = 0x733; // 诊断响应标识符 const byte ResetSvc = 0x11; // 复位服务ID const byte ResetSub = 0x01; // 硬件复位子功能 const byte ExpectedNRC = 0x78; // 预期否定响应码 // 测试控制参数 msTimer responseTimer; int requestCounter = 0; byte responseStatus[3]; // 存储三次响应状态 } testcase TC11_008_MultiResetTest() { TestModuleTitle("TC11-008 多复位请求冲突验证"); // ███ 阶段1:连续发送三次复位请求 ███ testStep("STEP1 发送三次复位请求(间隔150ms)"); for(requestCounter=0; requestCounter<3; requestCounter++) { // 发送复位请求 message DiagReqID [CAN] { dlc = 2; byte(0) = ResetSvc; byte(1) = ResetSub; } output(this); // 启动响应监测窗口 setTimer(responseTimer, 300); while(getTimer(responseTimer) < 300) { if(TestWaitForMessage(DiagResID, 50)) { // 响应解析逻辑 if(this.byte(0) == 0x51) { responseStatus[requestCounter] = 1; // 肯定响应 testAddLog("请求%d: 收到肯定响应", requestCounter+1); break; } else if(this.byte(0) == 0x7F && this.byte(1) == ResetSvc && this.byte(2) == ExpectedNRC) { responseStatus[requestCounter] = 2; // 否定响应 testAddLog("请求%d: 收到NRC=0x%02X", requestCounter+1, ExpectedNRC); break; } } } // 超时处理 if(responseStatus[requestCounter] == 0) { responseStatus[requestCounter] = 3; // 响应超时 testAddLog("请求%d: 响应超时", requestCounter+1); } // 请求间隔控制 testWait(150); } // ███ 阶段2:结果验证 ███ testStep("STEP2 响应结果验证"); // 首次请求验证 if(responseStatus[0] == 1) { testStepPass("首次请求成功执行"); } else { testStepFail("首次请求失败(状态码:%d)", responseStatus[0]); } // 后续请求验证 for(int i=1; i<3; i++) { if(responseStatus[i] == 2) { testStepPass("请求%d返回NRC=0x78", i+1); } else { testStepFail("请求%d异常(状态码:%d)", i+1, responseStatus[i]); } } // 综合判定 if(responseStatus[0]==1 && responseStatus[1]==2 && responseStatus[2]==2) { testCasePass("多复位冲突处理验证通过"); } else { testCaseFail("冲突处理机制异常"); } } /*---------------------------------------------------------- 系统状态监控模块(扩展功能) ----------------------------------------------------------*/ on sysvar ECU::ResetStatus { if(@this::ResetStatus == 1) { testAddLog("ECU复位操作已触发"); testAddCondition("复位持续时间:%dms", sysGetTimer(ECU_RESET_TIMER)); } }

流程图解(执行逻辑可视化)

#mermaid-svg-L3uezSKV0YzPk6Xx {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx .error-icon{fill:#552222;}#mermaid-svg-L3uezSKV0YzPk6Xx .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-L3uezSKV0YzPk6Xx .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-L3uezSKV0YzPk6Xx .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-L3uezSKV0YzPk6Xx .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-L3uezSKV0YzPk6Xx .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-L3uezSKV0YzPk6Xx .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-L3uezSKV0YzPk6Xx .marker{fill:#333333;stroke:#333333;}#mermaid-svg-L3uezSKV0YzPk6Xx .marker.cross{stroke:#333333;}#mermaid-svg-L3uezSKV0YzPk6Xx svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-L3uezSKV0YzPk6Xx .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-L3uezSKV0YzPk6Xx text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-L3uezSKV0YzPk6Xx .actor-line{stroke:grey;}#mermaid-svg-L3uezSKV0YzPk6Xx .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx .sequenceNumber{fill:white;}#mermaid-svg-L3uezSKV0YzPk6Xx #sequencenumber{fill:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx .messageText{fill:#333;stroke:#333;}#mermaid-svg-L3uezSKV0YzPk6Xx .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-L3uezSKV0YzPk6Xx .labelText,#mermaid-svg-L3uezSKV0YzPk6Xx .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-L3uezSKV0YzPk6Xx .loopText,#mermaid-svg-L3uezSKV0YzPk6Xx .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-L3uezSKV0YzPk6Xx .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-L3uezSKV0YzPk6Xx .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-L3uezSKV0YzPk6Xx .noteText,#mermaid-svg-L3uezSKV0YzPk6Xx .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-L3uezSKV0YzPk6Xx .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-L3uezSKV0YzPk6Xx .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-L3uezSKV0YzPk6Xx .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-L3uezSKV0YzPk6Xx .actorPopupMenu{position:absolute;}#mermaid-svg-L3uezSKV0YzPk6Xx .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-L3uezSKV0YzPk6Xx .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-L3uezSKV0YzPk6Xx .actor-man circle,#mermaid-svg-L3uezSKV0YzPk6Xx line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-L3uezSKV0YzPk6Xx :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Tester ECU 复位请求 肯定响应(0x51) 复位请求 NRC=0x78 复位请求 NRC=0x78 Tester ECU

关键参数说明表

参数名称示例值工程配置要点请求间隔150ms需小于ECU复位执行时间响应超时300ms覆盖ECU最大响应时间NRC 0x78请求未响应ISO 14229-1标准定义复位子功能0x01OEM定义的硬件复位类型

响应状态矩阵

请求序号预期状态失败场景示例1肯定响应(0x51)ECU未执行复位2NRC=0x78返回其他NRC或超时3NRC=0x78错误响应或系统崩溃

工业级增强功能

复位状态跟踪

// 通过系统变量监控实际复位动作 on sysvar ECU::PowerStatus { if(@this::PowerStatus == 0x02) { testAddLog("ECU进入重启流程"); } }

压力测试扩展

void ExecuteStressTest() { // 可扩展: // 1. 连续发送10次复位请求 // 2. 随机间隔测试(50-500ms) // 3. 混合其他服务请求 }

时序校验逻辑

// 验证响应时序合规性 if(getTimer(responseTimer) < 200) { testAddCondition("响应时间:%dms", getTimer(responseTimer)); }

专家调试技巧:

在Graphics窗口添加观测信号:ECU::ResetStatus sysvar::DiagResponseTime 使用Diagnostic Console设置过滤条件:filter.id = 0x733 && (payload[0] == 0x51 || payload[0] == 0x7F) 添加总线监测断点:break if (this.id == 0x733 && this.byte(0) == 0x7F)
标签:

【ISO14229-1:2023UDS诊断(ECU复位0x11服务)测试用例CAPL代码全解析⑧】由讯客互联开源代码栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“【ISO14229-1:2023UDS诊断(ECU复位0x11服务)测试用例CAPL代码全解析⑧】