46 CanFrameData* frameBuffer;
51 chibios_rt::CriticalSectionLocker csl;
62 frameBuffer->BusIndex = busIndex;
63 frameBuffer->Frame = frame;
64 frameBuffer->Callback = filter->Callback;
68 chibios_rt::CriticalSectionLocker csl;
91 if (data->Callback == NO_CALLBACK) {
93 lua_getglobal(ls,
"onCanRx");
96 lua_rawgeti(ls, LUA_REGISTRYINDEX, data->Callback);
99 auto frameCanId = CAN_ID(data->Frame);
101 if (lua_isnil(ls, -1)) {
103 efiPrintf(
"LUA CAN rx missing function onCanRx ID=%ld", frameCanId);
108 auto dlc = data->Frame.DLC;
111 lua_pushinteger(ls, HUMAN_OFFSET + data->BusIndex);
112 lua_pushinteger(ls, frameCanId);
113 lua_pushinteger(ls, dlc);
117 lua_getglobal(ls,
"global_can_data");
122 for (
size_t i = 0; i < dlc; i++) {
123 lua_pushinteger(ls, data->Frame.data8[i]);
126 lua_rawseti(ls, -2, i + 1);
130 int status = lua_pcall(ls, 4, 0, 0);
134 auto errMsg = lua_tostring(ls, -1);
135 efiPrintf(
"LUA CAN RX error %s", errMsg);