make lua CAN happy (#3416)

* lua can tx

* index

* make rx match
This commit is contained in:
Matthew Kennedy 2021-10-28 05:18:56 -07:00 committed by GitHub
parent 3cdfd9866e
commit 680518d13c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -78,7 +78,9 @@ static void handleCanFrame(LuaHandle& ls, CANRxFrame* frame) {
lua_newtable(ls);
for (size_t i = 0; i < dlc; i++) {
lua_pushinteger(ls, frame->data8[i]);
lua_rawseti(ls, -2, i);
// index is i+1 because Lua "arrays" (tables) are 1-indexed
lua_rawseti(ls, -2, i + 1);
}
// Perform the actual function call

View File

@ -125,7 +125,7 @@ static int lua_txCan(lua_State* l) {
while (true) {
lua_pushnumber(l, dlc + 1);
auto elementType = lua_gettable(l, 4);
auto val = lua_tointeger(l, -1);
auto val = lua_tonumber(l, -1);
lua_pop(l, 1);
if (elementType == LUA_TNIL) {