From 07f210a82b9f08bd1ce06aef6dc9b4ec9156c215 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 16 Apr 2022 17:35:59 -0400 Subject: [PATCH] random progress & method rename --- firmware/console/binary/tunerstudio.cpp | 8 ++++++-- firmware/console/status_loop.cpp | 13 ++++++++++++- firmware/controllers/core/error_handling.cpp | 8 ++++---- firmware/controllers/core/error_handling.h | 3 +-- firmware/controllers/gauges/lcd_controller.cpp | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 3a58b6d111..63490d653c 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -213,7 +213,11 @@ const void * getStructAddr(live_data_e structId) { case LDS_trigger_central: return static_cast(&engine->triggerCentral); case LDS_trigger_state: +#if EFI_SHAFT_POSITION_INPUT return static_cast(&engine->triggerCentral.triggerState); +#else + return nullptr; +#endif // EFI_SHAFT_POSITION_INPUT case LDS_wall_fuel_state: return static_cast(&engine->injectionEvents.elements[0].wallFuel); case LDS_idle_state: @@ -429,7 +433,7 @@ static void handleTestCommand(TsChannelBase* tsChannel) { tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer)); if (hasFirmwareError()) { - const char* error = getFirmwareError(); + const char* error = getCriticalErrorMessage(); chsnprintf(testOutputBuffer, sizeof(testOutputBuffer), "error=%s\r\n", error); tsChannel->write((const uint8_t*)testOutputBuffer, strlen(testOutputBuffer)); } @@ -810,7 +814,7 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int inco break; #endif /* ENABLE_PERF_TRACE */ case TS_GET_CONFIG_ERROR: { - const char* configError = getFirmwareError(); + const char* configError = getCriticalErrorMessage(); #if HW_CHECK_MODE // analog input errors are returned as firmware error in QC mode if (!hasFirmwareError()) { diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 2f14baf998..2118239364 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -261,7 +261,7 @@ void updateDevConsoleState(void) { #if EFI_PROD_CODE // todo: unify with simulator! if (hasFirmwareError()) { - efiPrintf("%s error: %s", CRITICAL_PREFIX, getFirmwareError()); + efiPrintf("%s error: %s", CRITICAL_PREFIX, getCriticalErrorMessage()); warningEnabled = false; return; } @@ -723,6 +723,8 @@ void updateTunerStudioState() { // header tsOutputChannels->tsConfigVersion = TS_FILE_VERSION; +#if EFI_SHAFT_POSITION_INPUT + // offset 0 tsOutputChannels->RPMValue = rpm; auto instantRpm = engine->triggerCentral.triggerState.getInstantRpm(); @@ -747,6 +749,9 @@ void updateTunerStudioState() { tsOutputChannels->totalTriggerErrorCounter = engine->triggerCentral.triggerState.totalTriggerErrorCounter; tsOutputChannels->orderingErrorCounter = engine->triggerCentral.triggerState.orderingErrorCounter; +#endif // EFI_SHAFT_POSITION_INPUT + + // 68 // 140 #if EFI_ENGINE_CONTROL @@ -820,6 +825,7 @@ void updateTunerStudioState() { tsOutputChannels->maxTriggerReentrant = maxTriggerReentrant; #endif /* EFI_CLOCK_LOCKS */ +#if EFI_SHAFT_POSITION_INPUT tsOutputChannels->triggerPrimaryFall = engine->triggerCentral.getHwEventCounter((int)SHAFT_PRIMARY_FALLING); tsOutputChannels->triggerPrimaryRise = engine->triggerCentral.getHwEventCounter((int)SHAFT_PRIMARY_RISING); @@ -828,6 +834,7 @@ void updateTunerStudioState() { tsOutputChannels->triggerVvtRise = engine->triggerCentral.vvtEventRiseCounter[0]; tsOutputChannels->triggerVvtFall = engine->triggerCentral.vvtEventFallCounter[0]; +#endif // EFI_SHAFT_POSITION_INPUT switch (engineConfiguration->debugMode) { @@ -847,8 +854,10 @@ void updateTunerStudioState() { tsOutputChannels->debugFloatField3 = icuRisingCallbackCounter + icuFallingCallbackCounter; #endif /* EFI_PROD_CODE */ +#if EFI_SHAFT_POSITION_INPUT tsOutputChannels->debugIntField4 = engine->triggerCentral.triggerState.currentCycle.eventCount[0]; tsOutputChannels->debugIntField5 = engine->triggerCentral.triggerState.currentCycle.eventCount[1]; +#endif // EFI_SHAFT_POSITION_INPUT // debugFloatField6 used // no one uses shaft so far tsOutputChannels->debugFloatField3 = engine->triggerCentral.getHwEventCounter((int)SHAFT_3RD_RISING); @@ -879,7 +888,9 @@ void updateTunerStudioState() { break; case DBG_INSTANT_RPM: { +#if EFI_SHAFT_POSITION_INPUT tsOutputChannels->debugFloatField2 = instantRpm / Sensor::getOrZero(SensorType::Rpm); +#endif // EFI_SHAFT_POSITION_INPUT tsOutputChannels->mostRecentTimeBetweenSparkEvents = engine->mostRecentTimeBetweenSparkEvents; tsOutputChannels->mostRecentTimeBetweenIgnitionEvents = engine->mostRecentTimeBetweenIgnitionEvents; diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 9456877284..fbcc61a658 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -22,7 +22,7 @@ bool hasFirmwareErrorFlag = false; const char *dbg_panic_file; int dbg_panic_line; -const char* getFirmwareError(void) { +const char* getCriticalErrorMessage(void) { return criticalErrorMessageBuffer; } @@ -218,12 +218,12 @@ void firmwareError(obd_code_e code, const char *fmt, ...) { va_end(ap); } - int size = strlen((char*)criticalErrorMessageBuffer); + int errorMessageSize = strlen((char*)criticalErrorMessageBuffer); static char versionBuffer[32]; chsnprintf(versionBuffer, sizeof(versionBuffer), " %d@%s", getRusEfiVersion(), FIRMWARE_ID); - if (size + strlen(versionBuffer) < sizeof(criticalErrorMessageBuffer)) { - strcpy((char*)(criticalErrorMessageBuffer) + size, versionBuffer); + if (errorMessageSize + strlen(versionBuffer) < sizeof(criticalErrorMessageBuffer)) { + strcpy((char*)(criticalErrorMessageBuffer) + errorMessageSize, versionBuffer); } #else diff --git a/firmware/controllers/core/error_handling.h b/firmware/controllers/core/error_handling.h index 7fea3bb1c5..9776c5e4d8 100644 --- a/firmware/controllers/core/error_handling.h +++ b/firmware/controllers/core/error_handling.h @@ -37,8 +37,7 @@ extern bool hasFirmwareErrorFlag; #define hasFirmwareError() hasFirmwareErrorFlag -// todo: rename to getCriticalErrorMessage -const char* getFirmwareError(void); +const char* getCriticalErrorMessage(void); const char* getWarningMessage(void); // todo: better place for this shared declaration? diff --git a/firmware/controllers/gauges/lcd_controller.cpp b/firmware/controllers/gauges/lcd_controller.cpp index 5e62f365d5..05b3ce591c 100644 --- a/firmware/controllers/gauges/lcd_controller.cpp +++ b/firmware/controllers/gauges/lcd_controller.cpp @@ -281,7 +281,7 @@ void updateHD44780lcd(void) { } - const char * message = hasFirmwareErrorFlag ? getFirmwareError() : getWarningMessage(); + const char * message = hasFirmwareErrorFlag ? getCriticalErrorMessage() : getWarningMessage(); memcpy(buffer, message, engineConfiguration->HD44780width); buffer[engineConfiguration->HD44780width] = 0; lcd_HD44780_set_position(engineConfiguration->HD44780height - 1, 0); @@ -309,7 +309,7 @@ void updateHD44780lcd(void) { // lcd_HD44780_print_string(buffer); // // if (hasFirmwareError()) { -// memcpy(buffer, getFirmwareError(), LCD_WIDTH); +// memcpy(buffer, getCriticalErrorMessage(), LCD_WIDTH); // buffer[LCD_WIDTH] = 0; // lcd_HD44780_set_position(1, 0); // lcd_HD44780_print_string(buffer);