diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index a6e1e7e666..55d7bc3411 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -165,8 +165,6 @@ void initializeConsole(Logging *sharedLogger) { startConsole(&handleConsoleLine); - initLogging(&logger, "console"); - sayHello(); addConsoleAction("test", sayNothing); addConsoleAction("hello", sayHello); diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index a528647bf7..fee680dd50 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -273,7 +273,7 @@ static char LOGGING_BUFFER[700]; volatile int needToReportStatus = FALSE; static int prevCkpEventCounter = -1; -static LoggingWithStorage logger2; +static LoggingWithStorage logger2("main event handler"); static void printStatus(void) { needToReportStatus = TRUE; @@ -640,7 +640,6 @@ void initStatusLoop(Engine *engine) { addConsoleActionI("warn", setWarningEnabled); #if EFI_PROD_CODE - initLogging(&logger2, "main event handler"); #if EFI_ENGINE_CONTROL addConsoleActionFFP("fuelinfo2", (VoidFloatFloatVoidPtr) showFuelInfo2, diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 2596de144d..d391958a54 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -21,7 +21,7 @@ #define isRunningBenchTest() true #endif -static LoggingWithStorage logger; +static LoggingWithStorage logger("engine"); extern engine_pins_s enginePins; @@ -55,7 +55,6 @@ void Engine::precalc(engine_configuration_s *engineConfiguration) { } void Engine::init() { - initLogging(&logger, "engine"); } static bool stopPin(NamedOutputPin *output) { diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 06ebb9dd5c..fdfa7c3791 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 LoggingWithStorage logger; +static LoggingWithStorage logger("Engine Controller"); #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) static engine_configuration2_s ec2 CCM_OPTIONAL; @@ -337,7 +337,6 @@ void initEngineContoller(Logging *sharedLogger, Engine *engine) { if (hasFirmwareError()) { return; } - initLogging(&logger, "Engine Controller"); initSensors(engine); diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index f3811f973a..f16d2d41fe 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 LoggingWithStorage logger; +static LoggingWithStorage logger("error handling"); #define WARNING_PREFIX "WARNING: " @@ -104,6 +104,5 @@ void onUnlockHook(void) { } void initErrorHandling(void) { - initLogging(&logger, "error handling"); msObjectInit(&warningStream, (uint8_t *) warningBuffer, WARNING_BUFFER_SIZE, 0); } diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index a4aa237256..f58feefac5 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 LoggingWithStorage logger; +static LoggingWithStorage logger("InjectorCentral"); EXTERN_ENGINE ; @@ -208,7 +208,6 @@ static msg_t benchThread(int param) { } void initInjectorCentral(Engine *engine) { - initLogging(&logger, "InjectorCentral"); chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { diff --git a/firmware/development/wave_chart.cpp b/firmware/development/wave_chart.cpp index 948fc54026..421ae5742c 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 LoggingWithStorage logger; +static LoggingWithStorage logger("wave info"); void WaveChart::resetWaveChart() { #if DEBUG_WAVE @@ -220,7 +220,6 @@ void showWaveChartHistogram(void) { } void initWaveChart(WaveChart *chart) { - initLogging(&logger, "wave info"); if (!engineConfiguration->isDigitalChartEnabled) { printMsg(&logger, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! chart disabled"); diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index 21b7f708ba..40d28f3176 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 LoggingWithStorage logger; +static LoggingWithStorage logger("CAN driver"); static THD_WORKING_AREA(canTreadStack, UTILITY_THREAD_STACK_SIZE); /* @@ -252,8 +252,6 @@ void initCan(void) { return; #endif /* EFI_PROD_CODE */ - initLogging(&logger, "CAN driver"); - #if STM32_CAN_USE_CAN2 // CAN1 is required for CAN2 canStart(&CAND1, &canConfig); diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp index fc33fb594c..c7c669040a 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 LoggingWithStorage logger; +static LoggingWithStorage logger("io_pins"); static OutputPin sdCsPin; @@ -97,8 +97,6 @@ void initPrimaryPins(void) { } void initOutputPins(void) { - initLogging(&logger, "io_pins"); - /** * want to make sure it's all zeros so that we can compare in initOutputPinExt() method */ diff --git a/firmware/hw_layer/neo6m.cpp b/firmware/hw_layer/neo6m.cpp index d36463d555..5d5ffa9a85 100644 --- a/firmware/hw_layer/neo6m.cpp +++ b/firmware/hw_layer/neo6m.cpp @@ -29,7 +29,7 @@ extern board_configuration_s *boardConfiguration; extern engine_configuration_s *engineConfiguration; -static LoggingWithStorage logging; +static LoggingWithStorage logging("uart gps"); static SerialConfig GPSserialConfig = { GPS_SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; static THD_WORKING_AREA(gpsThreadStack, UTILITY_THREAD_STACK_SIZE); @@ -108,7 +108,6 @@ void initGps(void) { if(!engineConfiguration->isGpsEnabled) return; - initLogging(&logging, "uart gps"); sdStart(GPS_SERIAL_DEVICE, &GPSserialConfig); // GPS we have USART1: PB7 -> USART1_RX and PB6 -> USART1_TX diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index dc9dcfe064..4ecbbb79e9 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -20,7 +20,7 @@ const char *PIN_USED[PIN_REPO_SIZE]; static int initialized = FALSE; -static LoggingWithStorage logger; +static LoggingWithStorage logger("pin repos"); static int totalPinsUsed = 0; /** @@ -125,7 +125,6 @@ void initPinRepository(void) { /** * this method cannot use console because this method is invoked before console is initialized */ - initLogging(&logger, "pin repos"); msObjectInit(&portNameStream, (uint8_t*) portNameBuffer, sizeof(portNameBuffer), 0); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 55a2d834d3..df55a669ac 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -117,7 +117,7 @@ #include "engine_emulator.h" #endif /* EFI_ENGINE_EMULATOR */ -static LoggingWithStorage sharedLogger; +static LoggingWithStorage sharedLogger("main"); bool_t main_loop_started = false; @@ -156,7 +156,6 @@ void runRusEfi(void) { * Next we should initialize serial port console, it's important to know what's going on */ initializeConsole(&sharedLogger); - initLogging(&sharedLogger, "main"); engine->init(); @@ -259,5 +258,5 @@ int getRusEfiVersion(void) { return 1; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE == 0) return 1; // this is here to make the compiler happy about the unused array - return 20150208; + return 20150209; } diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index fa55c169e7..1ec136a4e5 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -174,10 +174,6 @@ int isInitialized(Logging *logging) { return logging->isInitialized == MAGIC_LOGGING_FLAG; } -void initLogging(LoggingWithStorage *logging, const char *name) { - initLoggingExt(logging, name, logging->DEFAULT_BUFFER, sizeof(logging->DEFAULT_BUFFER)); -} - void debugInt(Logging *logging, const char *caption, int value) { append(logging, caption); append(logging, DELIMETER); @@ -389,10 +385,8 @@ void initIntermediateLoggingBuffer(void) { #endif /* ! EFI_UNIT_TEST */ -// todo: eliminate this constructor -LoggingWithStorage::LoggingWithStorage() { -} - LoggingWithStorage::LoggingWithStorage(const char *name) { - initLogging(this, name); +#if ! EFI_UNIT_TEST + initLoggingExt(this, name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)); +#endif /* ! EFI_UNIT_TEST */ } diff --git a/firmware/util/datalogging.h b/firmware/util/datalogging.h index 187845175b..1c6f5365b8 100644 --- a/firmware/util/datalogging.h +++ b/firmware/util/datalogging.h @@ -37,7 +37,6 @@ public: class LoggingWithStorage : public Logging { public: - LoggingWithStorage(); LoggingWithStorage(const char *name); char DEFAULT_BUFFER[200]; }; @@ -57,7 +56,6 @@ uint32_t remainingSize(Logging *logging); int isInitialized(Logging *logging); -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/java_console/io/src/com/rusefi/io/CommandQueue.java b/java_console/io/src/com/rusefi/io/CommandQueue.java index fdf2d93a3a..8c0bcbc01c 100644 --- a/java_console/io/src/com/rusefi/io/CommandQueue.java +++ b/java_console/io/src/com/rusefi/io/CommandQueue.java @@ -1,7 +1,6 @@ package com.rusefi.io; import com.irnems.core.MessagesCentral; -import com.rusefi.io.tcp.TcpConnector; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -9,8 +8,6 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import static com.rusefi.io.tcp.TcpConnector.parseIntWithReason; - /** * This class keeps re-sending a command till a proper confirmation is received *

@@ -97,6 +94,10 @@ public class CommandQueue { }); } + /** + * this method handles command confirmations packed as + * TODO: add example, todo: refactor method and add unit test + */ private void handleConfirmationMessage(String message, MessagesCentral mc) { String confirmation = message.substring(CONFIRMATION_PREFIX.length()); int index = confirmation.indexOf(":"); @@ -104,7 +105,14 @@ public class CommandQueue { mc.postMessage(CommandQueue.class, "Broken confirmation: " + confirmation); return; } - int length = parseIntWithReason(confirmation.substring(index + 1), "CQ confirmation"); + String number = confirmation.substring(index + 1); + int length; + try { + length = Integer.parseInt(number); + } catch (NumberFormatException e) { + mc.postMessage(CommandQueue.class, "Broken confirmation length: " + confirmation); + return; + } if (length != index) { mc.postMessage(CommandQueue.class, "Broken confirmation length: " + confirmation); return; diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index db09bf192f..2762df6f0a 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -23,7 +23,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see WavePanel */ public class Launcher extends FrameHelper { - public static final int CONSOLE_VERSION = 20150204; + public static final int CONSOLE_VERSION = 20150209; public static final boolean SHOW_STIMULATOR = true; public static final String TAB_INDEX = "main_tab"; private final String port; diff --git a/win32_functional_tests/simulator/boards.cpp b/win32_functional_tests/simulator/boards.cpp index cec3431871..13f6c67a9d 100644 --- a/win32_functional_tests/simulator/boards.cpp +++ b/win32_functional_tests/simulator/boards.cpp @@ -10,7 +10,7 @@ #include "engine_configuration.h" #include "adc_math.h" -static LoggingWithStorage logger; +static LoggingWithStorage logger("simulator board"); extern engine_configuration_s *engineConfiguration; static float fakeAdcValues[16]; @@ -49,7 +49,6 @@ static void setMapVoltage(float voltage) { } void initFakeBoard(void) { - initLogging(&logger, "simulator board"); addConsoleActionF("set_mock_clt_voltage", setCltVoltage); addConsoleActionF("set_mock_iat_voltage", setIatVoltage); diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index aad38b07f0..e19c1d7bc4 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -41,7 +41,7 @@ bool isInsideTriggerHandler; persistent_config_container_s persistentState; static engine_configuration2_s ec2; -static LoggingWithStorage sharedLogger; +static LoggingWithStorage sharedLogger("simulator"); engine_configuration_s * engineConfiguration = &persistentState.persistentConfiguration.engineConfiguration; board_configuration_s *boardConfiguration = &persistentState.persistentConfiguration.engineConfiguration.bc; @@ -66,12 +66,10 @@ float getMap(void) { } void rusEfiFunctionalTest(void) { - initLogging(&sharedLogger, "simulator"); initializeConsole(&sharedLogger); initFakeBoard(); - initStatusLoop(engine); initDataStructures(PASS_ENGINE_PARAMETER_F);