diff --git a/firmware/console/console.mk b/firmware/console/console.mk index 97ff010e9b..3b9184efcd 100644 --- a/firmware/console/console.mk +++ b/firmware/console/console.mk @@ -2,4 +2,5 @@ CONSOLESRC = $(PROJECT_DIR)/console/console_io.c CONSOLE_SRC_CPP = $(PROJECT_DIR)/console/status_loop.cpp \ - $(PROJECT_DIR)/controllers/error_handling.cpp + $(PROJECT_DIR)/console/eficonsole.cpp + diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index 8ca2cf86ac..a5997074ab 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -1,5 +1,5 @@ /** - * @file eficonsole.c + * @file eficonsole.cpp * @brief Console package entry point code * * @@ -29,7 +29,7 @@ #include "console_io.h" #include "svnversion.h" -static Logging logger; +static LoggingWithStorage logger; static char fatalErrorMessage[200]; diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 7a6a569228..6acc53e703 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -83,7 +83,7 @@ static void setWarningEnabled(int value) { } #if EFI_FILE_LOGGING || defined(__DOXYGEN__) -static Logging fileLogger; +static LoggingWithStorage fileLogger; #endif /* EFI_FILE_LOGGING */ static int logFileLineIndex = 0; @@ -232,7 +232,7 @@ static char LOGGING_BUFFER[700]; volatile int needToReportStatus = FALSE; static int prevCkpEventCounter = -1; -static Logging logger2; +static LoggingWithStorage logger2; static void printStatus(void) { needToReportStatus = TRUE; diff --git a/firmware/console/tunerstudio/tunerstudio.cpp b/firmware/console/tunerstudio/tunerstudio.cpp index 07c02ec57b..43b82c2255 100644 --- a/firmware/console/tunerstudio/tunerstudio.cpp +++ b/firmware/console/tunerstudio/tunerstudio.cpp @@ -72,7 +72,7 @@ BaseChannel * getTsSerialDevice(void) { #endif } -static Logging logger; +static LoggingWithStorage logger; extern persistent_config_s configWorkingCopy; extern persistent_config_container_s persistentState; diff --git a/firmware/console_util/rfiutil.c b/firmware/console_util/rfiutil.c index 4744b6ad25..0c676f7cb5 100644 --- a/firmware/console_util/rfiutil.c +++ b/firmware/console_util/rfiutil.c @@ -93,22 +93,3 @@ void chVTSetAny(virtual_timer_t *vtp, systime_t time, vtfunc_t vtfunc, void *par ; } } - -/** - * @brief This function knows how to print a histogram_s summary - */ -void printHistogram(Logging *logging, histogram_s *histogram) { -#if EFI_HISTOGRAMS - int report[5]; - int len = hsReport(histogram, report); - - resetLogging(logging); - appendMsgPrefix(logging); - appendPrintf(logging, "histogram %s *", histogram->name); - for (int i = 0; i < len; i++) - appendPrintf(logging, "%d ", report[i]); - appendPrintf(logging, "*"); - appendMsgPostfix(logging); - scheduleLogging(logging); -#endif /* EFI_HISTOGRAMS */ -} diff --git a/firmware/console_util/rfiutil.h b/firmware/console_util/rfiutil.h index 2fe6344dc7..b6676ec32d 100644 --- a/firmware/console_util/rfiutil.h +++ b/firmware/console_util/rfiutil.h @@ -11,7 +11,6 @@ #include "global.h" #include "histogram.h" -#include "datalogging.h" #ifdef __cplusplus extern "C" @@ -22,10 +21,10 @@ char hexC(int v); int isIsrContext(void); int isLocked(void); void chVTSetAny(virtual_timer_t *vtp, systime_t time, vtfunc_t vtfunc, void *par); -void printHistogram(Logging *logging, histogram_s *histogram); #ifdef __cplusplus } +void printHistogram(Logging *logging, histogram_s *histogram); #endif /* __cplusplus */ #endif /* RFIUTIL_H_ */ diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 789f117ecd..ae312249c5 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -21,7 +21,7 @@ #define isRunningBenchTest() true #endif -static Logging logger; +static LoggingWithStorage logger; extern engine_pins_s enginePins; diff --git a/firmware/controllers/algo/signal_executor.cpp b/firmware/controllers/algo/signal_executor.cpp index ae4124e714..f2abb177c7 100644 --- a/firmware/controllers/algo/signal_executor.cpp +++ b/firmware/controllers/algo/signal_executor.cpp @@ -41,7 +41,7 @@ extern WaveChart waveChart; #include "efiGpio.h" -static Logging logger; +static LoggingWithStorage logger; extern engine_pins_s enginePins; diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index ad0beebab2..f66fc25f7a 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -58,7 +58,7 @@ EXTERN_ENGINE; #if EFI_PROD_CODE || EFI_SIMULATOR -static Logging logger; +static LoggingWithStorage logger; float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) { efiAssert(engine!=NULL, "getLEValue", NAN); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 2d889c9871..a075ee1b2e 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -73,7 +73,7 @@ board_configuration_s *boardConfiguration = &persistentState.persistentConfigura static VirtualTimer everyMsTimer; -static Logging logger; +static LoggingWithStorage logger; #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) static engine_configuration2_s ec2 CCM_OPTIONAL; diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 63a7a03e5a..8e0e07d5c9 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -15,7 +15,7 @@ #endif /* EFI_HD44780_LCD */ static time_t timeOfPreviousWarning = -10; -static Logging logger; +static LoggingWithStorage logger; #define WARNING_PREFIX "WARNING: " diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index 30c0ec0a3d..0622a95413 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -26,7 +26,7 @@ static bool needToWriteConfiguration = false; EXTERN_ENGINE; -static Logging logger; +static LoggingWithStorage logger; extern persistent_config_container_s persistentState; diff --git a/firmware/controllers/idle_thread.cpp b/firmware/controllers/idle_thread.cpp index 8b12d87606..f3e32c1016 100644 --- a/firmware/controllers/idle_thread.cpp +++ b/firmware/controllers/idle_thread.cpp @@ -36,7 +36,7 @@ static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE); -static Logging logger; +static LoggingWithStorage logger; EXTERN_ENGINE ; diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index d346001ad7..476289c2f2 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -34,7 +34,7 @@ #include "pin_repository.h" #include "efiGpio.h" -static Logging logger; +static LoggingWithStorage logger; EXTERN_ENGINE ; diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index b4c300efaf..84262c7f9a 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -39,7 +39,7 @@ #define FAST_MAP_CHART_SKIP_FACTOR 16 -static Logging logger; +static LoggingWithStorage logger; /** * Running counter of measurements per revolution diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 637ff6343a..1a2e3e9f3e 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -19,7 +19,7 @@ typedef ArrayList OutputSignalList; void findTriggerPosition( - event_trigger_position_s *position, float angleOffset DECLARE_ENGINE_PARAMETER_S); + event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_S); int isInjectionEnabled(engine_configuration_s *engineConfiguration); diff --git a/firmware/controllers/system/signal_executor_sleep.c b/firmware/controllers/system/signal_executor_sleep.c index ecb696bfb1..1f0a320498 100644 --- a/firmware/controllers/system/signal_executor_sleep.c +++ b/firmware/controllers/system/signal_executor_sleep.c @@ -24,7 +24,6 @@ #include "main.h" #include "scheduler.h" -#include "datalogging.h" #if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__) diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 7ff2d8246c..fd13d1f362 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -78,7 +78,7 @@ static IgnitionEvent *iHead = NULL; static cyclic_buffer ignitionErrorDetection; -static Logging logger; +static LoggingWithStorage logger; // todo: figure out if this even helps? //#if defined __GNUC__ diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 5437ffa89e..583d3930c8 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -37,7 +37,7 @@ extern WaveChart waveChart; EXTERN_ENGINE; -static Logging logger; +static LoggingWithStorage logger; RpmCalculator::RpmCalculator() { #if !EFI_PROD_CODE diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 2520d81036..26cd76c87d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -38,7 +38,7 @@ static volatile uint64_t previousShaftEventTimeNt = (efitimems_t) -10 * US2NT(US TriggerCentral triggerCentral; -static Logging logger; +static LoggingWithStorage logger; uint64_t getCrankEventCounter() { return triggerCentral.triggerState.getTotalEventCounter(); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 5a89452915..b56663664f 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -51,7 +51,7 @@ float actualSynchGap; #endif /* ! EFI_PROD_CODE */ #if (EFI_PROD_CODE || EFI_SIMULATOR) -static Logging logger; +static LoggingWithStorage logger; #endif /** diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index 6f201bbfac..3879ae4a3b 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -68,7 +68,7 @@ PwmConfig triggerSignal(swtchTms, sr); static int stopEmulationAtIndex = DO_NOT_STOP; static bool isEmulating = true; -static Logging logger; +static LoggingWithStorage logger; static LocalVersionHolder localVersion; EXTERN_ENGINE; diff --git a/firmware/development/hw_layer/poten.cpp b/firmware/development/hw_layer/poten.cpp index ffdf918b5e..35b4d20e63 100644 --- a/firmware/development/hw_layer/poten.cpp +++ b/firmware/development/hw_layer/poten.cpp @@ -40,7 +40,7 @@ /* Low speed SPI configuration (281.250kHz, CPHA=0, CPOL=0, MSb first).*/ #define SPI_POT_CONFIG SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_DFF -static Logging logger; +static LoggingWithStorage logger; #if EFI_POTENTIOMETER || defined(__DOXYGEN__) Mcp42010Driver config[DIGIPOT_COUNT]; diff --git a/firmware/development/rfi_perftest.cpp b/firmware/development/rfi_perftest.cpp index 069b84d57c..53e002cf42 100644 --- a/firmware/development/rfi_perftest.cpp +++ b/firmware/development/rfi_perftest.cpp @@ -20,7 +20,7 @@ #if EFI_PERF_METRICS || defined(__DOXYGEN__) -static Logging logger; +static LoggingWithStorage logger; static void testSystemCalls(const int count) { time_t start, time; diff --git a/firmware/development/wave_analyzer.cpp b/firmware/development/wave_analyzer.cpp index 34d01464e1..0ab060f4c8 100644 --- a/firmware/development/wave_analyzer.cpp +++ b/firmware/development/wave_analyzer.cpp @@ -45,7 +45,7 @@ static int waveReaderCount = 0; static WaveReader readers[MAX_ICU_COUNT]; static THD_WORKING_AREA(waThreadStack, UTILITY_THREAD_STACK_SIZE); -static Logging logger; +static LoggingWithStorage logger; static void ensureInitialized(WaveReader *reader) { efiAssertVoid(reader->hw.started, "wave analyzer NOT INITIALIZED"); diff --git a/firmware/development/wave_chart.cpp b/firmware/development/wave_chart.cpp index 2e83554984..948fc54026 100644 --- a/firmware/development/wave_chart.cpp +++ b/firmware/development/wave_chart.cpp @@ -62,7 +62,7 @@ int waveChartUsedSize; static Logging debugLogging; #endif /* DEBUG_WAVE */ -static Logging logger; +static LoggingWithStorage logger; void WaveChart::resetWaveChart() { #if DEBUG_WAVE diff --git a/firmware/hw_layer/HIP9011.cpp b/firmware/hw_layer/HIP9011.cpp index 827a178656..e5c096c522 100644 --- a/firmware/hw_layer/HIP9011.cpp +++ b/firmware/hw_layer/HIP9011.cpp @@ -61,7 +61,7 @@ static bool_t isSendingSpiCommand = false; static scheduling_s startTimer[2]; static scheduling_s endTimer[2]; -static Logging logger; +static LoggingWithStorage logger; // SPI_CR1_BR_1 // 5MHz // SPI_CR1_CPHA Clock Phase diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index efc0f505cf..21b7f708ba 100644 --- a/firmware/hw_layer/can_hw.cpp +++ b/firmware/hw_layer/can_hw.cpp @@ -30,7 +30,7 @@ EXTERN_ENGINE static int canReadCounter = 0; static int can_write_ok = 0; static int can_write_not_ok = 0; -static Logging logger; +static LoggingWithStorage logger; static THD_WORKING_AREA(canTreadStack, UTILITY_THREAD_STACK_SIZE); /* diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 150ce74ef0..09635e5ed4 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -261,7 +261,7 @@ void initHardware(Logging *l, Engine *engine) { #if EFI_HD44780_LCD // initI2Cmodule(); - lcd_HD44780_init(); + lcd_HD44780_init(sharedLogger); if (hasFirmwareError()) return; diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp index fc0825b1ea..fc33fb594c 100644 --- a/firmware/hw_layer/io_pins.cpp +++ b/firmware/hw_layer/io_pins.cpp @@ -23,7 +23,7 @@ extern board_configuration_s *boardConfiguration; -static Logging logger; +static LoggingWithStorage logger; static OutputPin sdCsPin; diff --git a/firmware/hw_layer/lcd/lcd_HD44780.cpp b/firmware/hw_layer/lcd/lcd_HD44780.cpp index e4692b999e..682425f48d 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.cpp +++ b/firmware/hw_layer/lcd/lcd_HD44780.cpp @@ -20,7 +20,7 @@ extern engine_configuration_s *engineConfiguration; extern board_configuration_s *boardConfiguration; -static Logging logger; +static Logging *logger; enum { LCD_HD44780_DISPLAY_CLEAR = 0x01, @@ -166,16 +166,16 @@ void lcd_HD44780_print_string(const char* string) { } //getHwPin(boardConfiguration->HD44780_db7) static void lcdInfo(void) { - scheduleMsg(&logger, "HD44780 RS=%s E=%s", hwPortname(boardConfiguration->HD44780_rs), + scheduleMsg(logger, "HD44780 RS=%s E=%s", hwPortname(boardConfiguration->HD44780_rs), hwPortname(boardConfiguration->HD44780_e)); - scheduleMsg(&logger, "HD44780 D4=%s D5=%s", hwPortname(boardConfiguration->HD44780_db4), + scheduleMsg(logger, "HD44780 D4=%s D5=%s", hwPortname(boardConfiguration->HD44780_db4), hwPortname(boardConfiguration->HD44780_db5)); - scheduleMsg(&logger, "HD44780 D6=%s D7=%s", hwPortname(boardConfiguration->HD44780_db6), + scheduleMsg(logger, "HD44780 D6=%s D7=%s", hwPortname(boardConfiguration->HD44780_db6), hwPortname(boardConfiguration->HD44780_db7)); } -void lcd_HD44780_init(void) { - initLogging(&logger, "HD44780 driver"); +void lcd_HD44780_init(Logging *sharedLogger) { + logger = sharedLogger; addConsoleAction("lcdinfo", lcdInfo); @@ -184,7 +184,7 @@ void lcd_HD44780_init(void) { return; } - printMsg(&logger, "lcd_HD44780_init %d", engineConfiguration->displayMode); + printMsg(logger, "lcd_HD44780_init %d", engineConfiguration->displayMode); if (engineConfiguration->displayMode == DM_HD44780) { // initialize hardware lines @@ -228,7 +228,7 @@ void lcd_HD44780_init(void) { lcd_HD44780_write_command(LCD_HD44780_DISPLAY_ON); lcd_HD44780_set_position(0, 0); - printMsg(&logger, "lcd_HD44780_init() done"); + printMsg(logger, "lcd_HD44780_init() done"); } void lcdShowFatalMessage(char *message) { diff --git a/firmware/hw_layer/lcd/lcd_HD44780.h b/firmware/hw_layer/lcd/lcd_HD44780.h index dae3feacf1..0e9b2c0a10 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.h +++ b/firmware/hw_layer/lcd/lcd_HD44780.h @@ -13,7 +13,7 @@ extern "C" { #endif /* __cplusplus */ -void lcd_HD44780_init(void); +void lcd_HD44780_init(Logging *sharedLogger); void lcd_HD44780_set_position(uint8_t row, uint8_t column); void lcd_HD44780_print_char(char data); void lcd_HD44780_print_string(const char *string); diff --git a/firmware/hw_layer/max31855.cpp b/firmware/hw_layer/max31855.cpp index f3edc7ce74..806b8040fd 100644 --- a/firmware/hw_layer/max31855.cpp +++ b/firmware/hw_layer/max31855.cpp @@ -29,7 +29,7 @@ static SPIDriver *driver; -static Logging logger; +static LoggingWithStorage logger; static SPIConfig spiConfig[MAX31855_CS_COUNT]; diff --git a/firmware/hw_layer/mmc_card.cpp b/firmware/hw_layer/mmc_card.cpp index 3bc2b51073..d3e3ddde69 100644 --- a/firmware/hw_layer/mmc_card.cpp +++ b/firmware/hw_layer/mmc_card.cpp @@ -1,5 +1,5 @@ /** - * @file mmc_card.c + * @file mmc_card.cpp * * @date Dec 28, 2013 * @author Kot_dnz @@ -52,7 +52,7 @@ static bool fs_ready = false; */ static FATFS MMC_FS; -static Logging logger; +static LoggingWithStorage logger; // print FAT error function static void printError(const char *str, FRESULT f_error) { diff --git a/firmware/hw_layer/neo6m.cpp b/firmware/hw_layer/neo6m.cpp index ed0f6a09c6..d36463d555 100644 --- a/firmware/hw_layer/neo6m.cpp +++ b/firmware/hw_layer/neo6m.cpp @@ -1,5 +1,5 @@ /** - * @file neo6m.c + * @file neo6m.cpp * @brief Ublox 6M hardware UART driver * * http://www.u-blox.com/en/gps-modules/pvt-modules/previous-generations/neo-6-family.html @@ -29,7 +29,7 @@ extern board_configuration_s *boardConfiguration; extern engine_configuration_s *engineConfiguration; -static Logging logging; +static LoggingWithStorage logging; static SerialConfig GPSserialConfig = { GPS_SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; static THD_WORKING_AREA(gpsThreadStack, UTILITY_THREAD_STACK_SIZE); diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index 06d4bb6fa0..23e41509a9 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -1,5 +1,5 @@ /** - * @file pin_repository.c + * @file pin_repository.cpp * @brief I/O pin registry code * * This job of this class is to make sure that we are not using same hardware pin for two @@ -20,7 +20,7 @@ const char *PIN_USED[PIN_REPO_SIZE]; static int initialized = FALSE; -static Logging logger; +static LoggingWithStorage logger; static int totalPinsUsed = 0; /** @@ -106,7 +106,7 @@ brain_pin_e parseBrainPin(const char *str) { return (brain_pin_e)(basePin + pin); } -char *hwPortname(brain_pin_e brainPin) { +const char *hwPortname(brain_pin_e brainPin) { if (brainPin == GPIO_INVALID) { return "INVALID"; } diff --git a/firmware/hw_layer/pin_repository.h b/firmware/hw_layer/pin_repository.h index 9f6893e2a0..6917f78ffa 100644 --- a/firmware/hw_layer/pin_repository.h +++ b/firmware/hw_layer/pin_repository.h @@ -27,7 +27,7 @@ extern "C" #endif /* __cplusplus */ void initPinRepository(void); -char *hwPortname(brain_pin_e brainPin); +const char *hwPortname(brain_pin_e brainPin); brain_pin_e parseBrainPin(const char *str); void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t mode); void mySetPadMode2(const char *msg, brain_pin_e pin, iomode_t mode); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 75148a5056..0e82ec4d83 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -120,7 +120,7 @@ extern "C" { #include "engine_emulator.h" #endif /* EFI_ENGINE_EMULATOR */ -static Logging logging; +static LoggingWithStorage logging; int main_loop_started = FALSE; @@ -256,7 +256,7 @@ void firmwareError(const char *fmt, ...) { } } -static char UNUSED_RAM_SIZE[3000]; +static char UNUSED_RAM_SIZE[3500]; static char UNUSED_CCM_SIZE[8000] CCM_OPTIONAL; diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 3a72cf2a2b..16099bdfa9 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Sat Jan 10 10:38:47 EST 2015 +// Tue Jan 13 21:00:28 EST 2015 #ifndef VCS_VERSION -#define VCS_VERSION "6259" +#define VCS_VERSION "6353" #endif diff --git a/firmware/util/cli_registry.cpp b/firmware/util/cli_registry.cpp index 2cc6b0552a..7307f60366 100644 --- a/firmware/util/cli_registry.cpp +++ b/firmware/util/cli_registry.cpp @@ -1,5 +1,5 @@ /** - * @file cli_registry.c + * @file cli_registry.cpp * @brief Command-line interface commands registry * * Here we have a data structure which holds all the dynamically-registered @@ -27,7 +27,7 @@ #if ! EFI_UNIT_TEST #include "eficonsole.h" -static Logging logging; +static LoggingWithStorage logging; #endif /* ! EFI_UNIT_TEST */ static int consoleActionCount = 0; diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 552e599762..8391fa4ee0 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -1,5 +1,5 @@ /** - * @file datalogging.c + * @file datalogging.cpp * @brief Buffered console output stream code * * Here we have a memory buffer and method related to @@ -32,6 +32,8 @@ #include #include "main.h" + +#if ! EFI_UNIT_TEST #include "chprintf.h" #include "chmtx.h" #include "memstreams.h" @@ -184,7 +186,7 @@ int isInitialized(Logging *logging) { return logging->isInitialized == MAGIC_LOGGING_FLAG; } -void initLogging(Logging *logging, const char *name) { +void initLogging(LoggingWithStorage *logging, const char *name) { initLoggingExt(logging, name, logging->DEFAULT_BUFFER, sizeof(logging->DEFAULT_BUFFER)); } @@ -388,3 +390,9 @@ void initIntermediateLoggingBuffer(void) { msObjectInit(&intermediateLoggingBuffer, intermediateLoggingBufferData, INTERMEDIATE_LOGGING_BUFFER_SIZE, 0); intermediateLoggingBufferInited = TRUE; } + +#endif /* ! EFI_UNIT_TEST */ + +LoggingWithStorage::LoggingWithStorage() { + +} diff --git a/firmware/util/datalogging.h b/firmware/util/datalogging.h index a1a321a3ea..e027635fdf 100644 --- a/firmware/util/datalogging.h +++ b/firmware/util/datalogging.h @@ -37,15 +37,14 @@ typedef enum { // todo: migrate to external buffer so that different instances have different // size of buffers? -typedef struct { +class Logging { +public: const char *name; char SMALL_BUFFER[40]; - // todo: explicitly default buffer externally so that we do not have default_buffer where we do not need it? - char DEFAULT_BUFFER[200]; /** * Zero-terminated buffer of pending debug message * - * Unless a larger exteran buffer is specified, this is just a pointer to DEFAULT_BUFFER + * Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER */ char *buffer; /** @@ -55,7 +54,13 @@ typedef struct { char *linePointer; int bufferSize; volatile int isInitialized; -} Logging; +}; + +class LoggingWithStorage : public Logging { +public: + LoggingWithStorage(); + char DEFAULT_BUFFER[200]; +}; #ifdef __cplusplus extern "C" @@ -72,7 +77,7 @@ uint32_t remainingSize(Logging *logging); int isInitialized(Logging *logging); -void initLogging(Logging *logging, const char *name); +void initLogging(LoggingWithStorage *logging, const char *name); void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize); void debugInt(Logging *logging, const char *caption, int value); diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp index 1db15bac24..af61e378fc 100644 --- a/firmware/util/efilib.cpp +++ b/firmware/util/efilib.cpp @@ -10,6 +10,8 @@ #include #include #include "efilib.h" +#include "datalogging.h" +#include "histogram.h" #define _MAX_FILLER 11 @@ -242,3 +244,23 @@ bool strEqual(const char *str1, const char *str2) { return false; return true; } + +/** + * @brief This function knows how to print a histogram_s summary + */ +void printHistogram(Logging *logging, histogram_s *histogram) { +#if EFI_HISTOGRAMS && ! EFI_UNIT_TEST + int report[5]; + int len = hsReport(histogram, report); + + resetLogging(logging); + appendMsgPrefix(logging); + appendPrintf(logging, "histogram %s *", histogram->name); + for (int i = 0; i < len; i++) + appendPrintf(logging, "%d ", report[i]); + appendPrintf(logging, "*"); + appendMsgPostfix(logging); + scheduleLogging(logging); +#endif /* EFI_HISTOGRAMS */ +} + diff --git a/firmware/util/histogram.h b/firmware/util/histogram.h index 2279bfd114..336e81512a 100644 --- a/firmware/util/histogram.h +++ b/firmware/util/histogram.h @@ -16,14 +16,11 @@ #ifndef HISTOGRAM_H_ #define HISTOGRAM_H_ - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - - #include #define BOUND_LENGTH 895 diff --git a/firmware/util/util.mk b/firmware/util/util.mk index f476ee0ecc..d27dba66cd 100644 --- a/firmware/util/util.mk +++ b/firmware/util/util.mk @@ -2,10 +2,11 @@ UTIL_TEST_SRC = $(PROJECT_DIR)/util/crc.c \ $(PROJECT_DIR)/util/data_buffer.c \ $(PROJECT_DIR)/util/histogram.c + UTILSRC = $(UTIL_TEST_SRC) UTILSRC_CPP = $(PROJECT_DIR)/util/cyclic_buffer.cpp \ - $(PROJECT_DIR)/console_util/datalogging.cpp \ + $(PROJECT_DIR)/console_util/datalogging.cpp \ $(PROJECT_DIR)/util/listener_array.cpp \ $(PROJECT_DIR)/util/cli_registry.cpp \ $(PROJECT_DIR)/util/efilib.cpp \ diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 6a2b63f854..aac2a5cdd2 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -179,7 +179,7 @@ bool isCranking(void) { return 0; } -void initLogging(Logging *logging, const char *name) { +void initLogging(LoggingWithStorage *logging, const char *name) { } void scheduleMsg(Logging *logging, const char *fmt, ...) { diff --git a/unit_tests/main.h b/unit_tests/main.h index 6df9d2e1f9..dd8271f89c 100644 --- a/unit_tests/main.h +++ b/unit_tests/main.h @@ -15,7 +15,6 @@ #include "global.h" #include "error_handling.h" #include "efifeatures.h" -#include "datalogging.h" #include "efilib.h" #include "efitime.h" @@ -23,6 +22,8 @@ #include "boards.h" #ifdef __cplusplus +#include "datalogging.h" + extern "C" { #endif