From c0e2a872895de722b3b4bb8c0cdb224c961b0703 Mon Sep 17 00:00:00 2001 From: rusEFI LLC Date: Fri, 28 Jun 2024 13:39:48 -0400 Subject: [PATCH] only:nissan TCU R is smooth on jack stands with partial 4 ECU packets --- .../examples/man-in-the-middle-nissan-tcu.txt | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/firmware/controllers/lua/examples/man-in-the-middle-nissan-tcu.txt b/firmware/controllers/lua/examples/man-in-the-middle-nissan-tcu.txt index 5c44ae7d1f..bddfa14f4c 100644 --- a/firmware/controllers/lua/examples/man-in-the-middle-nissan-tcu.txt +++ b/firmware/controllers/lua/examples/man-in-the-middle-nissan-tcu.txt @@ -62,13 +62,13 @@ function relayFromECU(bus, id, dlc, data) txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU end -function onAnythingFromTCU(bus, id, dlc, data) - totalTcuMessages = totalTcuMessages + 1 - if id ~= TCU_251_593 and id ~= TCU_253_595 then - -- print('from TCU ' ..id .." " ..arrayToString(data) .." dropped=" ..totalDropped .." replaced " ..totalReplaced) - end +--function onAnythingFromTCU(bus, id, dlc, data) +-- totalTcuMessages = totalTcuMessages + 1 +-- if id ~= TCU_251_593 and id ~= TCU_253_595 then +-- -- print('from TCU ' ..id .." " ..arrayToString(data) .." dropped=" ..totalDropped .." replaced " ..totalReplaced) +-- end -- txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU -end +--end ENGINE_1_505 = 505 ENGINE_2_561 = 561 @@ -78,27 +78,36 @@ ENGINE_4_574 = 574 payloadENGINE_1_505 = {0x20, 0x00, 0x1a, 0x5e, 0x00, 0x00, 0x00, 0x00} function onENGINE_1_505(bus, id, dlc, data) --- payloadENGINE_1_505[x] = counter505_1f9 --- txCan(TCU_BUS, ENGINE_1_505, 0, payloadENGINE_1_505) - txCan(TCU_BUS, ENGINE_1_505, 0, data) +-- RPM + payloadENGINE_1_505[3] = data[3] + payloadENGINE_1_505[4] = data[4] + txCan(TCU_BUS, ENGINE_1_505, 0, payloadENGINE_1_505) +-- txCan(TCU_BUS, ENGINE_1_505, 0, data) end payloadENGINE_2_561 = {0xe0, 0x80, 0x09, 0xe0, 0xd4, 0xc3, 0x4c, 0x9e} function onENGINE_2_561(bus, id, dlc, data) --- txCan(TCU_BUS, ENGINE_2_561, 0, payloadENGINE_2_561) - txCan(TCU_BUS, ENGINE_2_561, 0, data) + payloadENGINE_2_561[3] = data[3] + txCan(TCU_BUS, ENGINE_2_561, 0, payloadENGINE_2_561) end payloadENGINE_7_563 = {0x79, 0xa2, 0x00, 0x18, 0x0e, 0x00, 0x00, 0x01} function onENGINE_7_563(bus, id, dlc, data) --- txCan(TCU_BUS, ENGINE_7_563, 0, payloadENGINE_7_563) - txCan(TCU_BUS, ENGINE_7_563, 0, data) + payloadENGINE_7_563[3] = data[3] + payloadENGINE_7_563[4] = data[4] + payloadENGINE_7_563[7] = data[7] + txCan(TCU_BUS, ENGINE_7_563, 0, payloadENGINE_7_563) +-- txCan(TCU_BUS, ENGINE_7_563, 0, data) end payloadENGINE_3_573 = {0x00, 0x0e, 0x0b, 0x0e, 0x01, 0x38, 0x00, 0x79} function onENGINE_3_573(bus, id, dlc, data) --- txCan(TCU_BUS, ENGINE_3_573, 0, payloadENGINE_3_573) - txCan(TCU_BUS, ENGINE_3_573, 0, data) + payloadENGINE_3_573[1] = data[1] + payloadENGINE_3_573[2] = data[2] + payloadENGINE_3_573[3] = data[3] + payloadENGINE_3_573[7] = data[7] + txCan(TCU_BUS, ENGINE_3_573, 0, payloadENGINE_3_573) + end canRxAdd(ECU_BUS, ENGINE_1_505, onENGINE_1_505) @@ -109,7 +118,7 @@ canRxAdd(ECU_BUS, ENGINE_3_573, onENGINE_3_573) -- last option: unconditional forward of all remaining messages canRxAddMask(ECU_BUS, 0, 0, onAnythingFromECU) -canRxAddMask(TCU_BUS, 0, 0, onAnythingFromTCU) +--canRxAddMask(TCU_BUS, 0, 0, onAnythingFromTCU) everySecondTimer = Timer.new()