diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index cd4f311720..1850ba2ade 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -102,11 +102,11 @@ static void printWarning(const char *fmt, va_list ap) { resetLogging(&logger); // todo: is 'reset' really needed here? appendMsgPrefix(&logger); - append(&logger, WARNING_PREFIX); + logger.append(WARNING_PREFIX); printToStream(&warningStream, fmt, ap); - append(&logger, warningBuffer); + logger.append(warningBuffer); append(&logger, DELIMETER); scheduleLogging(&logger); } diff --git a/firmware/controllers/math/pid.h b/firmware/controllers/math/pid.h index e449af2492..af7c04ad27 100644 --- a/firmware/controllers/math/pid.h +++ b/firmware/controllers/math/pid.h @@ -8,9 +8,8 @@ #ifndef PID_H_ #define PID_H_ -#include "global.h" +#include "main.h" #include "engine_configuration_generated_structures.h" -#include "datalogging.h" #if EFI_PROD_CODE || EFI_SIMULATOR #include "tunerstudio_configuration.h" diff --git a/firmware/main.h b/firmware/main.h index 6a9f63e37b..f4b86a29b4 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -29,6 +29,7 @@ extern "C" #ifdef __cplusplus #include "cli_registry.h" #include "datalogging.h" +#include "loggingcentral.h" #include "eficonsole.h" #endif diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index dce9361588..e4e9703471 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -39,7 +39,6 @@ #include "memstreams.h" #include "console_io.h" #include "rfiutil.h" -#include "loggingcentral.h" static MemoryStream intermediateLoggingBuffer; static uint8_t intermediateLoggingBufferData[INTERMEDIATE_LOGGING_BUFFER_SIZE] CCM_OPTIONAL; @@ -65,18 +64,23 @@ static ALWAYS_INLINE bool validateBuffer(Logging *logging, const char *text, uin return false; } -void append(Logging *logging, const char *text) { +void Logging::append(const char *text) { efiAssertVoid(CUSTOM_ERR_6602, text != NULL, "append NULL"); uint32_t extraLen = efiStrlen(text); - bool isCapacityProblem = validateBuffer(logging, text, extraLen); + bool isCapacityProblem = validateBuffer(this, text, extraLen); if (isCapacityProblem) { return; } - strcpy(logging->linePointer, text); + strcpy(linePointer, text); /** * And now we are pointing at the zero char at the end of the buffer again */ - logging->linePointer += extraLen; + linePointer += extraLen; +} + +// todo: inline +void append(Logging *logging, const char *text) { + logging->append(text); } /** diff --git a/firmware/util/datalogging.h b/firmware/util/datalogging.h index d569ebfc39..11fd03153e 100644 --- a/firmware/util/datalogging.h +++ b/firmware/util/datalogging.h @@ -64,8 +64,6 @@ void resetLogging(Logging *logging); void appendMsgPrefix(Logging *logging); void appendMsgPostfix(Logging *logging); -void scheduleMsg(Logging *logging, const char *fmt, ...); - #ifdef __cplusplus extern "C" diff --git a/firmware/util/loggingcentral.h b/firmware/util/loggingcentral.h index a789292e3d..b8b8723cb5 100644 --- a/firmware/util/loggingcentral.h +++ b/firmware/util/loggingcentral.h @@ -9,5 +9,6 @@ void initLoggingCentral(void); char * swapOutputBuffers(int *actualOutputBufferSize); +void scheduleMsg(Logging *logging, const char *fmt, ...); #endif /* UTIL_LOGGINGCENTRAL_H_ */ diff --git a/simulator/main.h b/simulator/main.h index f7de749f0c..8fe70eb5af 100644 --- a/simulator/main.h +++ b/simulator/main.h @@ -3,6 +3,7 @@ #ifdef __cplusplus #include "datalogging.h" +#include "loggingcentral.h" #include "eficonsole.h" #include "cli_registry.h" #include "chprintf.h" diff --git a/unit_tests/main.h b/unit_tests/main.h index b508b2f8a0..083775967c 100644 --- a/unit_tests/main.h +++ b/unit_tests/main.h @@ -24,6 +24,7 @@ #ifdef __cplusplus #include "datalogging.h" +#include "loggingcentral.h" extern "C" {