only:stronger stack shortage response
This commit is contained in:
parent
bc2a2b9ab9
commit
256e25a452
|
@ -457,7 +457,7 @@ bool TunerStudio::handlePlainCommand(TsChannelBase* tsChannel, uint8_t command)
|
||||||
TunerStudio tsInstance;
|
TunerStudio tsInstance;
|
||||||
|
|
||||||
static int tsProcessOne(TsChannelBase* tsChannel) {
|
static int tsProcessOne(TsChannelBase* tsChannel) {
|
||||||
validateStack("communication", ObdCode::STACK_USAGE_COMMUNICATION, EXPECTED_REMAINING_STACK);
|
assertStack("communication", ObdCode::STACK_USAGE_COMMUNICATION, EXPECTED_REMAINING_STACK, -1);
|
||||||
|
|
||||||
if (!tsChannel->isReady()) {
|
if (!tsChannel->isReady()) {
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(10);
|
||||||
|
|
|
@ -142,13 +142,6 @@ static void sayHello() {
|
||||||
chThdSleepMilliseconds(5);
|
chThdSleepMilliseconds(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateStack(const char*msg, ObdCode code, int desiredStackUnusedSize) {
|
|
||||||
int unusedStack = getCurrentRemainingStack();
|
|
||||||
if (unusedStack < desiredStackUnusedSize) {
|
|
||||||
warning(code, "Stack low on %s: %d", msg, unusedStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
#if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
||||||
int CountFreeStackSpace(const void* wabase) {
|
int CountFreeStackSpace(const void* wabase) {
|
||||||
const uint8_t* stackBase = reinterpret_cast<const uint8_t*>(wabase);
|
const uint8_t* stackBase = reinterpret_cast<const uint8_t*>(wabase);
|
||||||
|
|
|
@ -283,7 +283,7 @@ private:
|
||||||
UNUSED(nowNt);
|
UNUSED(nowNt);
|
||||||
setPeriod(50 /* ms */);
|
setPeriod(50 /* ms */);
|
||||||
|
|
||||||
validateStack("Bench", ObdCode::STACK_USAGE_BENCH, EXPECTED_REMAINING_STACK);
|
assertStackVoid("Bench", ObdCode::STACK_USAGE_BENCH, EXPECTED_REMAINING_STACK);
|
||||||
|
|
||||||
// naive inter-thread communication - waiting for a flag
|
// naive inter-thread communication - waiting for a flag
|
||||||
if (isBenchTestPending) {
|
if (isBenchTestPending) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ private:
|
||||||
void PeriodicTask(efitick_t nowNt) override {
|
void PeriodicTask(efitick_t nowNt) override {
|
||||||
UNUSED(nowNt);
|
UNUSED(nowNt);
|
||||||
|
|
||||||
validateStack("MIL", ObdCode::STACK_USAGE_MIL, EXPECTED_REMAINING_STACK);
|
assertStackVoid("MIL", ObdCode::STACK_USAGE_MIL, EXPECTED_REMAINING_STACK);
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < MS2NT(500)) {
|
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < MS2NT(500)) {
|
||||||
enginePins.checkEnginePin.setValue(1);
|
enginePins.checkEnginePin.setValue(1);
|
||||||
|
|
|
@ -32,4 +32,6 @@
|
||||||
*/
|
*/
|
||||||
EXTERNC int getRemainingStack(thread_t *otp);
|
EXTERNC int getRemainingStack(thread_t *otp);
|
||||||
int CountFreeStackSpace(const void* wabase);
|
int CountFreeStackSpace(const void* wabase);
|
||||||
void validateStack(const char*msg, ObdCode code, int stackUnusedSize);
|
|
||||||
|
#define assertStackVoid(message, code, desiredAvailableStack) { if (getCurrentRemainingStack() < desiredAvailableStack) { firmwareError(code, "stack: %s", message); return; } }
|
||||||
|
#define assertStack(message, code, desiredAvailableStack, result) { if (getCurrentRemainingStack() < desiredAvailableStack) { firmwareError(code, "stack: %s", message); return result; } }
|
||||||
|
|
Loading…
Reference in New Issue