参考:https://zhuanlan.zhihu.com/c_153808584
Fault Code Status Bits in Automotive Diagnostics
Status bits in Automotive Diagnostics
Diagnostic Trouble Code: When Fault occurs in vehicle, associated ECU captures it and stores it in memory as fault code. This is specific number for type of Fault and is called Diagnostic Trouble Code. This information can be retrieved either by tools at service station or by in vehicle methodologies.
Operation Cycle: Operation Cycle is the state in which ECU is operational. This is designer specific and it can be based on specific vehicle modes also. (Ex: Running, Pre-Running, Cranking)
kl15通,打火成功,kl15断,这算是一个cycle。
kl15通,未打火,kl15断,则不算是一个cycle。
Monitor Routine: Monitor Routine or Test Routine is the program which runs every operation cycle at some periodicity. They check whether the fault is still injected or active or not. Accordingly counter for the maturity of the fault for active and inactive will be decided. Maturity of the fault confirms the DTC for active and inactive state.
Clearing the DTC: DTC clearing is done using the ISO command for requesting Clear from the tester. The service ID is 14 for clearing the current DTCs(Fault code).
DTC status Bits: Each DTC will have Status byte that provides the status information of DTC. Each bit in the status bytes has meaning and provides different information. Let’s start with LSB
某厂的规定:
Bit0 => This Bit is “testFailed”. This bit provides the information about the fault (Error) is still active (injected) or not. If Fault is still injected or Active, then the value is 1 otherwise the value is 0. Ex: Fault “Short Circuit” is still active.
通常来说,ECU内部以循环的方式不断地针对预先定义好的错误路径进行测试,如果在最近的一次测试中,在某个错误路径中发现了故障,则相应DTC的这一个状态位就要被置1,表征出错。此时DTC的testFailed位被置1,但是它不一定被ECU存储到non-volatile memory中,只有当pendingDTC或confirmedDTC被置1时DTC才会被存储。而pendingDTC或confirmedDTC被置1的条件应该是检测到错误出现的次数或时间满足某个预定义的门限。当错误消失或者诊断仪执行了清除DTC指令时,testFailed会再次被置为0。
Bit1 => This Bit is “testFailedThisOperationCycle”. This bit indicates whether the fault is occurred anytime during the current operation cycle. If Fault has occurred in the current operation cycle, then the value is 1 otherwise the value is 0.
这个bit用于标识某个DTC在当前的operation cycle中是否出现过testFailed置1的情况,即是否出现过错误。operation cycle的起始点是ECU通过网络管理唤醒到ECU通过网络管理进入睡眠,对于没有网络管理的ECU,这个起始点就是KL15通断。通过bit 0我们无法判断某个DTC是否出现过,比如,当前testFailed = 0, 说明当前这个DTC没有出错,*如果testFailedThisOperationCycle = 1的话,就说明这个DTC在当前这个operation cycle中出过错,但是当前错误又消失了。
*
Bit2 => This Bit is “pendingDTC”. This bit indicates whether the fault is occurred anytime during the current operation cycle. The only difference between “testFailedThisOperationCycle” and “pendingDTC” is “testFailedThisOperationCycle” is cleared at the end of current operation cycle (least bothering whether the fault is still active or inactive) and “pendingDTC” is cleared only when in next operation cycle the monitor routine is run and the result shows pass(fault is not present). So if Fault is still injected or Active in the current operation cycle, then the value is 1 otherwise if the Fault was active in previous operation cycle and is inactive (i.e monitor routine is run and fault is inactive) in the current operation cycle, then the value is 0.
根据规范的解释,pendingDTC = 1表示某个DTC在当前或者上一个operation cycle中是否出现过。pendingDTC位其实是位于testFailed和confirmedDTC之间的一个状态,有的DTC被确认的判定条件比较严苛,需要在多个operation cycle中出现才可以被判定为confirmed的状态,此时就需要借助于pendingDTC位了。pendingDTC = 1的时候,DTC就要被存储下来了,如果接下来的两个operation cycle中这个DTC都还存在,那么confirmedDTC就要置1了。如果当前operation cycle中,故障发生,pendingDTC = 1,但是在下一个operation cycle中,故障没有了,pendingDTC 仍然为 1,再下一个operation cycle中,故障仍然不存在,那么pendingDTC 就可以置0了。
Bit3 => This Bit is “confirmedDTC”. This bit informs that fault is continuously active for specific monitor routines and is matured enough in the current operation cycle so that it can be said Confirmed. If fault is active and matured, then the value is 1 otherwise the value is 0.
当confirmedDTC = 1时,则说明某个DTC已经被存储到ECU的non-volatile memory中,说明这个DTC曾经满足了被confirmed的条件。但是请注意,confirmedDTC = 1时,并不意味着当前这个DTC仍然出错,如果confirmedDTC = 1,但testFailed = 0,则说明这个DTC表示的故障目前已经消失了。将confirmedDTC 重新置0的方法只有删除DTC,UDS用0x14服务,OBD用0x04服务。
Bit4 => This Bit is “testNotCompletedSinceLastClear”. This bit informs that monitor routine is not run in the current operation cycle(once after Clearing the DTC is done). The reason for not running in the current operation cycle can be because particular pin is inactive in the operation cycle(Ex: Parked or hibernate vehicle mode). If the monitor routine is not completed this operation cycle, then the value is 1 otherwise the value is 0.
这个bit用于标识,自从上次调用了清理DTC的服务(UDS用0x14服务,OBD用0x04服务)之后,是否成功地执行了对某个DTC的测试(不管测试结果是什么,只关心是否测了)。因为很多DTC的测试也是需要满足某些边界条件的,并不是ECU上电就一定会对DTC进行检测。
testNotCompletedSinceLastClear = 1 : 自从清理DTC之后还没有完成过针对该DTC的测试。
testNotCompletedSinceLastClear = 0 : 自从清理DTC之后已经完成过针对该DTC的测试。
Bit5 => This Bit is “testFailedSinceLastClear”. This bit informs monitor routine has reported that test has failed (at least once Bit0 is set) in any operation cycle at least once after clearing the DTC action is performed. If the fault has occurred after clear DTC is performed, then the value is 1 otherwise the value is 0.
这个位与bit 1 :testFailedThisOperationCycle有些类似,后者标识某个DTC在当前的operation cycle中是否出现过testFailed置1的情况,而testFailedSinceLastClear标识的是在上次执行过清理DTC之后某个DTC是否出过错。
testFailedSinceLastClear = 1, 自从清理DTC之后该DTC出过至少一次错。
testFailedSinceLastClear = 0 , 自从清理DTC之后该DTC没有出过错。
Bit6 => This Bit is “testNotCompletedThisOperationCycle”. This bit informs that the monitor routine is still not run during this current operation cycle. This is because the pin is not active for this operation cycle or when the request is sent from the tester, the monitor routine is not run. If the monitor routine is not run this operation cycle, then the value is 1 otherwise the value is 0.
这个位与bit 4 : testNotCompletedSinceLastClear类似,后者标识自从上次调用了清理DTC的服务之后,是否成功地执行了对某个DTC的测试。而testNotCompletedThisOperationCycle则标识在当前operation cycle中是否成功地执行了对某个DTC的测试。
testNotCompletedThisOperationCycle = 1 : 在当前operation cycle中还没在完成过针对该DTC的测试。
testNotCompletedThisOperationCycle = 0 : 在当前operation cycle中已经完成过针对该DTC的测试。
Bit7 => This Bit is “warningIndicatorRequested”. This bit is used to bring into the attention of the user or driver when the fault occurs. If fault occurs and any monitor is required for specific fault, then the value is 1 otherwise the value is 0.
某些比较严重的DTC会与用户可见的警告指示相关联,比如仪表上的报警灯,或者是文字,或者是声音。这个warningIndicatorRequested就用于此类DTC。
warningIndicatorRequested = 1 : ECU请求激活警告指示。
warningIndicatorRequested = 0: ECU不请求激活警告指示。
注意,如果这个DTC不支持警告指示,则这个位永远置0。
0x14:ClearDiagnosticInformation
这条诊断命令的格式比较简单,用法也很好理解,即删除存储在ECU中的DTC。
第一个字节就是SID了,后边的三个字节用于标识将要被删除的DTC种类,UDS规定用FF FF FF表示所有种类的DTC,由厂家自定义代表Powertrain、Chassis、、Body、Network Communication等种类DTC的值。
比如,14 FF FF FF这条指令表示的就是删除掉ECU中的所有DTC。ECU只需要返回一个0x54表示成功执行即可。
0x19:ReadDTCInformation
这条指令用于读取存储在ECU中的DTC,它的格式如下
0x14诊断命令请求的格式
0x19服务的sub-function代表了各式各样读取DTC的方法,UDS给19服务的sub-function从0x00到0x19进行了明确定义,我只使用过其中4种,下面对我用过的这些进行介绍,如果大家对其他的感兴趣,可以查阅ISO 14229的定义。
sub-function = 0x01 (reportNumberOfDTCByStatusMask)
sub-function = 0x01用于读取符合特定条件的DTC数量,此时parameter为一个byte的Mask,用于与DTC的Status进行“与”运算,而ECU返回的则是"与"运算之后结果不为0的DTC的数量。DTC的Status用一个byte表示,其中的8个bit分别代表DTC的不同状态,比如,bit 0 表示这个DTC是active的还是passive的,bit 4表示这个DTC是否已经被confirm了,如果DTC的状态是confirm,则说明该DTC已经被ECU存储下来了。
比如:19 01 08这个命令的用途,就是读取所有状态为confirm的DTC的数量。
19 01 09 读所有状态为confirm并且当前为active 的DTC 数量,也就是所有历史DTC 和当前DTC的数量。
比如19 02 01这个命令的用途,就是读取所有状态为active的DTC的数量。此时ECU返回的格式应该是59 02 01 XX XX XX 01 YY YY YY 09…。返回的DTC列表中的每个条目为4个字节,前三个字节用于标识DTC,比如 XX XX XX,最后一个字节用于标识DTC状态,比如01,表示DTC是active的,09表示DTC是active且confirm的。