请列举出UDS中NRC CODE及相关含义
时间: 2025-06-04 13:00:56 浏览: 41
以下是UDS(Unified Diagnostic Services)协议中常见的NRC(Negative Response Codes)代码及其含义的表格形式展示。这些代码来源于ISO 14229标准文档[^1],并结合实际应用场景进行了整理。
### UDS 协议 NRC 代码列表
| **NRC代码** | **十六进制值** | **描述** |
|-------------|----------------|----------------------------------------------------------------------------------------------|
| General Reject | `0x10` | 通用拒绝:服务请求被拒绝,通常是因为ECU内部逻辑判定此服务不可执行。 |
| Sub-Function Not Supported | `0x12` | 子功能不受支持:当前SID的服务子功能未被实现或不适用于该ECU。 |
| Incorrect Message Length or Invalid Format | `0x13` | 消息长度错误或格式无效:接收到的消息不符合预期的长度或格式要求。 |
| Conditions Not Correct | `0x22` | 条件不满足:某些先决条件未达成,例如电源模式、档位状态等不适合执行该服务。 |
| Request Sequence Error | `0x24` | 请求序列错误:多个连续请求之间的顺序有问题,可能需要重新初始化通信过程。 |
| Required Time Delay Not Expired | `0x35` | 必要的时间延迟未过期:上次操作完成后,必须等待一段时间才能再次发起相同类型的请求。 |
| Security Access Denied | `0x33` | 安全访问被拒绝:尝试进入安全区域的操作失败,可能是密钥验证未通过或权限不足。 |
| Session Control Not Allowed | `0x78` | 不允许切换会话:当前状态下不允许更改诊断会话模式。 |
---
#### 示例场景解析
当客户端向ECU发送一个服务请求时,如果ECU检测到任何异常情况,则会返回带有否定响应码(NRC)的结果包。例如,在调用Security Access (`0x27`)服务过程中,若输入的安全种子校验失败,则ECU将回应数据流为`7F 27 33`,其中`7F`代表否定响应标志,而`33`即表示“安全性访问受限”的具体原因[^2]。
```python
def interpret_nrc(response_code):
nrc_map = {
0x10: "General Reject",
0x12: "Sub-function not supported",
0x13: "Incorrect message length or invalid format",
0x22: "Conditions not correct",
0x24: "Request sequence error",
0x33: "Security access denied",
0x35: "Required time delay not expired",
0x78: "Session control not allowed"
}
return nrc_map.get(response_code, "Unknown NRC")
# Example usage of the function
print(interpret_nrc(0x12)) # Output: Sub-function not supported
```
上述Python函数可用于快速查询指定数值对应的NRC意义。
---
阅读全文
相关推荐

















