refactoring: reducing code duplication
This commit is contained in:
parent
4bba678dce
commit
46bdbf82d1
|
@ -155,7 +155,7 @@ bool stopTsPort(ts_channel_s *tsChannel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
|
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6570, getRemainingStack(chThdGetSelfX()) > 64, "tunerStudioWriteData");
|
efiAssertVoid(CUSTOM_ERR_6570, getCurrentRemainingStack() > 64, "tunerStudioWriteData");
|
||||||
#if EFI_SIMULATOR || defined(__DOXYGEN__)
|
#if EFI_SIMULATOR || defined(__DOXYGEN__)
|
||||||
logMsg("chSequentialStreamWrite [%d]\r\n", size);
|
logMsg("chSequentialStreamWrite [%d]\r\n", size);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -157,7 +157,7 @@ void runConsoleLoop(ts_channel_s *console) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6571, getRemainingStack(chThdGetSelfX()) > 256, "lowstck#9e");
|
efiAssertVoid(CUSTOM_ERR_6571, getCurrentRemainingStack() > 256, "lowstck#9e");
|
||||||
bool end = getConsoleLine((BaseSequentialStream*) console->channel, console->crcReadBuffer, sizeof(console->crcReadBuffer) - 3);
|
bool end = getConsoleLine((BaseSequentialStream*) console->channel, console->crcReadBuffer, sizeof(console->crcReadBuffer) - 3);
|
||||||
if (end) {
|
if (end) {
|
||||||
// firmware simulator is the only case when this happens
|
// firmware simulator is the only case when this happens
|
||||||
|
|
|
@ -1343,7 +1343,7 @@ void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
efiAssertVoid(CUSTOM_APPLY_STACK, getRemainingStack(chThdGetSelfX()) > 256, "apply c");
|
efiAssertVoid(CUSTOM_APPLY_STACK, getCurrentRemainingStack() > 256, "apply c");
|
||||||
scheduleMsg(logger, "applyNonPersistentConfiguration()");
|
scheduleMsg(logger, "applyNonPersistentConfiguration()");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ void LECalculator::push(le_action_e action, float value) {
|
||||||
*/
|
*/
|
||||||
bool LECalculator::processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
bool LECalculator::processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 64, "FSIO logic", false);
|
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 64, "FSIO logic", false);
|
||||||
#endif
|
#endif
|
||||||
switch (element->action) {
|
switch (element->action) {
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ static void invokePerSecond(void) {
|
||||||
|
|
||||||
static void periodicSlowCallback(Engine *engine) {
|
static void periodicSlowCallback(Engine *engine) {
|
||||||
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
|
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
|
||||||
efiAssertVoid(CUSTOM_ERR_6661, getRemainingStack(chThdGetSelfX()) > 64, "lowStckOnEv");
|
efiAssertVoid(CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
/**
|
/**
|
||||||
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
||||||
|
|
|
@ -130,7 +130,7 @@ static persisted_configuration_state_e doReadConfiguration(flashaddr_t address,
|
||||||
* connectivity so no console output here
|
* connectivity so no console output here
|
||||||
*/
|
*/
|
||||||
persisted_configuration_state_e readConfiguration(Logging * logger) {
|
persisted_configuration_state_e readConfiguration(Logging * logger) {
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 256, "read f", PC_ERROR);
|
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 256, "read f", PC_ERROR);
|
||||||
persisted_configuration_state_e result = doReadConfiguration(FLASH_ADDR, logger);
|
persisted_configuration_state_e result = doReadConfiguration(FLASH_ADDR, logger);
|
||||||
if (result != PC_OK) {
|
if (result != PC_OK) {
|
||||||
printMsg(logger, "Reading second configuration copy");
|
printMsg(logger, "Reading second configuration copy");
|
||||||
|
|
|
@ -109,7 +109,7 @@ static bool isAveraging = false;
|
||||||
|
|
||||||
static void startAveraging(void *arg) {
|
static void startAveraging(void *arg) {
|
||||||
(void) arg;
|
(void) arg;
|
||||||
efiAssertVoid(CUSTOM_ERR_6649, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#9");
|
efiAssertVoid(CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9");
|
||||||
bool wasLocked = lockAnyContext();
|
bool wasLocked = lockAnyContext();
|
||||||
;
|
;
|
||||||
// with locking we would have a consistent state
|
// with locking we would have a consistent state
|
||||||
|
@ -135,7 +135,7 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
|
||||||
|
|
||||||
/* Calculates the average values from the ADC samples.*/
|
/* Calculates the average values from the ADC samples.*/
|
||||||
measurementsPerRevolutionCounter++;
|
measurementsPerRevolutionCounter++;
|
||||||
efiAssertVoid(CUSTOM_ERR_6650, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#9a");
|
efiAssertVoid(CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
|
||||||
|
|
||||||
#if (EFI_SENSOR_CHART && EFI_ANALOG_SENSORS) || defined(__DOXYGEN__)
|
#if (EFI_SENSOR_CHART && EFI_ANALOG_SENSORS) || defined(__DOXYGEN__)
|
||||||
if (ENGINE(sensorChartMode) == SC_MAP) {
|
if (ENGINE(sensorChartMode) == SC_MAP) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ uint32_t lastExecutionCount;
|
||||||
|
|
||||||
static void executorCallback(void *arg) {
|
static void executorCallback(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
efiAssertVoid(CUSTOM_ERR_6624, getRemainingStack(chThdGetSelfX()) > 256, "lowstck#2y");
|
efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > 256, "lowstck#2y");
|
||||||
|
|
||||||
// callbackTime = getTimeNowNt();
|
// callbackTime = getTimeNowNt();
|
||||||
// if((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) {
|
// if((callbackTime > nextEventTimeNt) && (callbackTime - nextEventTimeNt > US2NT(5000))) {
|
||||||
|
|
|
@ -404,7 +404,7 @@ void TriggerShape::setSecondTriggerSynchronizationGap(float syncRatio) {
|
||||||
void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e operationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig) {
|
void TriggerShape::initializeTriggerShape(Logging *logger, operation_mode_e operationMode, bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig) {
|
||||||
|
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
efiAssertVoid(CUSTOM_ERR_6641, getRemainingStack(chThdGetSelfX()) > 256, "init t");
|
efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > 256, "init t");
|
||||||
scheduleMsg(logger, "initializeTriggerShape(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type);
|
scheduleMsg(logger, "initializeTriggerShape(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,6 @@
|
||||||
#include <nvic.h>
|
#include <nvic.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!EFI_PROD_CODE && !EFI_SIMULATOR) || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
#define chThdGetSelfX() 0
|
|
||||||
#define getRemainingStack(x) (999999)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
|
#if (EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
#include "main_trigger_callback.h"
|
#include "main_trigger_callback.h"
|
||||||
|
@ -373,7 +366,7 @@ static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
|
|
||||||
static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
static ALWAYS_INLINE void handleFuel(const bool limitedFuel, uint32_t trgEventIndex, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6627, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#3");
|
efiAssertVoid(CUSTOM_ERR_6627, getCurrentRemainingStack() > 128, "lowstck#3");
|
||||||
efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < engine->engineCycleEventCount, "handleFuel/event index");
|
efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < engine->engineCycleEventCount, "handleFuel/event index");
|
||||||
|
|
||||||
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE) || limitedFuel) {
|
if (!isInjectionEnabled(PASS_ENGINE_PARAMETER_SIGNATURE) || limitedFuel) {
|
||||||
|
@ -446,7 +439,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
efiAssertVoid(CUSTOM_ERR_6629, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#2");
|
efiAssertVoid(CUSTOM_ERR_6629, getCurrentRemainingStack() > 128, "lowstck#2");
|
||||||
|
|
||||||
if (trgEventIndex >= ENGINE(engineCycleEventCount)) {
|
if (trgEventIndex >= ENGINE(engineCycleEventCount)) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -228,7 +228,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
|
||||||
uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
uint32_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
efitick_t nowNt = getTimeNowNt();
|
efitick_t nowNt = getTimeNowNt();
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
efiAssertVoid(CUSTOM_ERR_6632, getRemainingStack(chThdGetSelfX()) > 256, "lowstckRCL");
|
efiAssertVoid(CUSTOM_ERR_6632, getCurrentRemainingStack() > 256, "lowstckRCL");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RpmCalculator *rpmState = &engine->rpmCalculator;
|
RpmCalculator *rpmState = &engine->rpmCalculator;
|
||||||
|
|
|
@ -198,7 +198,7 @@ void hwHandleShaftSignal(trigger_event_e signal) {
|
||||||
if (triggerReentraint > maxTriggerReentraint)
|
if (triggerReentraint > maxTriggerReentraint)
|
||||||
maxTriggerReentraint = triggerReentraint;
|
maxTriggerReentraint = triggerReentraint;
|
||||||
triggerReentraint++;
|
triggerReentraint++;
|
||||||
efiAssertVoid(CUSTOM_ERR_6636, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#8");
|
efiAssertVoid(CUSTOM_ERR_6636, getCurrentRemainingStack() > 128, "lowstck#8");
|
||||||
engine->triggerCentral.handleShaftSignal(signal PASS_ENGINE_PARAMETER_SUFFIX);
|
engine->triggerCentral.handleShaftSignal(signal PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
triggerReentraint--;
|
triggerReentraint--;
|
||||||
triggerDuration = GET_TIMESTAMP() - triggerHandlerEntryTime;
|
triggerDuration = GET_TIMESTAMP() - triggerHandlerEntryTime;
|
||||||
|
|
|
@ -107,7 +107,7 @@ bool isTriggerDecoderError(void) {
|
||||||
|
|
||||||
void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
efiAssertVoid(CUSTOM_ERR_6642, getRemainingStack(chThdGetSelfX()) > 256, "calc s");
|
efiAssertVoid(CUSTOM_ERR_6642, getCurrentRemainingStack() > 256, "calc s");
|
||||||
#endif
|
#endif
|
||||||
trigger_config_s const*triggerConfig = &engineConfiguration->trigger;
|
trigger_config_s const*triggerConfig = &engineConfiguration->trigger;
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape,
|
||||||
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
UNUSED(triggerConfig);
|
UNUSED(triggerConfig);
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 128, "findPos", -1);
|
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
|
||||||
#endif
|
#endif
|
||||||
errorDetection.clear();
|
errorDetection.clear();
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, state != NULL, "NULL state", -1);
|
efiAssert(CUSTOM_ERR_ASSERT, state != NULL, "NULL state", -1);
|
||||||
|
|
|
@ -172,7 +172,7 @@ void WaveChart::addEvent3(const char *name, const char * msg) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6651, name!=NULL, "WC: NULL name");
|
efiAssertVoid(CUSTOM_ERR_6651, name!=NULL, "WC: NULL name");
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
efiAssertVoid(CUSTOM_ERR_6652, getRemainingStack(chThdGetSelfX()) > 32, "lowstck#2c");
|
efiAssertVoid(CUSTOM_ERR_6652, getCurrentRemainingStack() > 32, "lowstck#2c");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_ERR_6653, isInitialized, "chart not initialized");
|
efiAssertVoid(CUSTOM_ERR_6653, isInitialized, "chart not initialized");
|
||||||
|
|
|
@ -103,6 +103,8 @@ typedef unsigned int time_t;
|
||||||
turnAllPinsOff(); \
|
turnAllPinsOff(); \
|
||||||
enginePins.communicationLedPin.setValue(1);
|
enginePins.communicationLedPin.setValue(1);
|
||||||
|
|
||||||
|
#define getCurrentRemainingStack() getRemainingStack(chThdGetSelfX())
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stack debugging
|
* Stack debugging
|
||||||
* See also getMaxUsedStack()
|
* See also getMaxUsedStack()
|
||||||
|
|
|
@ -174,7 +174,7 @@ AdcDevice fastAdc(&adcgrpcfg_fast);
|
||||||
|
|
||||||
void doSlowAdc(void) {
|
void doSlowAdc(void) {
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_ERR_6658, getRemainingStack(chThdGetSelfX())> 32, "lwStAdcSlow");
|
efiAssertVoid(CUSTOM_ERR_6658, getCurrentRemainingStack()> 32, "lwStAdcSlow");
|
||||||
|
|
||||||
#if EFI_INTERNAL_ADC
|
#if EFI_INTERNAL_ADC
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ static void pwmpcb_slow(PWMDriver *pwmp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pwmpcb_fast(PWMDriver *pwmp) {
|
static void pwmpcb_fast(PWMDriver *pwmp) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6659, getRemainingStack(chThdGetSelfX())> 32, "lwStAdcFast");
|
efiAssertVoid(CUSTOM_ERR_6659, getCurrentRemainingStack()> 32, "lwStAdcFast");
|
||||||
#if EFI_INTERNAL_ADC
|
#if EFI_INTERNAL_ADC
|
||||||
(void) pwmp;
|
(void) pwmp;
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ int getSlowAdcCounter() {
|
||||||
static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
||||||
(void) buffer;
|
(void) buffer;
|
||||||
(void) n;
|
(void) n;
|
||||||
efiAssertVoid(CUSTOM_ERR_6671, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#9c");
|
efiAssertVoid(CUSTOM_ERR_6671, getCurrentRemainingStack() > 128, "lowstck#9c");
|
||||||
/* Note, only in the ADC_COMPLETE state because the ADC driver fires
|
/* Note, only in the ADC_COMPLETE state because the ADC driver fires
|
||||||
* an intermediate callback when the buffer is half full. */
|
* an intermediate callback when the buffer is half full. */
|
||||||
if (adcp->state == ADC_COMPLETE) {
|
if (adcp->state == ADC_COMPLETE) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool rtcWorks = true;
|
||||||
* Only one consumer can use SPI bus at a given time
|
* Only one consumer can use SPI bus at a given time
|
||||||
*/
|
*/
|
||||||
void lockSpi(spi_device_e device) {
|
void lockSpi(spi_device_e device) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6674, getRemainingStack(chThdGetSelfX()) > 128, "lockSpi");
|
efiAssertVoid(CUSTOM_ERR_6674, getCurrentRemainingStack() > 128, "lockSpi");
|
||||||
// todo: different locks for different SPI devices!
|
// todo: different locks for different SPI devices!
|
||||||
chMtxLock(&spiMtx);
|
chMtxLock(&spiMtx);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ void adc_callback_fast(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
||||||
/**
|
/**
|
||||||
* this callback is executed 10 000 times a second, it needs to be as fast as possible
|
* this callback is executed 10 000 times a second, it needs to be as fast as possible
|
||||||
*/
|
*/
|
||||||
efiAssertVoid(CUSTOM_ERR_6676, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#9b");
|
efiAssertVoid(CUSTOM_ERR_6676, getCurrentRemainingStack() > 128, "lowstck#9b");
|
||||||
|
|
||||||
#if EFI_MAP_AVERAGING
|
#if EFI_MAP_AVERAGING
|
||||||
mapAveragingAdcCallback(fastAdc.samples[fastMapSampleIndex]);
|
mapAveragingAdcCallback(fastAdc.samples[fastMapSampleIndex]);
|
||||||
|
@ -325,7 +325,7 @@ void showBor(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initHardware(Logging *l) {
|
void initHardware(Logging *l) {
|
||||||
efiAssertVoid(CUSTOM_IH_STACK, getRemainingStack(chThdGetSelfX()) > 256, "init h");
|
efiAssertVoid(CUSTOM_IH_STACK, getCurrentRemainingStack() > 256, "init h");
|
||||||
sharedLogger = l;
|
sharedLogger = l;
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr;
|
engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr;
|
||||||
efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration");
|
efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration");
|
||||||
|
|
|
@ -161,7 +161,7 @@ static void scheduleReboot(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void runRusEfi(void) {
|
void runRusEfi(void) {
|
||||||
efiAssertVoid(CUSTOM_RM_STACK_1, getRemainingStack(chThdGetSelfX()) > 512, "init s");
|
efiAssertVoid(CUSTOM_RM_STACK_1, getCurrentRemainingStack() > 512, "init s");
|
||||||
assertEngineReference();
|
assertEngineReference();
|
||||||
engine->setConfig(config);
|
engine->setConfig(config);
|
||||||
initIntermediateLoggingBuffer();
|
initIntermediateLoggingBuffer();
|
||||||
|
@ -233,7 +233,7 @@ void runRusEfi(void) {
|
||||||
* control is around main_trigger_callback
|
* control is around main_trigger_callback
|
||||||
*/
|
*/
|
||||||
while (true) {
|
while (true) {
|
||||||
efiAssertVoid(CUSTOM_RM_STACK, getRemainingStack(chThdGetSelfX()) > 128, "stack#1");
|
efiAssertVoid(CUSTOM_RM_STACK, getCurrentRemainingStack() > 128, "stack#1");
|
||||||
|
|
||||||
#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
|
#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
|
||||||
// sensor state + all pending messages for our own dev console
|
// sensor state + all pending messages for our own dev console
|
||||||
|
|
|
@ -100,7 +100,7 @@ static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
intermediateLoggingBuffer.eos = 0; // reset
|
intermediateLoggingBuffer.eos = 0; // reset
|
||||||
efiAssertVoid(CUSTOM_ERR_6603, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#1b");
|
efiAssertVoid(CUSTOM_ERR_6603, getCurrentRemainingStack() > 128, "lowstck#1b");
|
||||||
chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg);
|
chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg);
|
||||||
intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly
|
intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly
|
||||||
logging->append((char *)intermediateLoggingBuffer.buffer);
|
logging->append((char *)intermediateLoggingBuffer.buffer);
|
||||||
|
@ -110,7 +110,7 @@ static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
|
||||||
* this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream
|
* this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream
|
||||||
*/
|
*/
|
||||||
void Logging::vappendPrintf(const char *fmt, va_list arg) {
|
void Logging::vappendPrintf(const char *fmt, va_list arg) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6604, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5b");
|
efiAssertVoid(CUSTOM_ERR_6604, getCurrentRemainingStack() > 128, "lowstck#5b");
|
||||||
int wasLocked = lockAnyContext();
|
int wasLocked = lockAnyContext();
|
||||||
vappendPrintfI(this, fmt, arg);
|
vappendPrintfI(this, fmt, arg);
|
||||||
if (!wasLocked) {
|
if (!wasLocked) {
|
||||||
|
@ -120,7 +120,7 @@ void Logging::vappendPrintf(const char *fmt, va_list arg) {
|
||||||
|
|
||||||
// todo: replace with logging->appendPrintf
|
// todo: replace with logging->appendPrintf
|
||||||
void appendPrintf(Logging *logging, const char *fmt, ...) {
|
void appendPrintf(Logging *logging, const char *fmt, ...) {
|
||||||
efiAssertVoid(CUSTOM_APPEND_STACK, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
efiAssertVoid(CUSTOM_APPEND_STACK, getCurrentRemainingStack() > 128, "lowstck#4");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
logging->vappendPrintf(fmt, ap);
|
logging->vappendPrintf(fmt, ap);
|
||||||
|
@ -128,7 +128,7 @@ void appendPrintf(Logging *logging, const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logging::appendPrintf(const char *fmt, ...) {
|
void Logging::appendPrintf(const char *fmt, ...) {
|
||||||
efiAssertVoid(CUSTOM_APPEND_STACK, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
efiAssertVoid(CUSTOM_APPEND_STACK, getCurrentRemainingStack() > 128, "lowstck#4");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vappendPrintf(fmt, ap);
|
vappendPrintf(fmt, ap);
|
||||||
|
@ -250,7 +250,7 @@ void resetLogging(Logging *logging) {
|
||||||
* This method should only be invoked on main thread because only the main thread can write to the console
|
* This method should only be invoked on main thread because only the main thread can write to the console
|
||||||
*/
|
*/
|
||||||
void printMsg(Logging *logger, const char *fmt, ...) {
|
void printMsg(Logging *logger, const char *fmt, ...) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6605, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5o");
|
efiAssertVoid(CUSTOM_ERR_6605, getCurrentRemainingStack() > 128, "lowstck#5o");
|
||||||
// resetLogging(logging); // I guess 'reset' is not needed here?
|
// resetLogging(logging); // I guess 'reset' is not needed here?
|
||||||
appendMsgPrefix(logger);
|
appendMsgPrefix(logger);
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,8 @@ extern "C"
|
||||||
|
|
||||||
void printToConsole(char *p);
|
void printToConsole(char *p);
|
||||||
|
|
||||||
|
#define getCurrentRemainingStack() getRemainingStack(chThdGetSelfX())
|
||||||
|
|
||||||
int getRemainingStack(thread_t *otp);
|
int getRemainingStack(thread_t *otp);
|
||||||
|
|
||||||
// todo: move somewhere else?
|
// todo: move somewhere else?
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
#include "boards.h"
|
#include "boards.h"
|
||||||
|
|
||||||
|
//#define chThdGetSelfX() 0
|
||||||
|
//#define getRemainingStack(x) (999999)
|
||||||
|
#define getCurrentRemainingStack() (999999)
|
||||||
|
|
||||||
// this is needed by all DECLARE_ENGINE_PARAMETER_* usages
|
// this is needed by all DECLARE_ENGINE_PARAMETER_* usages
|
||||||
#include "engine_configuration_generated_structures.h"
|
#include "engine_configuration_generated_structures.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue