From 7c7252694647d5c5d05b0fab0848a325aeeb6f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Sun, 31 Aug 2025 15:08:45 +0300 Subject: [PATCH] Make tests pass --- Software/src/communication/can/comm_can.cpp | 22 +++++++++------------ test/emul/Preferences.h | 1 + 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Software/src/communication/can/comm_can.cpp b/Software/src/communication/can/comm_can.cpp index f12ae2b8..003e1988 100644 --- a/Software/src/communication/can/comm_can.cpp +++ b/Software/src/communication/can/comm_can.cpp @@ -92,7 +92,6 @@ bool init_CAN() { const uint32_t errorCode = ACAN_ESP32::can.begin(*settingsespcan); if (errorCode == 0) { native_can_initialized = true; -#ifdef DEBUG_LOG logging.println("Native Can ok"); logging.print("Bit Rate prescaler: "); logging.println(settingsespcan->mBitRatePrescaler); @@ -112,12 +111,9 @@ bool init_CAN() { logging.print("Sample point: "); logging.print(settingsespcan->samplePointFromBitStart()); logging.println("%"); -#endif // DEBUG_LOG } else { -#ifdef DEBUG_LOG logging.print("Error Native Can: 0x"); logging.println(errorCode, HEX); -#endif // DEBUG_LOG return false; } } @@ -233,9 +229,9 @@ void transmit_can_frame_to_interface(const CAN_frame* tx_frame, int interface) { } print_can_frame(*tx_frame, frameDirection(MSG_TX)); -#ifdef LOG_CAN_TO_SD - add_can_frame_to_buffer(*tx_frame, frameDirection(MSG_TX)); -#endif + if (datalayer.system.info.CAN_SD_logging_active) { + add_can_frame_to_buffer(*tx_frame, frameDirection(MSG_TX)); + } switch (interface) { case CAN_NATIVE: { @@ -398,13 +394,13 @@ void map_can_frame_to_variable(CAN_frame* rx_frame, CAN_Interface interface) { print_can_frame(*rx_frame, frameDirection(MSG_RX)); } -#ifdef LOG_CAN_TO_SD - if (interface != - CANFD_NATIVE) { //Avoid printing twice due to receive_frame_canfd_addon sending to both FD interfaces - //TODO: This check can be removed later when refactored to use inline functions for logging - add_can_frame_to_buffer(*rx_frame, frameDirection(MSG_RX)); + if (datalayer.system.info.CAN_SD_logging_active) { + if (interface != + CANFD_NATIVE) { //Avoid printing twice due to receive_frame_canfd_addon sending to both FD interfaces + //TODO: This check can be removed later when refactored to use inline functions for logging + add_can_frame_to_buffer(*rx_frame, frameDirection(MSG_RX)); + } } -#endif // Send the frame to all the receivers registered for this interface. auto receivers = can_receivers.equal_range(interface); diff --git a/test/emul/Preferences.h b/test/emul/Preferences.h index b1091def..fa2e6019 100644 --- a/test/emul/Preferences.h +++ b/test/emul/Preferences.h @@ -1,6 +1,7 @@ #ifndef PREFERENCES #define PREFERENCES +#include #include class Preferences {