mirror of https://github.com/rusefi/rusefi.git
DBW
This commit is contained in:
parent
b8b3eb20e7
commit
74cdbc35b5
|
@ -18,6 +18,37 @@ function setTwoBytesMsb(data, offset, value)
|
|||
data[offset + 2] = value & 0xff
|
||||
end
|
||||
|
||||
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 printPacket(bus, id, dlc, data)
|
||||
print('Received ' ..arrayToString(data))
|
||||
end
|
||||
|
||||
canRxAddMask(1, 0, 0, printPacket)
|
||||
protocolPacket = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
||||
function onTick()
|
||||
|
|
Loading…
Reference in New Issue