Hello all;
So I am working on a CANBUS Arduino application that can read trouble codes from a vehicle. I searched the forums and got some great tips on a MCP2515 library, and have tested out the library and it works great when obtaining PIDs from the vehicle’s ECU, one thing I have not been able to find however is how to parse the trouble codes.
Looking at wikipedia I found that you can request the trouble codes by doing a request to 0x03. This was fairly easy and I did manage to get a response from my vehicle.
Using the MCP2515 library, this is the message I sent:
message.adrsValue = 0x7DF;
message.data[0] = 0x01;
message.data[1] = 0x03;
for(int i = 2; i < 8; i++) {
message.data[i] = 0x00;
}
And I get a return message of
message.adrsValue = 0x7E8;
message.data[0] = 0x04;
message.data[1] = 0x43;
message.data[2] = 0x01;
message.data[3] = 0x01;
message.data[4] = 0x00;
message.data[5] = 0x00;
message.data[6] = 0x00;
message.data[7] = 0x00;
I did manage to find some code on google that allowed me to get the first DTC:
if(message.data[1] == 0x43) {
int hexA = message.data[3];
int hexB = message.data[4];
String milCode = "";
switch(hexA & 0xC0)
{
case 0x00:
milCode += 'P'; // powertrain
break;
case 0x40:
milCode += 'C'; // chassis
break;
case 0x80:
milCode += 'B'; // body
break;
case 0xC0:
milCode += 'U'; // network
break;
}
milCode += String((hexA & 0x30) >> 4, DEC); // first digit is 0-3 only
milCode += String((hexA & 0x0F), DEC);
milCode += String((hexB & 0xF0) >> 4, DEC);
milCode += String((hexB & 0x0F), DEC);
But now I am confused how I would be able to get the other stored DTC’s ? Although the response that came back from my car shows only one trouble code, I know there are times when more than one code is being thrown.
Can anyone help? Thanks!