diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 4265369ff9..6acd8234c9 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -89,7 +89,7 @@ #if EFI_SIMULATOR #include "rusEfiFunctionalTest.h" -#endif +#endif /* EFI_SIMULATOR */ #if EFI_TUNER_STUDIO diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index c4ebbe8f51..981434cd30 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -81,6 +81,8 @@ typedef float percent_t; typedef void (*Void)(void); +typedef char critical_error_message_t[ERROR_BUFFER_SIZE]; + typedef char le_formula_t[LE_COMMAND_LENGTH]; typedef brain_pin_e egt_cs_array_t[EGT_CHANNEL_COUNT]; diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 88e382d97d..c6e2b2b425 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -15,8 +15,7 @@ static MemoryStream warningStream; static MemoryStream firmwareErrorMessageStream; #endif /* EFI_SIMULATOR || EFI_PROD_CODE */ -#define WARNING_BUFFER_SIZE 80 -static char warningBuffer[WARNING_BUFFER_SIZE]; +static char warningBuffer[ERROR_BUFFER_SIZE]; static volatile bool isWarningStreamInitialized = false; #if EFI_HD44780_LCD @@ -32,15 +31,18 @@ EXTERN_ENGINE; extern int warningEnabled; extern bool main_loop_started; -// todo: rename to fatalErrorMessage? -static fatal_msg_t errorMessageBuffer; +static fatal_msg_t criticalErrorMessageBuffer; bool hasFirmwareErrorFlag = false; const char *dbg_panic_file; int dbg_panic_line; +#if EFI_TUNER_STUDIO && !defined(EFI_NO_CONFIG_WORKING_COPY) +extern persistent_config_s configWorkingCopy; +#endif + char *getFirmwareError(void) { - return (char*) errorMessageBuffer; + return (char*) criticalErrorMessageBuffer; } #if EFI_PROD_CODE @@ -205,8 +207,8 @@ void onUnlockHook(void) { */ void initErrorHandlingDataStructures(void) { #if EFI_SIMULATOR || EFI_PROD_CODE - msObjectInit(&warningStream, (uint8_t *) warningBuffer, WARNING_BUFFER_SIZE, 0); - msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0); + msObjectInit(&warningStream, (uint8_t *) warningBuffer, ERROR_BUFFER_SIZE, 0); + msObjectInit(&firmwareErrorMessageStream, criticalErrorMessageBuffer, sizeof(criticalErrorMessageBuffer), 0); #endif isWarningStreamInitialized = true; } @@ -230,8 +232,8 @@ void firmwareError(obd_code_e code, const char *fmt, ...) { * in case of simple error message let's reduce stack usage * because chvprintf might be causing an error */ - strncpy((char*) errorMessageBuffer, fmt, sizeof(errorMessageBuffer) - 1); - errorMessageBuffer[sizeof(errorMessageBuffer) - 1] = 0; // just to be sure + strncpy((char*) criticalErrorMessageBuffer, fmt, sizeof(criticalErrorMessageBuffer) - 1); + criticalErrorMessageBuffer[sizeof(criticalErrorMessageBuffer) - 1] = 0; // just to be sure } else { // todo: look into chsnprintf once on Chibios 3 firmwareErrorMessageStream.eos = 0; // reset @@ -242,6 +244,15 @@ void firmwareError(obd_code_e code, const char *fmt, ...) { // todo: reuse warning buffer helper method firmwareErrorMessageStream.buffer[firmwareErrorMessageStream.eos] = 0; // need to terminate explicitly } + +#if EFI_TUNER_STUDIO + #if defined(EFI_NO_CONFIG_WORKING_COPY) + memcpy(persistentState.persistentConfiguration.critical_error_message, criticalErrorMessageBuffer, sizeof(criticalErrorMessageBuffer)); + #else /* defined(EFI_NO_CONFIG_WORKING_COPY) */ + memcpy(configWorkingCopy.critical_error_message, criticalErrorMessageBuffer, sizeof(criticalErrorMessageBuffer)); + #endif /* defined(EFI_NO_CONFIG_WORKING_COPY) */ +#endif /* EFI_TUNER_STUDIO */ + #else printf("firmwareError [%s]\r\n", fmt); diff --git a/firmware/controllers/core/error_handling.h b/firmware/controllers/core/error_handling.h index 1eea226cce..463257871c 100644 --- a/firmware/controllers/core/error_handling.h +++ b/firmware/controllers/core/error_handling.h @@ -33,7 +33,7 @@ void firmwareError(obd_code_e code, const char *fmt, ...); #define hasFirmwareError() hasFirmwareErrorFlag -// todo: rename to getFatalErrorMessage +// todo: rename to getCriticalErrorMessage char *getFirmwareError(void); void initErrorHandlingDataStructures(void); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index fee9bd93bc..8304703e50 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -759,6 +759,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 201200326; + return 201200328; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index 9bc8d2252b..7c21e98762 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -150,6 +150,7 @@ persisted_configuration_state_e readConfiguration(Logging * logger) { } // we can only change the state after the CRC check engineConfiguration->byFirmwareVersion = getRusEfiVersion(); + memset(persistentState.persistentConfiguration.critical_error_message, 0, ERROR_BUFFER_SIZE); validateConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE); return result; } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 7145f57380..a50269fc4b 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -738,6 +738,11 @@ custom maf_sensor_type_e 4 bits, S32, @OFFSET@, [0:7], @@maf_sensor_type_e_enum@ maf_sensor_type_e mafSensorType; +! same length used for critical and soft error messages +#define ERROR_BUFFER_SIZE 80 + +! todo: improve code generator so that we could use reuse 'ERROR_BUFFER_SIZE' for type size + custom critical_error_message_t 80 string, ASCII, @OFFSET@, @@ERROR_BUFFER_SIZE@@ custom le_formula_t 200 string, ASCII, @OFFSET@, 200 brain_pin_e[FSIO_COMMAND_COUNT iterate] fsioDigitalInputs;todo:not finished\nThese input pins allow us to pull toggle buttons state; @@ -1192,13 +1197,14 @@ uint8_t[4] unusuedsw; uint8_t[IAC_PID_MULT_SIZE] iacPidMultLoadBins;;"Load", 1, 0.0, 0, 500.0, 2 uint8_t[IAC_PID_MULT_SIZE] iacPidMultRpmBins;;"RPM", @@RPM_1_BYTE_PACKING_MULT@@, 0, 0.0, 12000.0, 0 - int[495] mainUnusedEnd; + int[475] mainUnusedEnd; ! end of engine_configuration_s end_struct engine_configuration_s engineConfiguration; +critical_error_message_t critical_error_message; float[AFTERSTART_HOLD_CURVE_SIZE] afterstartCoolantBins;;"C", 1, 0, -100.0, 250.0, 0 float[AFTERSTART_HOLD_CURVE_SIZE] afterstartHoldTime;;"Seconds", 1, 0, 0, 100, 1 diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 596d24b1ca..14b7017028 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -275,7 +275,8 @@ fileVersion = { @@TS_FILE_VERSION@@ } knockLevel = scalar, F32, 108, "Volts", 1, 0 ; Mode, firmware, protocol, run time - timeSeconds = scalar, U32, 112, "sec", 1, 0.0 +; TS requires 'seconds' name since it has special internal meaning + seconds = scalar, U32, 112, "sec", 1, 0.0 engineMode = scalar, U32, 116, "em", 1, 0.0; firmwareVersion = scalar, U32, 120,"version_f", 1, 0 firmwareTsVersion=scalar, U32, 124,"version_p", 1, 0 @@ -364,8 +365,21 @@ fileVersion = { @@TS_FILE_VERSION@@ } debugFieldI4List = bits, U08, [0:7], "", "", "", "", "Idle df4", "", "", "", "", "", "", "", "", "", "", "", "", "ETB di4", "", "", "di4", "di4", "22di4", "", "23:di4", "", "", "", "", "", "", "Init Count", "", "", "", "", "", "" debugFieldI5List = bits, U08, [0:7], "", "", "", "", "Idle df5", "", "", "", "", "", "", "", "", "", "", "di5", "di5", "ETB di5", "di5", "di5", "di5", "di5", "22di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5", "di5" [ConstantsExtensions] + ; defaultValue is used to provide TunerStudio with a value to use in the case of + ; the constant not yet being initialized. This is primarily important if the + ; constant is used as a variable in the ini. + ; defaultValue = constantName, value; defaultValue = wueAfrTargetOffset, -1.5 -1.4 -1.15 -0.95 -0.775 -0.65 -0.5625 -0.5 -0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625 0 + + requiresPowerCycle = warningLedPin + requiresPowerCycle = runningLedPin + requiresPowerCycle = binarySerialTxPin + requiresPowerCycle = binarySerialRxPin + + readOnly = critical_error_message + + [CurveEditor] ; xAxis = leftValue, rightValue, step ; yAxis = bottomValue, topValue, step @@ -792,7 +806,7 @@ gaugeCategory = ECU Status recentErrorCode6Gauge = recentErrorCode6, "Error#7", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 recentErrorCode7Gauge = recentErrorCode7, "Error#8", "", 0, 18000, 0, 0, 18000, 18000, 0, 0 firmwareVersionGauge = firmwareVersion , "ECU Software Version", "%", 0, 100, 0, 0, 100, 100, 0, 0 - timeSecondsGauge = timeSeconds, "Uptime", "sec", 0, 100, 0, 0, 100, 100, 0, 0 + timeSecondsGauge = seconds, "Uptime", "sec", 0, 100, 0, 0, 100, 100, 0, 0 gaugeCategory = Debug @@ -917,7 +931,7 @@ gaugeCategory = Throttle Body (incl. ETB) ; = expression, off-label, on-label, off-bg, off-fg, on-bg, on-fg ; important status - indicator = { ind_hasFatalError }, "", "FATAL ERROR", green, black, red, black + indicator = { ind_hasFatalError }, "", "CRITICAL ERROR", green, black, red, black indicator = { firmwareTsVersion == fileVersion }, "WRONG VERSION", "version", red, black, green, black indicator = { ind_isWarnNow }, "", "warn", green, black, red, black indicator = { ind_check_engine }, "ok", "Check engine", green, black, red, black @@ -1677,7 +1691,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = mc33816_driven, mc33816_driven field = mc33816spiDevice, mc33816spiDevice field = "Warning Led", warningLedPin - ; field = "Fatal Error Led", fatalErrorPin field = "tle6240_cs", tle6240_cs field = "tle6240 SPI", tle6240spiDevice field = "mc33972_cs", mc33972_cs @@ -2087,7 +2100,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "Running status LED", runningLedPin field = "TS communication status LED", communicationLedPin field = "Trigger error LED", triggerErrorPin - ; field = "Fatal Error Led", fatalErrorPin ; Engine->MIL Settings dialog = malfunction, "Check Engine Settings" @@ -2330,6 +2342,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" dialog = debugging, "Debug" field = "!https://rusefi.com/s/debugmode" field = "Debug mode", debugMode + field = "Critical Error", critical_error_message dialog = limits, "Limits" diff --git a/java_console/models/src/com/rusefi/config/generated/Fields.java b/java_console/models/src/com/rusefi/config/generated/Fields.java index 0cf66dbd94..97265505e1 100644 --- a/java_console/models/src/com/rusefi/config/generated/Fields.java +++ b/java_console/models/src/com/rusefi/config/generated/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Mar 27 12:12:49 EDT 2020 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Mar 28 19:52:31 EDT 2020 // by class com.rusefi.output.FileJavaFieldsConsumer import com.rusefi.config.*; @@ -318,6 +318,8 @@ public class Fields { public static final int crankingTpsBins_offset_hex = 688; public static final int crankingTpsCoef_offset = 1640; public static final int crankingTpsCoef_offset_hex = 668; + public static final int critical_error_message_offset = 6040; + public static final int critical_error_message_offset_hex = 1798; public static final int cutFuelOnHardLimit_offset = 1464; public static final int cutSparkOnHardLimit_offset = 1464; public static final int cylinderBore_offset = 408; @@ -368,6 +370,7 @@ public class Fields { public static final int engineSnifferRpmThreshold_offset_hex = 4; public static final int engineType_offset = 0; public static final int engineType_offset_hex = 0; + public static final int ERROR_BUFFER_SIZE = 80; public static final int ETB_BIAS_CURVE_LENGTH = 8; public static final int ETB_COUNT = 2; public static final int etb_dFactor_offset = 1744; @@ -2375,6 +2378,7 @@ public class Fields { public static final Field IDLERPMPID2_MINVALUE = Field.create("IDLERPMPID2_MINVALUE", 4056, FieldType.INT16); public static final Field IDLERPMPID2_MAXVALUE = Field.create("IDLERPMPID2_MAXVALUE", 4058, FieldType.INT16); public static final Field IACPIDMULTTABLE = Field.create("IACPIDMULTTABLE", 4060, FieldType.INT); + public static final Field CRITICAL_ERROR_MESSAGE = Field.create("CRITICAL_ERROR_MESSAGE", 6040, FieldType.INT); public static final Field BOOSTTABLEOPENLOOP = Field.create("BOOSTTABLEOPENLOOP", 6248, FieldType.INT); public static final Field BOOSTTABLECLOSEDLOOP = Field.create("BOOSTTABLECLOSEDLOOP", 6328, FieldType.INT); public static final Field PEDALTOTPSTABLE = Field.create("PEDALTOTPSTABLE", 6400, FieldType.INT); @@ -3271,6 +3275,7 @@ public class Fields { IDLERPMPID2_MINVALUE, IDLERPMPID2_MAXVALUE, IACPIDMULTTABLE, + CRITICAL_ERROR_MESSAGE, BOOSTTABLEOPENLOOP, BOOSTTABLECLOSEDLOOP, PEDALTOTPSTABLE,