From 2c78093e379bb18731bfdaecdcfd5af1c2b36df4 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 13 Jun 2023 18:50:41 -0400 Subject: [PATCH] i know how to drop a packet, but not how to modify a packet --- .../controllers/lua/examples/man-in-the-middle.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/firmware/controllers/lua/examples/man-in-the-middle.txt b/firmware/controllers/lua/examples/man-in-the-middle.txt index 8e3e4083b1..31d705b6df 100644 --- a/firmware/controllers/lua/examples/man-in-the-middle.txt +++ b/firmware/controllers/lua/examples/man-in-the-middle.txt @@ -51,8 +51,18 @@ function onAnythingFromTCU(bus, id, dlc, data) txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU end +MOTOR_1 = 0x282 + +function interceptAndReplaceContent(bus, id, dlc, data) + rpm = 200 + data[3] = rpm + -- send adjusted packet into the other bus + txCan(TCU_BUS, MOTOR_1, 0, data) +end + -- VAG Motor_1 just as example -- canRxAdd(ECU_BUS, 0x280, printAndDrop) +-- canRxAdd(ECU_BUS, MOTOR_1, interceptAndReplaceContent) -- last option: unconditional forward of all remaining messages canRxAddMask(ECU_BUS, 0, 0, onAnythingFromECU)