This commit is contained in:
parent
585f2ebeea
commit
bd4fb37ae1
|
@ -1,11 +1,9 @@
|
||||||
-- sometimes we want to cut a CAN bus and install rusEFI into that cut
|
-- sometimes we want to cut a CAN bus and install rusEFI into that cut
|
||||||
-- https://en.wikipedia.org/wiki/Man-in-the-middle_attack
|
-- https://en.wikipedia.org/wiki/Man-in-the-middle_attack
|
||||||
|
|
||||||
|
|
||||||
-- this controls onCanRx rate as well!
|
-- this controls onCanRx rate as well!
|
||||||
setTickRate(300)
|
setTickRate(300)
|
||||||
|
|
||||||
|
|
||||||
ECU_BUS = 1
|
ECU_BUS = 1
|
||||||
-- really 'not ECU'
|
-- really 'not ECU'
|
||||||
TCU_BUS = 2
|
TCU_BUS = 2
|
||||||
|
@ -36,7 +34,35 @@ function arrayToString(arr)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
totalEcuMessages = 0
|
||||||
|
totalTcuMessages = 0
|
||||||
|
|
||||||
|
function printAndDrop(bus, id, dlc, data)
|
||||||
|
print('Dropping ' ..arrayToString(data))
|
||||||
|
end
|
||||||
|
|
||||||
|
function onAnythingFromECU(bus, id, dlc, data)
|
||||||
|
totalEcuMessages = totalEcuMessages + 1
|
||||||
|
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||||
|
end
|
||||||
|
|
||||||
|
function onAnythingFromTCU(bus, id, dlc, data)
|
||||||
|
totalTcuMessages = totalTcuMessages + 1
|
||||||
|
txCan(ECU_BUS, id, 0, data) -- relay non-ECU message to ECU
|
||||||
|
end
|
||||||
|
|
||||||
|
-- VAG Motor_1 just as example
|
||||||
|
-- canRxAdd(ECU_BUS, 0x280, printAndDrop)
|
||||||
|
|
||||||
|
-- last option: unconditional forward of all remaining messages
|
||||||
|
canRxAddMask(ECU_BUS, 0, 0, onAnythingFromECU)
|
||||||
|
canRxAddMask(TCU_BUS, 0, 0, onAnythingFromTCU)
|
||||||
|
|
||||||
|
everySecondTimer = Timer.new()
|
||||||
|
|
||||||
function onTick()
|
function onTick()
|
||||||
-- empty 'onTick' until we make 'onTick' method optional
|
if everySecondTimer:getElapsedSeconds() > 1 then
|
||||||
|
everySecondTimer:reset()
|
||||||
|
print("Total from ECU " .. totalEcuMessages .. " from TCU " .. totalTcuMessages)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue