From a2bf7616ae663ca92747e54f5b4f0d679b5f5621 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 21 Dec 2021 01:17:02 -0500 Subject: [PATCH] Second CAN #3687 --- firmware/controllers/can/can_rx.cpp | 10 ++++++---- firmware/controllers/lua/lua_can_rx.cpp | 2 +- firmware/controllers/lua/rusefi_lua.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp index 4b26f26aeb..f30b1934f1 100644 --- a/firmware/controllers/can/can_rx.cpp +++ b/firmware/controllers/can/can_rx.cpp @@ -61,7 +61,7 @@ bool acceptCanRx(int sid) { /** * this build-in CAN sniffer is very basic but that's our CAN sniffer */ -static void printPacket(const CANRxFrame &rx) { +static void printPacket(const size_t busIndex, const CANRxFrame &rx) { bool accept = acceptCanRx(CAN_SID(rx)); if (!accept) { return; @@ -70,7 +70,9 @@ static void printPacket(const CANRxFrame &rx) { // only print info if we're in can debug mode // internet people use both hex and decimal to discuss packed IDs, for usability it's better to print both right here - efiPrintf("CAN_rx %x(%d) %d: %02x %02x %02x %02x %02x %02x %02x %02x", CAN_SID(rx), + efiPrintf("CAN_rx bus=%d %x(%d) %d: %02x %02x %02x %02x %02x %02x %02x %02x", + busIndex, + CAN_SID(rx), CAN_SID(rx), rx.DLC, rx.data8[0], rx.data8[1], rx.data8[2], rx.data8[3], rx.data8[4], rx.data8[5], rx.data8[6], rx.data8[7]); @@ -160,7 +162,7 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) { void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) { if (engineConfiguration->verboseCan) { - printPacket(frame); + printPacket(busIndex, frame); } serviceCanSubscribers(frame, nowNt); @@ -172,7 +174,7 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick // todo: convert to CanListener or not? processCanRxImu(frame, nowNt); - processLuaCan(frame); + processLuaCan(busIndex, frame); #if EFI_CANBUS_SLAVE if (CAN_EID(frame) == engineConfiguration->verboseCanBaseAddress + CAN_SENSOR_1_OFFSET) { diff --git a/firmware/controllers/lua/lua_can_rx.cpp b/firmware/controllers/lua/lua_can_rx.cpp index 20c6e3bc5d..3bd0c3b843 100644 --- a/firmware/controllers/lua/lua_can_rx.cpp +++ b/firmware/controllers/lua/lua_can_rx.cpp @@ -28,7 +28,7 @@ chibios_rt::Mailbox freeBuffers; // CAN frame buffers that are waiting to be processed by the lua thread chibios_rt::Mailbox filledBuffers; -void processLuaCan(const CANRxFrame& frame) { +void processLuaCan(const size_t busIndex, const CANRxFrame& frame) { // Filter the frame if we aren't listening for it if (!shouldRxCanFrame(frame)) { return; diff --git a/firmware/controllers/lua/rusefi_lua.h b/firmware/controllers/lua/rusefi_lua.h index 344d138a1b..14b452519b 100644 --- a/firmware/controllers/lua/rusefi_lua.h +++ b/firmware/controllers/lua/rusefi_lua.h @@ -62,5 +62,5 @@ void addLuaCanRxFilter(int32_t eid); // Called from the Lua loop to process any pending CAN frames void doLuaCanRx(LuaHandle& ls); // Called from the CAN RX thread to queue a frame for Lua consumption -void processLuaCan(const CANRxFrame& frame); +void processLuaCan(const size_t busIndex, const CANRxFrame& frame); #endif // not EFI_CAN_SUPPORT