diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index 34f7db5764..bc5530d8fb 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -32,8 +32,9 @@ Release template (copy/paste this for new release): - VVT minimum RPM setting #4545 - Flexible ignition adder/trim tables #4586 - Enforce board configuration overrides more strictly #4614 - - Startup Frame should scan for available hardware #4633 + - rusEFI console Startup Frame should scan for available hardware #4633 - Don't fire the engine without the ignition on (avoids USB keeping engine alive after ignition off) #4474 + - Lua: function to access VIN setting #3967 ### Fixed - Fuel Priming reset fix #4627 diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index bb2fe3bb57..345ed5c3f5 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -28,8 +28,12 @@ using namespace luaaa; static int lua_vin(lua_State* l) { auto zeroBasedCharIndex = luaL_checkinteger(l, 1); - char value = engineConfiguration->vinNumber[zeroBasedCharIndex]; - lua_pushnumber(l, value); + if (zeroBasedCharIndex < 0 || zeroBasedCharIndex > VIN_NUMBER_SIZE) { + lua_pushnil(l); + } else { + char value = engineConfiguration->vinNumber[zeroBasedCharIndex]; + lua_pushnumber(l, value); + } return 1; }