diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index 235e71b53d..a6e1e7e666 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -29,7 +29,7 @@ #include "console_io.h" #include "svnversion.h" -static LoggingWithStorage logger; +static LoggingWithStorage logger("console"); static char fatalErrorMessage[200]; diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 571fa79d52..68f0567eea 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -55,6 +55,8 @@ #include "settings.h" #include "rusefi_outputs.h" +extern bool_t main_loop_started; + #if EFI_PROD_CODE || defined(__DOXYGEN__) // todo: move this logic to algo folder! #include "rtc_helper.h" @@ -87,7 +89,7 @@ static void setWarningEnabled(int value) { } #if EFI_FILE_LOGGING || defined(__DOXYGEN__) -static LoggingWithStorage fileLogger; +static LoggingWithStorage fileLogger("file logger"); #endif /* EFI_FILE_LOGGING */ static int logFileLineIndex = 0; @@ -179,7 +181,6 @@ void printSensors(Logging *log, bool fileFormat, Engine *engine) { reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2); reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(engineConfiguration), 2); - reportSensorF(log, fileFormat, "TP", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2); if (engineConfiguration->hasCltSensor) { @@ -196,6 +197,8 @@ EXTERN_ENGINE ; void writeLogLine(void) { + if (!main_loop_started) + return; #if EFI_FILE_LOGGING || defined(__DOXYGEN__) resetLogging(&fileLogger); printSensors(&fileLogger, true, engine); @@ -353,7 +356,6 @@ void updateDevConsoleState(Engine *engine) { chThdSleepMilliseconds(200); #endif - printState(engine); #if EFI_WAVE_ANALYZER @@ -607,10 +609,6 @@ void initStatusLoop(Engine *engine) { addConsoleAction("status", printStatus); #endif /* EFI_PROD_CODE */ - -#if EFI_FILE_LOGGING - initLogging(&fileLogger, "file logger"); -#endif /* EFI_FILE_LOGGING */ } void startStatusThreads(Engine *engine) { diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 8e0e07d5c9..162ed2817d 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -20,7 +20,7 @@ static LoggingWithStorage logger; #define WARNING_PREFIX "WARNING: " extern int warningEnabled; -extern int main_loop_started; +extern bool_t main_loop_started; const char *dbg_panic_file; int dbg_panic_line; diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index d3e3ddde69..e83770c684 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -52,7 +52,7 @@ static bool fs_ready = false; */ static FATFS MMC_FS; -static LoggingWithStorage logger; +static LoggingWithStorage logger("mmcCard"); // print FAT error function static void printError(const char *str, FRESULT f_error) { @@ -251,7 +251,6 @@ bool isSdCardAlive(void) { } void initMmcCard(void) { - initLogging(&logger, "mmcCard"); addConsoleAction("sdstat", sdStatistics); if (!boardConfiguration->isSdCardEnabled) { return; diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 2246ca6988..2b82ae95c5 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -119,7 +119,7 @@ static LoggingWithStorage sharedLogger; -int main_loop_started = FALSE; +bool_t main_loop_started = false; static MemoryStream firmwareErrorMessageStream; static char panicMessage[200]; @@ -216,8 +216,6 @@ void scheduleReset(void) { unlockAnyContext(); } -extern int main_loop_started; - void chDbgStackOverflowPanic(Thread *otp) { strcpy(panicMessage, "stack overflow: "); #ifdef CH_USE_REGISTRY diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index edf385185a..fa55c169e7 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -163,7 +163,6 @@ void appendPrintf(Logging *logging, const char *fmt, ...) { } void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) { - print("Init logging %s\r\n", name); logging->name = name; logging->buffer = buffer; logging->bufferSize = bufferSize; @@ -390,6 +389,10 @@ void initIntermediateLoggingBuffer(void) { #endif /* ! EFI_UNIT_TEST */ +// todo: eliminate this constructor LoggingWithStorage::LoggingWithStorage() { - +} + +LoggingWithStorage::LoggingWithStorage(const char *name) { + initLogging(this, name); } diff --git a/firmware/util/datalogging.h b/firmware/util/datalogging.h index 52b4e40582..187845175b 100644 --- a/firmware/util/datalogging.h +++ b/firmware/util/datalogging.h @@ -38,6 +38,7 @@ public: class LoggingWithStorage : public Logging { public: LoggingWithStorage(); + LoggingWithStorage(const char *name); char DEFAULT_BUFFER[200]; };