diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index e12cb629c1..3ede86b5eb 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -53,6 +53,7 @@ #include "engine.h" #include "lcd_controller.h" #include "settings.h" +#include "rusefi_outputs.h" #if EFI_PROD_CODE || defined(__DOXYGEN__) // todo: move this logic to algo folder! @@ -66,6 +67,9 @@ #endif extern engine_pins_s enginePins; +extern TriggerCentral triggerCentral; + +static bool_t subscription[(int) RO_LAST_ELEMENT]; // this 'true' value is needed for simulator static volatile bool fullLog = true; @@ -181,7 +185,8 @@ void printSensors(Logging *log, bool fileFormat, Engine *engine) { } -EXTERN_ENGINE; +EXTERN_ENGINE +; void writeLogLine(void) { #if EFI_FILE_LOGGING || defined(__DOXYGEN__) @@ -196,14 +201,17 @@ void writeLogLine(void) { #endif /* EFI_FILE_LOGGING */ } -void printState(Engine *engine, int currentCkpEventCounter) { +static void printState(Engine *engine) { #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) printSensors(&logger, false, engine); engine_configuration_s *engineConfiguration = engine->engineConfiguration; int rpm = getRpmE(engine); - debugInt(&logger, "ckp_c", currentCkpEventCounter); + if (subscription[(int) RO_TOTAL_REVOLUTION_COUNTER]) + debugInt(&logger, "ckp_c", getCrankEventCounter()); + if (subscription[(int) RO_RUNNING_REVOLUTION_COUNTER]) + debugInt(&logger, "ckp_r", triggerCentral.triggerState.runningRevolutionCounter); // debugInt(&logger, "idl", getIdleSwitch()); @@ -326,7 +334,7 @@ void updateDevConsoleState(Engine *engine) { prevCkpEventCounter = currentCkpEventCounter; - printState(engine, currentCkpEventCounter); + printState(engine); #if EFI_WAVE_ANALYZER printWave(&logger); @@ -550,6 +558,14 @@ static void tsStatusThread(Engine *engine) { } } +static void subscribe(int outputOrdinal) { + subscription[outputOrdinal] = true; +} + +static void unsubscribe(int outputOrdinal) { + subscription[outputOrdinal] = false; +} + void initStatusLoop(Engine *engine) { #if EFI_PROD_CODE || EFI_SIMULATOR initLoggingExt(&logger, "status loop", LOGGING_BUFFER, sizeof(LOGGING_BUFFER)); @@ -565,6 +581,16 @@ void initStatusLoop(Engine *engine) { addConsoleActionFFP("fuelinfo2", (VoidFloatFloatVoidPtr) showFuelInfo2, engine); addConsoleActionP("fuelinfo", (VoidPtr) showFuelInfo, engine); + subscription[(int) RO_TRG1_DUTY] = true; + subscription[(int) RO_TRG2_DUTY] = true; + subscription[(int) RO_TRG3_DUTY] = false; + subscription[(int) RO_TRG4_DUTY] = false; + subscription[(int) RO_TOTAL_REVOLUTION_COUNTER] = true; + subscription[(int) RO_RUNNING_REVOLUTION_COUNTER] = false; + + addConsoleActionI("subscribe", subscribe); + addConsoleActionI("unsubscribe", unsubscribe); + addConsoleAction("status", printStatus); #endif /* EFI_PROD_CODE */ diff --git a/firmware/console/status_loop.h b/firmware/console/status_loop.h index 7a962a5efd..cbc05c3faa 100644 --- a/firmware/console/status_loop.h +++ b/firmware/console/status_loop.h @@ -8,27 +8,13 @@ #ifndef CONSOLE_LOOP_H_ #define CONSOLE_LOOP_H_ -#ifdef __cplusplus #include "engine.h" + void updateDevConsoleState(Engine *engine); void printSensors(Engine *engine); -void printState(Engine *engine, int currentCkpEventCounter); void startStatusThreads(Engine *engine); void initStatusLoop(Engine *engine); - -#endif /* __cplusplus */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - void writeLogLine(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - bool getFullLog(void); void setFullLog(int value); diff --git a/firmware/controllers/algo/rusefi_outputs.h b/firmware/controllers/algo/rusefi_outputs.h new file mode 100644 index 0000000000..f3dbab1536 --- /dev/null +++ b/firmware/controllers/algo/rusefi_outputs.h @@ -0,0 +1,40 @@ +/** + * @file rusefi_outputs.h + * + * rusEfi output channels enum is needed for subscription/un-subscription + * + * @date Jan 17, 2015 + * @author Andrey Belomutskiy, (c) 2012-2014 + */ +#ifndef CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_ +#define CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_ + +/** + * this enum is part of the console protocol API, it should be in sync with ...java + */ + +/** + * For example, + * subscribe 10 + * unsubscribe 9 + */ + +typedef enum { + RO_TPS_ADC_VALUE = 0, + RO_MAF = 1, + RO_MAP = 2, + RO_TRG1_DUTY = 3, + RO_TRG2_DUTY = 4, + RO_TRG3_DUTY = 5, + RO_TRG4_DUTY = 6, + RO_INJECTOR_LAG = 7, + RO_VBATT = 8, + RO_TOTAL_REVOLUTION_COUNTER = 9, + RO_RUNNING_REVOLUTION_COUNTER = 10, + + RO_LAST_ELEMENT = 11 +} rusefi_output_e; + + + +#endif /* CONTROLLERS_ALGO_RUSEFI_OUTPUTS_H_ */ diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 10fded2c5f..0dae03d81d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -291,6 +291,10 @@ float getTriggerDutyCycle(int index) { return triggerCentral.triggerState.getTriggerDutyCycle(index); } +static void resetRunningTriggerCounter() { + triggerCentral.triggerState.runningRevolutionCounter = 0; +} + void initTriggerCentral(Logging *sharedLogger, Engine *engine) { logger = sharedLogger; strcpy((char*) shaft_signal_msg_index, "x_"); @@ -302,8 +306,11 @@ void initTriggerCentral(Logging *sharedLogger, Engine *engine) { #if EFI_PROD_CODE || EFI_SIMULATOR addConsoleActionP("triggerinfo", (VoidPtr) triggerInfo, engine); addConsoleActionP("triggershapeinfo", (VoidPtr) triggerShapeInfo, engine); + addConsoleAction("reset_running_trigger_counter", resetRunningTriggerCounter); #endif + + #if EFI_HISTOGRAMS initHistogram(&triggerCallback, "all callbacks"); #endif /* EFI_HISTOGRAMS */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 974783d749..0111f691a0 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -94,6 +94,7 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW startOfCycleNt = nowNt; \ clear(); \ totalRevolutionCounter++; \ + runningRevolutionCounter++; \ totalEventCountBase += TRIGGER_SHAPE(size); \ } diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 87d57adbac..eb41095b91 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -55,6 +55,7 @@ public: * index within trigger revolution, from 0 to trigger event count */ uint32_t current_index; + uint32_t runningRevolutionCounter; private: void clear(); /** diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index e0e1a2b228..e19adb3332 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -115,6 +115,7 @@ TriggerState::TriggerState() { toothed_previous_time = 0; toothed_previous_duration = 0; totalRevolutionCounter = 0; + runningRevolutionCounter = 0; totalTriggerErrorCounter = 0; clear(); memset(expectedTotalTime, 0, sizeof(expectedTotalTime)); diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 11c2739e52..0950a105dc 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -262,5 +262,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 20150116; + return 20150117; }