Purpose

Executes the OBD Request Permanent Fault Codes service. All permanent Diagnostic Trouble Codes (DTCs) are read.

Format

        long ndOBDRequestPermanentFaultCodes(
       TD1 *diagRef,
       TD3 *DTCDescriptor,
       TD4 DTCs[],
       long *len,
       LVBoolean *success);
      

Input

diagRef

Specifies the diagnostic session handle, obtained from ndOpenDiagnosticOnCANFD or ndOpenDiagnosticOnIPStack and passed to subsequent diagnostic functions. Normally, it is not necessary to manually manipulate the elements of this struct.

DTCDescriptor

A struct that describes the DTC records the ECU delivers:

             typedef struct {
            long DTCByteLength;
            long StatusByteLength;
            long AddDataByteLength;
            unsigned short ByteOrder;
            } TD3;
      

DTCByteLength indicates the number of bytes the ECU sends for each DTC. The default is 2.

StatusByteLength indicates the number of bytes the ECU sends for each DTC's status. The default is 0 for OBD.

AddDataByteLength indicates the number of bytes the ECU sends for each DTC's additional data. Usually, there are no additional data, so the default is 0.

ByteOrder indicates the byte ordering for multibyte items:

0: MSB_FIRST (Motorola) , default

1: LSB_FIRST (Intel)

This function interprets the response byte stream according to this description and returns the resulting DTC records in the DTCs struct array. Output

DTCs

Returns the resulting DTCs as an array of structs:

        typedef struct {
            unsigned long DTC;
            unsigned long Status;
            unsigned long AddData;
            } TD4;
      

DTC is the resulting Diagnostic Trouble Code. For the default 2-byte DTCs, use ndDTCToString to convert this code to readable format as defined by SAE J2012.

Status is the DTC status. Usually, this is a bit field with following meaning:

Bit Meaning
0 testFailed
1 testFailedThisMonitoringCycle
2 pendingDTC
3 confirmedDTC
4 testNotCompletedSinceLastClear
5 testFailedSinceLastClear
6 testNotCompletedThisMonitoringCycle
7 warningIndicatorRequested

For OBD, this field usually does not contain valid information.

AddData contains optional additional data for this DTC. Usually, this does not contain valid information (refer to DTCDescriptor).

len

On input, len must contain the DTCs array length in elements. On return, it contains the number of valid elements in the DTCs array.

success

Indicates successful receipt of a positive response message for this diagnostic service.

Return Value

The return value indicates the function call status as a signed 32-bit integer. Zero means the function executed successfully. A negative value specifies an error, which means the function did not perform the expected behavior. A positive value specifies a warning, which means the function performed as expected, but a condition arose that may require attention.

Use the ndStatusToString function to obtain a descriptive string for the return value.