43 lines
770 B
Plaintext
43 lines
770 B
Plaintext
-- 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
|