Mark is asking for VIN number field #3967

This commit is contained in:
Andrey 2022-10-04 21:12:51 -04:00
parent bb27329c89
commit 83afa58baf
3 changed files with 32 additions and 0 deletions

View File

@ -26,6 +26,13 @@ using namespace luaaa;
#include "electronic_throttle_impl.h"
#endif
static int lua_vin(lua_State* l) {
auto zeroBasedCharIndex = luaL_checkinteger(l, 1);
char value = engineConfiguration->vinNumber[zeroBasedCharIndex];
lua_pushnumber(l, value);
return 1;
}
static int lua_readpin(lua_State* l) {
auto msg = luaL_checkstring(l, 1);
#if EFI_PROD_CODE
@ -585,6 +592,7 @@ void configureRusefiLuaHooks(lua_State* l) {
configureRusefiLuaUtilHooks(l);
lua_register(l, "readPin", lua_readpin);
lua_register(l, "vin", lua_vin);
lua_register(l, "getAuxAnalog", lua_getAuxAnalog);
lua_register(l, "getSensorByIndex", lua_getSensorByIndex);
lua_register(l, "getSensor", lua_getSensorByName);

View File

@ -0,0 +1,23 @@
/*
* test_lua_vin.cpp
*
*/
#include "pch.h"
#include "rusefi_lua.h"
#include "lua_lib.h"
TEST(LuaVin, Test) {
EngineTestHelper eth(TEST_CRANK_ENGINE);
strcpy(engineConfiguration->vinNumber, "GM123");
const char* realdata = TWO_BYTES_MSB R"(
function testFunc()
return vin(0)
end)";
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 0x47);
}

View File

@ -41,6 +41,7 @@ TESTS_SRC_CPP = \
tests/lua/test_lua_hooks.cpp \
tests/lua/test_lua_Leiderman_Khlystov.cpp \
tests/lua/test_can_filter.cpp \
tests/lua/test_lua_vin.cpp \
tests/sensor/test_cj125.cpp \
tests/test_change_engine_type.cpp \
tests/util/test_scaled_channel.cpp \