diff --git a/firmware/controllers/lua/lua_lib.h b/firmware/controllers/lua/lua_lib.h index 3f00d47d38..f26203e3eb 100644 --- a/firmware/controllers/lua/lua_lib.h +++ b/firmware/controllers/lua/lua_lib.h @@ -21,6 +21,22 @@ end \ #define PRINT_ARRAY "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 \ +\ +\ +\ " // LSB (Least Significant Byte comes first) "Intel" diff --git a/unit_tests/tests/lua/test_lua_vag.cpp b/unit_tests/tests/lua/test_lua_vag.cpp index 15c49598a5..fc5482172c 100644 --- a/unit_tests/tests/lua/test_lua_vag.cpp +++ b/unit_tests/tests/lua/test_lua_vag.cpp @@ -23,19 +23,6 @@ TEST(LuaVag, Checksum) { TEST(LuaVag, packMotor1) { const char* realdata = PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES R"( -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 = ""