Fixed error codes and clearing

Added mode 9
This commit is contained in:
brendan gecse 2019-12-02 23:45:01 +13:00
parent 492a95c2ab
commit c6aa55d009
4 changed files with 73 additions and 26 deletions

25
CAN.ino
View File

@ -1,28 +1,31 @@
void DOCAN()
{
if (!digitalRead(CAN0_INT))
if (!digitalRead(CAN0_INT))
{
CAN.readMsgBuf(&canId, &len, buf);
MODE = buf[1];
PID = buf[2];
if (MODE == 1)
{
if (ProcessMode1(PID))
{
CAN.sendMsgBuf(0x7E8, 0, 8, OBDIImsg);
if (ProcessMode1(PID))
{
CAN.sendMsgBuf(0x7E8, 0, 8, OBDIImsg);
}
}
}
else if (MODE == 3)
else if (MODE == 3)
{
ProcessMode3();
ProcessMode3();
}
else if (MODE == 4)
else if (MODE == 4)
{
ProcessMode4();
ProcessMode4();
}
else if (MODE == 9)
else if (MODE == 9)
{
//ProcessMode9();
if (ProcessMode9(PID))
{
CAN.sendMsgBuf(0x7E8, 0, 17, OBDIImsg);
}
}
}
}

View File

@ -17,16 +17,16 @@ byte sweep = 0;
//Adjustable values
byte Load = 10;
byte Load = 5;
byte TPS = 15;
int TA = 10;
float O2 = 1;
int ECT = 80;
int IAT = 30;
byte MAP = 99;
int RPM = 2000;
int MAF = 50;
byte VSS = 50;
int ECT = 0;
int IAT = 0;
byte MAP = 0;
int RPM = 1000;
int MAF = 10;
byte VSS = 25;
byte FP = 10;
void setup() {

View File

@ -2,17 +2,17 @@ void ProcessMode3()
{
OBDIImsg[0] = 6;
OBDIImsg[1] = 67;
OBDIImsg[2] = 1;
OBDIImsg[3] = 2;
OBDIImsg[4] = 23;
CAN.sendMsgBuf(0x7E8, 0, 8, OBDIImsg);
OBDIImsg[2] = 0x04;
OBDIImsg[3] = 0x20;
OBDIImsg[4] = 0x04;
OBDIImsg[5] = 0x21;
CAN.sendMsgBuf(0x7E8, 0, 6, OBDIImsg);
}
void ProcessMode4()
{
OBDIImsg[0] = 4;
OBDIImsg[1] = 65;
OBDIImsg[2] = 04;
OBDIImsg[3] = 44;
OBDIImsg[4] = 00;
CAN.sendMsgBuf(0x7E8, 0, 8, OBDIImsg);
OBDIImsg[2] = 0x44;
OBDIImsg[3] = 0x00;
CAN.sendMsgBuf(0x7E8, 0, 4, OBDIImsg);
}

44
MODE9.ino Normal file
View File

@ -0,0 +1,44 @@
bool ProcessMode9(byte PID)
{
OBDIImsg[0] = 6;
OBDIImsg[1] = 67;
OBDIImsg[2] = PID;
if (PID == 0x02) //VIN: XXXXXXXXXXXXXXXXX
{
OBDIImsg[3] = 0x20;
OBDIImsg[4] = 0x04;
OBDIImsg[5] = 0x21;
OBDIImsg[6] = 0x21;
OBDIImsg[7] = 0x21;
OBDIImsg[8] = 0x21;
OBDIImsg[9] = 0x21;
OBDIImsg[10] = 0x21;
OBDIImsg[11] = 0x21;
OBDIImsg[12] = 0x21;
OBDIImsg[13] = 0x21;
OBDIImsg[14] = 0x21;
OBDIImsg[15] = 0x21;
OBDIImsg[16] = 0x21;
return true;
}
if (PID == 0x04) //CALID: XXXXXXXXXXXXXXXX
{
OBDIImsg[3] = 0x20;
OBDIImsg[4] = 0x04;
OBDIImsg[5] = 0x21;
OBDIImsg[6] = 0x21;
OBDIImsg[7] = 0x21;
OBDIImsg[8] = 0x21;
OBDIImsg[9] = 0x21;
OBDIImsg[10] = 0x21;
OBDIImsg[11] = 0x21;
OBDIImsg[12] = 0x21;
OBDIImsg[13] = 0x21;
OBDIImsg[14] = 0x21;
OBDIImsg[15] = 0x21;
OBDIImsg[16] = 0x21;
return true;
}
return false;
}