This commit is contained in:
parent
1c01d5608f
commit
083211c233
|
@ -87,7 +87,7 @@ TCU_SERVICE = 0x598
|
|||
TCU_INPA_RESPONSE = 0x6f1
|
||||
|
||||
ECU_BUS = 1
|
||||
GEAR_BUS = 2
|
||||
TCU_BUS = 2
|
||||
|
||||
canRxAdd(E90_TORQUE_1)
|
||||
canRxAdd(E90_TORQUE_2)
|
||||
|
@ -116,7 +116,7 @@ canRxAdd(TCU_INPA_RESPONSE)
|
|||
|
||||
|
||||
function relayToTcu(id, data)
|
||||
txCan(GEAR_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||
txCan(TCU_BUS, id, 0, data) -- relay non-TCU message to TCU
|
||||
end
|
||||
|
||||
function relayToEcu(id, data)
|
||||
|
@ -129,7 +129,7 @@ end
|
|||
|
||||
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
|
||||
|
||||
function decimalToHex(num)
|
||||
function toHexString(num)
|
||||
if num == 0 then
|
||||
return '0'
|
||||
end
|
||||
|
@ -143,11 +143,11 @@ function decimalToHex(num)
|
|||
return result
|
||||
end
|
||||
|
||||
function print_array(arr)
|
||||
function arrayToString(arr)
|
||||
local str = ""
|
||||
local index = 1
|
||||
while arr[index] ~= nil do
|
||||
str = str.." "..decimalToHex(arr[index])
|
||||
str = str.." "..toHexString(arr[index])
|
||||
index = index + 1
|
||||
end
|
||||
return str
|
||||
|
@ -174,8 +174,8 @@ function onCanRx(bus, id, dlc, data)
|
|||
output[2] = counterE90_RPM_THROTTLE
|
||||
output[1] = bmwChecksum(E90_RPM_THROTTLE, output, 2, 7)
|
||||
|
||||
-- print('original ' ..print_array(data))
|
||||
-- print('repacked ' ..print_array(output))
|
||||
-- print('original ' ..arrayToString(data))
|
||||
-- print('repacked ' ..arrayToString(output))
|
||||
|
||||
relayToTcu(id, output)
|
||||
elseif id == E90_DSC_TORQUE_DEMAND then
|
||||
|
@ -266,6 +266,7 @@ function onCanRx(bus, id, dlc, data)
|
|||
end
|
||||
|
||||
function onTick()
|
||||
-- empty 'onTick' until we make 'onTick' method optional
|
||||
end
|
||||
|
||||
)", efi::size(config->luaScript));
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
-- sometimes we want to cut a CAN bus and install rusEFI into that cut
|
||||
-- https://en.wikipedia.org/wiki/Man-in-the-middle_attack
|
||||
|
||||
|
||||
-- this controls onCanRx rate as well!
|
||||
setTickRate(300)
|
||||
|
||||
|
||||
ECU_BUS = 1
|
||||
-- really 'not ECU'
|
||||
TCU_BUS = 2
|
||||
|
||||
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
|
||||
|
||||
function toHexString(num)
|
||||
if num == 0 then
|
||||
return '0'
|
||||
end
|
||||
|
||||
local result = ""
|
||||
while num > 0 do
|
||||
local n = num % 16
|
||||
result = hexstr[n + 1] ..result
|
||||
num = math.floor(num / 16)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function arrayToString(arr)
|
||||
local str = ""
|
||||
local index = 1
|
||||
while arr[index] ~= nil do
|
||||
str = str.." "..toHexString(arr[index])
|
||||
index = index + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
function onTick()
|
||||
-- empty 'onTick' until we make 'onTick' method optional
|
||||
end
|
Loading…
Reference in New Issue