37 CanFrameData* frameBuffer;
42 chibios_rt::CriticalSectionLocker csl;
53 frameBuffer->BusIndex = busIndex;
54 frameBuffer->Frame = frame;
55 frameBuffer->Callback = filter->Callback;
59 chibios_rt::CriticalSectionLocker csl;
82 if (data->Callback == NO_CALLBACK) {
84 lua_getglobal(ls,
"onCanRx");
87 lua_rawgeti(ls, LUA_REGISTRYINDEX, data->Callback);
90 auto frameCanId = CAN_ID(data->Frame);
92 if (lua_isnil(ls, -1)) {
94 efiPrintf(
"LUA CAN rx missing function onCanRx ID=%ld", frameCanId);
99 auto dlc = data->Frame.DLC;
102 lua_pushinteger(ls, HUMAN_OFFSET + data->BusIndex);
103 lua_pushinteger(ls, frameCanId);
104 lua_pushinteger(ls, dlc);
108 lua_getglobal(ls,
"global_can_data");
113 for (
size_t i = 0; i < dlc; i++) {
114 lua_pushinteger(ls, data->Frame.data8[i]);
117 lua_rawseti(ls, -2, i + 1);
121 int status = lua_pcall(ls, 4, 0, 0);
125 auto errMsg = lua_tostring(ls, -1);
126 efiPrintf(
"LUA CAN RX error %s", errMsg);