diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index 65d9af4137..800e7c2831 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -112,6 +112,10 @@ typedef struct { float currentTargetAfr; // 176 float chargeAirMass; // 180 float cltCorrection; // 184 + /** + * @see actualLastInjection + * without injector lag, see engine.h for details + */ float runningFuel; // 188 int debugIntField1; // 192 float injectorLagMs; // 196 diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 2eb1d7ae6f..dedbdfb96f 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -58,6 +58,8 @@ #include "settings.h" #include "rusefi_outputs.h" +extern fuel_Map3D_t veMap; +extern afr_Map3D_t afrMap; extern bool main_loop_started; #if EFI_PROD_CODE || defined(__DOXYGEN__) @@ -91,7 +93,8 @@ static void setWarningEnabled(int value) { } #if EFI_FILE_LOGGING || defined(__DOXYGEN__) -static LoggingWithStorage fileLogger("file logger"); +static char FILE_LOGGER[1000] CCM_OPTIONAL; +static Logging fileLogger("file logger", FILE_LOGGER, sizeof(FILE_LOGGER)); #endif /* EFI_FILE_LOGGING */ static int logFileLineIndex = 0; @@ -150,40 +153,87 @@ static void printSensors(Logging *log, bool fileFormat) { // current time, in milliseconds int nowMs = currentTimeMillis(); float sec = ((float) nowMs) / 1000; - reportSensorF(log, fileFormat, "time", "", sec, 3); + reportSensorF(log, fileFormat, "time", "", sec, 3); // log column 1 int rpm = 0; #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) rpm = getRpmE(engine); - reportSensorI(log, fileFormat, "rpm", "RPM", rpm); + reportSensorI(log, fileFormat, "rpm", "RPM", rpm); // log column 2 // reportSensorF(log, fileFormat, "TRG_0_DUTY", "%", getTriggerDutyCycle(0), 2); // reportSensorF(log, fileFormat, "TRG_1_DUTY", "%", getTriggerDutyCycle(1), 2); #endif +#if EFI_PROD_CODE || defined(__DOXYGEN__) + reportSensorF(log, fileFormat, "int_temp", "C", getMCUInternalTemperature(), 2); // log column #3 +#endif + + if (engineConfiguration->hasCltSensor) { + reportSensorF(log, fileFormat, "CLT", "C", getCoolantTemperature(PASS_ENGINE_PARAMETER_F), 2); // log column #4 + } + reportSensorF(log, fileFormat, "TPS", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2); // log column #5 + + if (hasVBatt(PASS_ENGINE_PARAMETER_F)) { + reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(PASS_ENGINE_PARAMETER_F), 2); // log column #6 + } + + reportSensorF(log, fileFormat, "IAT", "C", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F), 2); // log column #7 + + if (hasMafSensor()) { reportSensorF(log, fileFormat, "maf", "V", getMaf(PASS_ENGINE_PARAMETER_F), 2); reportSensorF(log, fileFormat, "mafr", "kg/hr", getRealMaf(PASS_ENGINE_PARAMETER_F), 2); } - - reportSensorF(log, fileFormat, "ENGINE_LOAD", "x", getEngineLoadT(PASS_ENGINE_PARAMETER_F), 2); - - - #if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) if (engineConfiguration->hasMapSensor) { reportSensorF(log, fileFormat, "MAP", "kPa", getMap(), 2); // reportSensorF(log, fileFormat, "map_r", "V", getRawMap(), 2); } +#endif /* EFI_ANALOG_SENSORS */ +#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) if (hasBaroSensor()) { reportSensorF(log, fileFormat, "baro", "kPa", getBaroPressure(), 2); } +#endif /* EFI_ANALOG_SENSORS */ + if (engineConfiguration->hasAfrSensor) { reportSensorF(log, fileFormat, "afr", "AFR", getAfr(PASS_ENGINE_PARAMETER_F), 2); } - reportSensorF(log, fileFormat, "target", "AFR", engine->engineState.targetAFR, 2); -#endif + if (fileFormat) { + reportSensorF(log, fileFormat, "idle", "%", getIdlePosition(), 2); + } + +#if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) + reportSensorF(log, fileFormat, "target", "AFR", engine->engineState.targetAFR, 2); +#endif /* EFI_ANALOG_SENSORS */ + + if (fileFormat) { + reportSensorF(log, fileFormat, "tCharge", "K", engine->engineState.tChargeK, 2); // log column #8 + reportSensorF(log, fileFormat, "curVE", "%", veMap.getValue(rpm, getMap()), 2); + } + + float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); + reportSensorF(log, fileFormat, "ENGINE_LOAD", "x", engineLoad, 2); + + + reportSensorF(log, fileFormat, "dwell", "ms", ENGINE(engineState.sparkDwell), 2); + if (fileFormat) { + reportSensorF(log, fileFormat, "timing", "deg", engine->engineState.timingAdvance, 2); + + } + + if (fileFormat) { + floatms_t baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER); + reportSensorF(log, fileFormat, "f: base", "ms", baseFuel, 2); + reportSensorF(log, fileFormat, "f: actual", "ms", ENGINE(actualLastInjection), 2); + reportSensorF(log, fileFormat, "f: lag", "ms", engine->engineState.injectorLag, 2); + reportSensorF(log, fileFormat, "f: running", "ms", ENGINE(engineState.runningFuel), 2); + + reportSensorF(log, fileFormat, "f: wall amt", "v", ENGINE(wallFuel).getWallFuel(0), 2); + reportSensorF(log, fileFormat, "f: wall crr", "v", ENGINE(wallFuelCorrection), 2); + } + if (engineConfiguration->hasVehicleSpeedSensor) { #if EFI_VEHICLE_SPEED || defined(__DOXYGEN__) @@ -196,37 +246,21 @@ static void printSensors(Logging *log, bool fileFormat) { reportSensorF(log, fileFormat, "sp2rpm", "x", sp2rpm, 2); } - reportSensorI(log, fileFormat, "warn", "count", engine->engineState.warningCounter); - reportSensorI(log, fileFormat, "error", "code", engine->engineState.lastErrorCode); - reportSensorF(log, fileFormat, "knck_c", "count", engine->knockCount, 0); reportSensorF(log, fileFormat, "knck_v", "v", engine->knockVolts, 2); -#if EFI_PROD_CODE || defined(__DOXYGEN__) - reportSensorF(log, fileFormat, "int_temp", "C", getMCUInternalTemperature(), 2); -#endif - // reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2); - if (hasVBatt(PASS_ENGINE_PARAMETER_F)) { - reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(PASS_ENGINE_PARAMETER_F), 2); - } - - reportSensorF(log, fileFormat, "TP", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2); if (fileFormat) { - reportSensorF(log, fileFormat, "tpsacc", "ms", engine->tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F), 2); - reportSensorF(log, fileFormat, "advance", "deg", engine->engineState.timingAdvance, 2); - reportSensorF(log, fileFormat, "duty", "%", getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER), 2); + reportSensorF(log, fileFormat, "f: tps delta", "v", engine->tpsAccelEnrichment.getMaxDelta(), 2); + reportSensorF(log, fileFormat, "f: tps fuel", "ms", engine->engineState.tpsAccelEnrich, 2); + reportSensorF(log, fileFormat, "f: el delta", "v", engine->engineLoadAccelEnrichment.getMaxDelta(), 2); + reportSensorF(log, fileFormat, "f: el fuel", "v", engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F) * 100 / getMap(), 2); - reportSensorF(log, fileFormat, "tCharge", "K", engine->engineState.tChargeK, 2); + reportSensorF(log, fileFormat, "f: duty", "%", getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER), 2); } - if (engineConfiguration->hasCltSensor) { - reportSensorF(log, fileFormat, "CLT", "C", getCoolantTemperature(PASS_ENGINE_PARAMETER_F), 2); - } - - reportSensorF(log, fileFormat, "MAT", "C", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F), 2); // debugFloat(&logger, "tch", getTCharge1(tps), 2); @@ -237,6 +271,10 @@ static void printSensors(Logging *log, bool fileFormat) { reportSensorF(log, fileFormat, buf, "", getVoltage("fsio", engineConfiguration->fsioAdc[i]), 2); } } + + reportSensorI(log, fileFormat, "warn", "count", engine->engineState.warningCounter); + reportSensorI(log, fileFormat, "error", "code", engine->engineState.lastErrorCode); + } @@ -283,14 +321,6 @@ static void printState(void) { // debugFloat(&logger, "table_spark", getAdvance(rpm, getMaf()), 2); - float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F); - float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER); - debugFloat(&logger, "fuel_base", baseFuel, 2); - debugFloat(&logger, "fuel_lag", engine->engineState.injectorLag, 2); - debugFloat(&logger, "fuel", ENGINE(actualLastInjection), 2); - - debugFloat(&logger, "timing", engine->engineState.timingAdvance, 2); - // float map = getMap(); #endif /* EFI_SHAFT_POSITION_INPUT */ @@ -388,7 +418,7 @@ void updateDevConsoleState(Engine *engine) { #endif #if (EFI_PROD_CODE && HAL_USE_ADC) || defined(__DOXYGEN__) - printFullAdcReportIfNeeded(); + printFullAdcReportIfNeeded(&logger); #endif if (!fullLog) { @@ -592,9 +622,6 @@ static void lcdThread(void *arg) { #if EFI_TUNER_STUDIO || defined(__DOXYGEN__) -extern fuel_Map3D_t veMap; -extern afr_Map3D_t afrMap; - void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_S) { #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) int rpm = getRpmE(engine); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index e37eb16418..f2980477b2 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -196,7 +196,7 @@ public: * Total fuel with CLT, IAT and TPS acceleration corrections per cycle, * as squirt duration. * Without injector lag. - * @see baseFule + * @see baseFuel * @see actualLastInjection */ floatms_t runningFuel; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 6d16c7b53d..1205b85b3b 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -69,8 +69,7 @@ AdcDevice::AdcDevice(ADCConversionGroup* hwConfig) { #define ADC_FAST_DEVICE ADCD2 static int slowAdcCounter = 0; -static char LOGGING_BUFFER[500]; -static Logging logger("ADC", LOGGING_BUFFER, sizeof(LOGGING_BUFFER)); +static LoggingWithStorage logger("ADC"); // todo: move this flag to Engine god object static int adcDebugReporting = false; @@ -453,24 +452,24 @@ adc_channel_e AdcDevice::getAdcHardwareIndexByInternalIndex(int index) { return hardwareIndexByIndernalAdcIndex[index]; } -static void printFullAdcReport(void) { - scheduleMsg(&logger, "fast %d slow %d", fastAdc.conversionCount, slowAdc.conversionCount); +static void printFullAdcReport(Logging *logger) { + scheduleMsg(logger, "fast %d slow %d", fastAdc.conversionCount, slowAdc.conversionCount); for (int index = 0; index < slowAdc.size(); index++) { - appendMsgPrefix(&logger); + appendMsgPrefix(logger); adc_channel_e hwIndex = slowAdc.getAdcHardwareIndexByInternalIndex(index); ioportid_t port = getAdcChannelPort(hwIndex); int pin = getAdcChannelPin(hwIndex); int adcValue = slowAdc.getAdcValueByIndex(index); - appendPrintf(&logger, " ch%d %s%d", index, portname(port), pin); - appendPrintf(&logger, " ADC%d 12bit=%d", hwIndex, adcValue); + appendPrintf(logger, " ch%d %s%d", index, portname(port), pin); + appendPrintf(logger, " ADC%d 12bit=%d", hwIndex, adcValue); float volts = adcToVolts(adcValue); - appendPrintf(&logger, " v=%f", volts); + appendPrintf(logger, " v=%f", volts); - appendMsgPostfix(&logger); - scheduleLogging(&logger); + appendMsgPostfix(logger); + scheduleLogging(logger); } } @@ -603,16 +602,15 @@ void initAdcInputs(bool boardTestMode) { //if(slowAdcChannelCount > ADC_MAX_SLOW_CHANNELS_COUNT) // todo: do we need this logic? do we need this check addConsoleActionI("adc", (VoidInt) printAdcValue); - addConsoleAction("fadc", printFullAdcReport); #else printMsg(&logger, "ADC disabled"); #endif } -void printFullAdcReportIfNeeded(void) { +void printFullAdcReportIfNeeded(Logging *logger) { if (!adcDebugReporting) return; - printFullAdcReport(); + printFullAdcReport(logger); } #endif /* HAL_USE_ADC */ diff --git a/firmware/hw_layer/adc_inputs.h b/firmware/hw_layer/adc_inputs.h index b10d3d4aa9..101f29b638 100644 --- a/firmware/hw_layer/adc_inputs.h +++ b/firmware/hw_layer/adc_inputs.h @@ -24,7 +24,7 @@ void doSlowAdc(void); int getAdcHardwareIndexByInternalIndex(int index); -void printFullAdcReportIfNeeded(void); +void printFullAdcReportIfNeeded(Logging *log); int getInternalAdcValue(const char *msg, adc_channel_e index); float getMCUInternalTemperature(void); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index f48df63e11..e93c0cb7cb 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -300,7 +300,7 @@ void firmwareError(const char *errorMsg, ...) { } } -static char UNUSED_RAM_SIZE[700]; +static char UNUSED_RAM_SIZE[400]; static char UNUSED_CCM_SIZE[8500] CCM_OPTIONAL; @@ -309,5 +309,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20160906; + return 20160909; } diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 6f31db0830..0ebda68daf 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -38,7 +38,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20160826; + public static final int CONSOLE_VERSION = 20160909; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; diff --git a/java_console/ui/src/com/rusefi/SensorLogger.java b/java_console/ui/src/com/rusefi/SensorLogger.java index 6749baa186..a631f39e1b 100644 --- a/java_console/ui/src/com/rusefi/SensorLogger.java +++ b/java_console/ui/src/com/rusefi/SensorLogger.java @@ -16,26 +16,45 @@ public class SensorLogger { private static Sensor[] SENSORS = {Sensor.RPM, Sensor.INT_TEMP, - Sensor.CLT, Sensor.TPS, Sensor.VBATT, - Sensor.FUEL_BASE, - Sensor.T_CHARGE, - Sensor.DWELL, - Sensor.CURRENT_VE, - Sensor.deltaTps, - Sensor.engineLoadAccelDelta, - Sensor.tpsAccelFuel, - Sensor.Injector_duty, - Sensor.wallFuelAmount, - Sensor.iatCorrection, - Sensor.wallFuelCorrection, + + Sensor.CLT, + Sensor.TPS, + Sensor.VBATT, + Sensor.IAT, + Sensor.MAF, + Sensor.MAP, + Sensor.AFR, + Sensor.idlePosition, + Sensor.TARGET_AFR, - Sensor.CHARGE_AIR_MASS, + Sensor.T_CHARGE, + Sensor.CURRENT_VE, + Sensor.ENGINE_LOAD, + + Sensor.DWELL, + Sensor.TIMING, + + Sensor.FUEL_BASE, + + Sensor.deltaTps, + Sensor.tpsAccelFuel, + Sensor.engineLoadAccelDelta, + Sensor.Injector_duty, + + Sensor.wallFuelAmount, + Sensor.wallFuelCorrection, + + Sensor.iatCorrection, Sensor.cltCorrection, + + Sensor.CHARGE_AIR_MASS, Sensor.runningFuel, Sensor.injectorLagMs, + Sensor.VSS, Sensor.SPEED2RPM, + Sensor.debugFloatField1, Sensor.debugFloatField2, Sensor.debugFloatField3, @@ -44,12 +63,11 @@ public class SensorLogger { Sensor.debugIntField1, Sensor.debugIntField2, Sensor.debugIntField3, + Sensor.warningCounter, Sensor.lastErrorCode, - Sensor.MAF, - Sensor.MAP, - Sensor.IAT}; + }; private static long fileStartTime; private SensorLogger() {