From 5d846b64e44666ee2440d5e0ced534ac7bbea79f Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 22 Feb 2022 22:20:03 -0500 Subject: [PATCH] N73 --- firmware/config/engines/bmw_n73.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/firmware/config/engines/bmw_n73.cpp b/firmware/config/engines/bmw_n73.cpp index 785f94dff3..4c24f26255 100644 --- a/firmware/config/engines/bmw_n73.cpp +++ b/firmware/config/engines/bmw_n73.cpp @@ -131,6 +131,32 @@ function printDebug(msg) print(msg) end +hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" } + +function decimalToHex(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 print_array(arr) + local str = "" + local index = 1 + while arr[index] ~= nil do + str = str.." "..decimalToHex(arr[index]) + index = index + 1 + end + return str +end + function onCanRx(bus, id, dlc, data) id = id % 2048 -- local output = string.format("%x", id)