diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index cb938abe34..010b57c97a 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -49,7 +49,7 @@ static EventListener consoleEventListener; static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) { char *p = line; - while (TRUE) { + while (true) { if (!isConsoleReady()) { // we better do not read from USB serial before it is ready chThdSleepMilliseconds(10); @@ -82,7 +82,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) #endif if (c < 0 || c == 4) { - return TRUE; + return true; } if (c == 8) { if (p != line) { diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index b45e67bd05..48e9879746 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -25,6 +25,7 @@ SimplePwm::SimplePwm() { void PwmConfig::baseConstructor() { memset(&scheduling, 0, sizeof(scheduling)); memset(&safe, 0, sizeof(safe)); + dbgNestingLevel = 0; scheduling.name = "PwmConfig"; periodNt = NAN; memset(&outputPins, 0, sizeof(outputPins)); @@ -107,7 +108,7 @@ static efitimeus_t togglePwmState(PwmConfig *state) { /** * NaN period means PWM is paused */ - return MS2US(1); + return getTimeNowUs() + MS2US(100); } state->handleCycleStart(); @@ -150,8 +151,12 @@ static efitimeus_t togglePwmState(PwmConfig *state) { * Main PWM loop: toggle pin & schedule next invocation */ static void timerCallback(PwmConfig *state) { + state->dbgNestingLevel++; + efiAssertVoid(state->dbgNestingLevel < 25, "PWM nesting issue"); + efitimeus_t switchTimeUs = togglePwmState(state); scheduleByTime("pwm", &state->scheduling, switchTimeUs, (schfunc_t) timerCallback, state); + state->dbgNestingLevel--; } /** diff --git a/firmware/controllers/system/pwm_generator_logic.h b/firmware/controllers/system/pwm_generator_logic.h index 1ee6d927de..6f0a1ae602 100644 --- a/firmware/controllers/system/pwm_generator_logic.h +++ b/firmware/controllers/system/pwm_generator_logic.h @@ -63,6 +63,8 @@ public: */ float periodNt; + int dbgNestingLevel; + scheduling_s scheduling; pwm_config_safe_state_s safe; @@ -77,7 +79,7 @@ public: pwm_cycle_callback *cycleCallback; /** - * this main callback is invoked when it's time to switch level on amy of the output channels + * this main callback is invoked when it's time to switch level on any of the output channels */ pwm_gen_callback *stateChangeCallback; }; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 733545f10e..125f31d0fd 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -117,7 +117,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now eventCount[triggerWheel]++; eventCountExt[signal]++; - int isLessImportant = (TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP) + bool_t isLessImportant = (TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP) || (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN); uint64_t currentDurationLong = getCurrentGapDuration(nowNt); diff --git a/firmware/util/cli_registry.cpp b/firmware/util/cli_registry.cpp index eebc427fda..2647a4924c 100644 --- a/firmware/util/cli_registry.cpp +++ b/firmware/util/cli_registry.cpp @@ -429,8 +429,11 @@ char *validateSecureLine(char *line) { } static char confirmation[200]; +static char handleBuffer[200]; -static bool handleConsoleLineInternal(char *line, int lineLength) { +static bool handleConsoleLineInternal(const char *commandLine, int lineLength) { + strncpy(handleBuffer, commandLine, sizeof(handleBuffer)); + char *line = handleBuffer; int firstTokenLength = tokenLength(line); // print("processing [%s] with %d actions\r\n", line, consoleActionCount); @@ -497,6 +500,8 @@ void handleConsoleLine(char *line) { bool isKnownComman = handleConsoleLineInternal(line, lineLength); - if (!isKnownComman) + if (!isKnownComman) { + scheduleMsg(logging, "unknown [%s]", line); helpCommand(); + } }