extracting runtime state from trigger central

This commit is contained in:
rusefillc 2021-01-31 22:41:17 -05:00
parent 869e4cfc49
commit 4bb9762e2e
7 changed files with 82 additions and 55 deletions

View File

@ -7,6 +7,7 @@ CONTROLLERS_ALGO_SRC_CPP = $(PROJECT_DIR)/controllers/algo/advance_map.cpp \
$(PROJECT_DIR)/controllers/algo/accel_enrichment.cpp \
$(PROJECT_DIR)/controllers/algo/launch_control.cpp \
$(PROJECT_DIR)/controllers/algo/dynoview.cpp \
$(PROJECT_DIR)/controllers/algo/runtime_state.cpp \
$(PROJECT_DIR)/controllers/algo/engine_configuration.cpp \
$(PROJECT_DIR)/controllers/algo/engine.cpp \
$(PROJECT_DIR)/controllers/algo/engine2.cpp \

View File

@ -0,0 +1,69 @@
/*
* runtime_state.cpp
*
* Created on: Jan 31, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#include "global.h"
#include "runtime_state.h"
// todo: revive implementation! we shall measure how far is actual execution timestamp from desired execution timestamp
uint32_t maxSchedulingPrecisionLoss = 0;
extern uint32_t hipLastExecutionCount;
extern uint32_t maxLockedDuration;
extern uint32_t maxEventCallbackDuration;
extern uint32_t triggerMaxDuration;
extern int perSecondIrqDuration;
extern int perSecondIrqCounter;
#if EFI_PROD_CODE
extern uint32_t maxPrecisionCallbackDuration;
#endif /* EFI_PROD_CODE */
extern uint32_t maxSchedulingPrecisionLoss;
extern uint32_t *cyccnt;
void resetMaxValues() {
#if EFI_PROD_CODE || EFI_SIMULATOR
maxEventCallbackDuration = triggerMaxDuration = 0;
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
maxSchedulingPrecisionLoss = 0;
#if EFI_CLOCK_LOCKS
maxLockedDuration = 0;
#endif /* EFI_CLOCK_LOCKS */
#if EFI_PROD_CODE
maxPrecisionCallbackDuration = 0;
#endif /* EFI_PROD_CODE */
}
extern LoggingWithStorage sharedLogger;
void printRuntimeStats(void) {
Logging *logger = &sharedLogger;
scheduleMsg(logger, "maxSchedulingPrecisionLoss=%d", maxSchedulingPrecisionLoss);
#if EFI_CLOCK_LOCKS
scheduleMsg(logger, "maxLockedDuration=%d / maxTriggerReentraint=%d", maxLockedDuration, maxTriggerReentraint);
scheduleMsg(logger, "perSecondIrqDuration=%d ticks / perSecondIrqCounter=%d", perSecondIrqDuration, perSecondIrqCounter);
scheduleMsg(logger, "IRQ CPU utilization %f%%", perSecondIrqDuration / (float)CORE_CLOCK * 100);
#endif /* EFI_CLOCK_LOCKS */
scheduleMsg(logger, "maxEventCallbackDuration=%d", maxEventCallbackDuration);
#if EFI_HIP_9011
scheduleMsg(logger, "hipLastExecutionCount=%d", hipLastExecutionCount);
#endif /* EFI_HIP_9011 */
}

View File

@ -0,0 +1,10 @@
/*
* runtime_state.h
*
* Created on: Jan 31, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#pragma once
void resetMaxValues();

View File

@ -20,6 +20,7 @@
#include "tunerstudio.h"
#endif
#include "runtime_state.h"
#include "engine_controller.h"
@ -92,9 +93,7 @@ void writeToFlashNow(void) {
}
assertEngineReference();
#if EFI_SHAFT_POSITION_INPUT
resetMaxValues();
#endif
}
static bool isValidCrc(persistent_config_container_s *state) {

View File

@ -23,8 +23,6 @@ extern int timeNowUs;
extern bool verboseMode;
#endif /* EFI_UNIT_TEST */
uint32_t maxSchedulingPrecisionLoss = 0;
/**
* @return true if inserted into the head of the list

View File

@ -348,8 +348,7 @@ void hwHandleShaftSignal(trigger_event_e signal, efitick_t timestamp) {
triggerReentraint--;
triggerDuration = getTimeNowLowerNt() - triggerHandlerEntryTime;
if (triggerDuration > triggerMaxDuration)
triggerMaxDuration = triggerDuration;
triggerMaxDuration = maxI(triggerMaxDuration, triggerDuration);
}
#endif /* EFI_PROD_CODE */
@ -562,37 +561,6 @@ static void triggerShapeInfo(void) {
extern PwmConfig triggerSignal;
#endif /* #if EFI_PROD_CODE */
extern uint32_t hipLastExecutionCount;
extern uint32_t maxLockedDuration;
extern uint32_t maxEventCallbackDuration;
extern int perSecondIrqDuration;
extern int perSecondIrqCounter;
#if EFI_PROD_CODE
extern uint32_t maxPrecisionCallbackDuration;
#endif /* EFI_PROD_CODE */
extern uint32_t maxSchedulingPrecisionLoss;
extern uint32_t *cyccnt;
void resetMaxValues() {
#if EFI_PROD_CODE || EFI_SIMULATOR
maxEventCallbackDuration = triggerMaxDuration = 0;
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
maxSchedulingPrecisionLoss = 0;
#if EFI_CLOCK_LOCKS
maxLockedDuration = 0;
#endif /* EFI_CLOCK_LOCKS */
#if EFI_PROD_CODE
maxPrecisionCallbackDuration = 0;
#endif /* EFI_PROD_CODE */
}
#if HAL_USE_ICU == TRUE
extern int icuRisingCallbackCounter;
extern int icuFallingCallbackCounter;
@ -681,25 +649,8 @@ void triggerInfo(void) {
scheduleMsg(logger, "primary logic input: %s", hwPortname(CONFIG(logicAnalyzerPins)[0]));
scheduleMsg(logger, "secondary logic input: %s", hwPortname(CONFIG(logicAnalyzerPins)[1]));
scheduleMsg(logger, "maxSchedulingPrecisionLoss=%d", maxSchedulingPrecisionLoss);
#if EFI_CLOCK_LOCKS
scheduleMsg(logger, "maxLockedDuration=%d / maxTriggerReentraint=%d", maxLockedDuration, maxTriggerReentraint);
scheduleMsg(logger, "perSecondIrqDuration=%d ticks / perSecondIrqCounter=%d", perSecondIrqDuration, perSecondIrqCounter);
scheduleMsg(logger, "IRQ CPU utilization %f%%", perSecondIrqDuration / (float)CORE_CLOCK * 100);
#endif /* EFI_CLOCK_LOCKS */
scheduleMsg(logger, "maxEventCallbackDuration=%d", maxEventCallbackDuration);
#if EFI_HIP_9011
scheduleMsg(logger, "hipLastExecutionCount=%d", hipLastExecutionCount);
#endif /* EFI_HIP_9011 */
scheduleMsg(logger, "totalTriggerHandlerMaxTime=%d", triggerMaxDuration);
scheduleMsg(logger, "maxPrecisionCallbackDuration=%d", maxPrecisionCallbackDuration);
resetMaxValues();
#endif /* EFI_PROD_CODE */
}

View File

@ -88,7 +88,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp, int index
void initTriggerCentral(Logging *sharedLogger);
int isSignalDecoderError(void);
void resetMaxValues();
void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);