diff --git a/examples/CaptureAllMsgTypes.js b/examples/CaptureAllMsgTypes.js new file mode 100644 index 0000000..b89c101 --- /dev/null +++ b/examples/CaptureAllMsgTypes.js @@ -0,0 +1,30 @@ +function setup () +{ + host.log("Example script 1.0"); + host.setTickInterval(20000); + can.sendFrame(0, 0x200, 4, [1,30,20,10]); + uds.sendUDS(0, 0x604, 0x3E, 1, 0, 0, 0); + can.setFilter(0x100, 0x700, 0); + uds.setFilter(0x600, 0x7F0, 0); + +} + +function gotCANFrame (bus, id, len, data) +{ + host.log("Bus: " + bus + " id: " + id.toString(16)); +} + +function gotISOTPMessage(bus, id, len, data) +{ + host.log("ISOTP bus " + bus + " ID: " + id.toString(16)); +} + +function gotUDSMessage(bus, id, service, subFunc, len, data) +{ + host.log("UDS Bus: " + bus + " ID: " + id.toString(16) + " Sv: " + service.toString(16)); +} + +function tick() +{ + host.log("TICK!"); +} \ No newline at end of file diff --git a/examples/GetCANandTick.js b/examples/GetCANandTick.js new file mode 100644 index 0000000..38a857a --- /dev/null +++ b/examples/GetCANandTick.js @@ -0,0 +1,17 @@ +function setup () +{ + host.log("Example script 1.0"); + host.setTickInterval(20000); + can.sendFrame(0, 0x7E0, 8, [0x0d, 1, 0, 0, 0, 0, 0, 0]); + + can.setFilter(0x100, 0x700, 0); +} + +function gotCANFrame (bus, id, len, data) +{ + host.log("Bus: " + bus + " id: " + id.toString(16)); +} +function tick() +{ + host.log("TICK!"); +} \ No newline at end of file diff --git a/examples/RLEC.js b/examples/RLEC.js new file mode 100644 index 0000000..320ad65 --- /dev/null +++ b/examples/RLEC.js @@ -0,0 +1,44 @@ +var newID = 0; + +function setup () +{ + host.log("RLEC ID Changer"); + can.setFilter(0x0, 0x0F, 0); + can.sendFrame(0, 0x7E0, 8, [0x0d, 1, 0, 0, 0, 0, 0, 0]); +} + +function gotCANFrame (bus, id, len, data) +{ + var dataBytes = []; + + if (len == 8) + { + if (data[0] == 0xd && data[1] == 1 && data[2] == 0xAA) + { + host.log("Got challenge: 0x" + data[3].toString(16) + data[4].toString(16)); + var notData3 = ~data[3]; + var notData4 = ~data[4]; + dataBytes[0] = 0xD; + dataBytes[1] = 2; + dataBytes[2] = ((notData4 & 0xF) << 4) + ((notData3 >> 4) & 0xF); + dataBytes[3] = ((notData4 >> 4) & 0xF) + ((notData3 & 0xF) << 4); + dataBytes[4] = 0; + dataBytes[5] = 0; + dataBytes[6] = 0; + dataBytes[7] = 0; + can.sendFrame(0, 0x7E0, 8, dataBytes); + } + if (data[0] == 0xd && data[1] == 2 && data[2] == 0xAA) + { + host.log("Passed security Check!"); + dataBytes[0] = 4; + dataBytes[1] = 0x15; + dataBytes[2] = newID; + can.sendFrame(0, 0x7E0, 8, dataBytes); + } + if (data[0] ==4 && data[1] == 0x15 && data[2] == 0xAA) + { + host.log("ID Reprogramming Successful!"); + } + } +} \ No newline at end of file diff --git a/examples/UpdateParameter.js b/examples/UpdateParameter.js new file mode 100644 index 0000000..6dda11a --- /dev/null +++ b/examples/UpdateParameter.js @@ -0,0 +1,12 @@ +var testingVar = 10; + +function setup() +{ + host.addParameter("testingVar"); + host.setTickInterval(2000); +} + +function tick() +{ + testingVar++; +} \ No newline at end of file