Skip to content

DTC's (Diagnostic Trouble Codes)

Procedure: ClearVehicleFaults

void ClearVehicleFaults()

Description:
Clears all the diagnostic trouble codes (DTCs) for the entire vehicle.

Usage Example
ClearVehicleFaults();
PrintLine("All vehicle DTCs cleared.");

Function: ClearFaults

bool ClearFaults()

Description:
Attempts to clear the diagnostic trouble codes (DTCs) from the ECU.

Return Value:
Returns true if the DTCs were successfully cleared from the ECU, otherwise false.

Usage Example
1
2
3
if (!OpenEcu(0x19)) return;
bool success = ClearFaults();
PrintLine($"DTCs cleared from ECU: {success}");

Function: GetDtcCount

int GetDtcCount(byte mask = 0xAE)

Description:
Retrieves the count of Diagnostic Trouble Codes (DTCs) based on the provided mask.

Parameters:
- mask: The mask used to filter the DTCs. Default value is 0xAE.

Return Value:
Returns an integer representing the count of DTCs that match the given mask. -1 if an error occured.

Usage Example
1
2
3
4
5
6
if (OpenEcu(0x01))
{
    int dtcCount = GetDtcCount();
    PrintLine($"DTC Count: {dtcCount}");
    CloseEcu();
}

Function: GetDtc

byte[] GetDtc(byte mask = 0xAE)

Description:
Retrieves the Diagnostic Trouble Codes (DTCs) raw data based on the provided mask.

Parameters:
- mask: The mask used to filter the DTCs. Default value is 0xAE.

Return Value:
Returns a byte array containing the DTCs raw data that match the given mask.

Usage Example
1
2
3
4
5
6
if (OpenEcu(0x01))
{
    byte[] dtcCodes = GetDtc();
    PrintLine($"DTC Codes: {ArrayToHexString(dtcCodes)}");
    CloseEcu();
}

Function: GetDtcList

(int code, byte status)[] GetDtcList(byte[] data)

Description:
Processes the provided data to generate a list of DTC codes and their corresponding statuses. Use GetDtc() to read raw DTC data.

Parameters:
- data: Byte array containing the raw DTC data.

Return Value:
Returns an array of tuples, where each tuple consists of a DTC code and its status.

Usage Example
if (OpenEcu(0x01))
{
    byte[] dtcData = GetDtc();
    var dtcList = GetDtcList(dtcData);
    foreach (var dtc in dtcList)
    {
        PrintLine($"DTC Code: {dtc.code}, Status: {dtc.status}");
    }
    CloseEcu();
}   

Function: GetDtcDescription

(string sae, string odx, string text) GetDtcDescription(int address, int code)

Description:
Retrieves a detailed description of a Diagnostic Trouble Code based on ECU address and DTC code.

Parameters:
- address: The address of the ECU.
- code: The code of the DTC.

Return Value:
Returns a tuple containing the SAE code, ODX text, and a descriptive text for the given DTC.

Usage Example
int ecuAddress = 0x01;
if (OpenEcu(ecuAddress))
{
    byte[] dtcData = GetDtc();
    var dtcList = GetDtcList(dtcData);
    foreach (var dtc in dtcList)
    {
        PrintLine($"DTC Code: {dtc.code:X6}, Status: {dtc.status}");
        var dtcDescription = GetDtcDescription(ecuAddress, dtc.code);
        PrintLine($"SAE: {dtcDescription.sae}, ODX: {dtcDescription.odx}, Description: {dtcDescription.text}");
    }
    CloseEcu();
}