From c6aa55d009361f029f246d23f1f1a6bd1441e216 Mon Sep 17 00:00:00 2001 From: brendan gecse Date: Mon, 2 Dec 2019 23:45:01 +1300 Subject: [PATCH] Fixed error codes and clearing Added mode 9 --- CAN.ino | 25 ++++++++++++++----------- HTSCANSIM.ino | 14 +++++++------- MODE34.ino | 16 ++++++++-------- MODE9.ino | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 MODE9.ino diff --git a/CAN.ino b/CAN.ino index 9d303c8..a4fe37d 100644 --- a/CAN.ino +++ b/CAN.ino @@ -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); + } } } } diff --git a/HTSCANSIM.ino b/HTSCANSIM.ino index 80c73ec..eed9cc4 100644 --- a/HTSCANSIM.ino +++ b/HTSCANSIM.ino @@ -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() { diff --git a/MODE34.ino b/MODE34.ino index b19c99e..d05e2c8 100644 --- a/MODE34.ino +++ b/MODE34.ino @@ -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); } diff --git a/MODE9.ino b/MODE9.ino new file mode 100644 index 0000000..ca50617 --- /dev/null +++ b/MODE9.ino @@ -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; +}