diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-20 15:20:42 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-20 15:21:43 +0300 |
commit | 4dab8c62664b105aea0153baf487bd98dd7344bd (patch) | |
tree | a2273d8c87e0a2d16b54aa03cc1a513588a0907b | |
parent | 80adc441d72440b60e393ef700c81427d301f3d3 (diff) |
Fixed assertion error when tick ISR tries to turn off all heaters
-rw-r--r-- | src/Heating/Heat.cpp | 16 | ||||
-rw-r--r-- | src/Heating/Heat.h | 3 | ||||
-rw-r--r-- | src/Heating/Heater.h | 1 | ||||
-rw-r--r-- | src/Heating/LocalHeater.h | 1 | ||||
-rw-r--r-- | src/Heating/RemoteHeater.h | 1 | ||||
-rw-r--r-- | src/Platform/RepRap.cpp | 2 |
6 files changed, 22 insertions, 2 deletions
diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index a4759bd2..0ddb64b0 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -732,6 +732,22 @@ void Heat::SwitchOffAll(bool includingChamberAndBed) noexcept } } +// Turn off all local heaters. Safe to call from an ISR. Called only from the tick ISR. +void Heat::SwitchOffAllLocalFromISR() noexcept +{ + for (Heater* h : heaters) + { + if (h != nullptr +#if SUPPORT_CAN_EXPANSION + && h->IsLocal() +#endif + ) + { + h->SwitchOff(); + } + } +} + void Heat::Standby(int heater, const Tool *tool) noexcept { const auto h = FindHeater(heater); diff --git a/src/Heating/Heat.h b/src/Heating/Heat.h index 12ef77ed..2338c136 100644 --- a/src/Heating/Heat.h +++ b/src/Heating/Heat.h @@ -73,7 +73,8 @@ public: bool AllHeatersAtSetTemperatures(bool includingBed, float tolerance) const noexcept; // Is everything at temperature within tolerance? - void SwitchOffAll(bool includingChamberAndBed) noexcept; // Turn all heaters off + void SwitchOffAll(bool includingChamberAndBed) noexcept; // Turn all heaters off. Not safe to call from an ISR. + void SwitchOffAllLocalFromISR() noexcept; // Turn off all local heaters. Safe to call from an ISR. void SuspendHeaters(bool sus) noexcept; // Suspend the heaters to conserve power or while probing GCodeResult ResetFault(int heater, const StringRef& reply) noexcept; // Reset a heater fault for a specific heater or all heaters diff --git a/src/Heating/Heater.h b/src/Heating/Heater.h index c5b088b7..fea96985 100644 --- a/src/Heating/Heater.h +++ b/src/Heating/Heater.h @@ -50,6 +50,7 @@ public: virtual void FeedForwardAdjustment(float fanPwmChange, float extrusionChange) noexcept = 0; #if SUPPORT_CAN_EXPANSION + virtual bool IsLocal() const noexcept = 0; virtual void UpdateRemoteStatus(CanAddress src, const CanHeaterReport& report) noexcept = 0; virtual void UpdateHeaterTuning(CanAddress src, const CanMessageHeaterTuningReport& msg) noexcept = 0; #endif diff --git a/src/Heating/LocalHeater.h b/src/Heating/LocalHeater.h index d6ef0c99..4c4193d6 100644 --- a/src/Heating/LocalHeater.h +++ b/src/Heating/LocalHeater.h @@ -41,6 +41,7 @@ public: void FeedForwardAdjustment(float fanPwmChange, float extrusionChange) noexcept override; #if SUPPORT_CAN_EXPANSION + bool IsLocal() const noexcept override { return true; } void UpdateRemoteStatus(CanAddress src, const CanHeaterReport& report) noexcept override { } void UpdateHeaterTuning(CanAddress src, const CanMessageHeaterTuningReport& msg) noexcept override { } #endif diff --git a/src/Heating/RemoteHeater.h b/src/Heating/RemoteHeater.h index 0391426b..67bd8eb3 100644 --- a/src/Heating/RemoteHeater.h +++ b/src/Heating/RemoteHeater.h @@ -30,6 +30,7 @@ public: float GetAccumulator() const noexcept override; // Return the integral accumulator void Suspend(bool sus) noexcept override; // Suspend the heater to conserve power or while doing Z probing void FeedForwardAdjustment(float fanPwmChange, float extrusionChange) noexcept override; + bool IsLocal() const noexcept override { return false; } void UpdateRemoteStatus(CanAddress src, const CanHeaterReport& report) noexcept override; void UpdateHeaterTuning(CanAddress src, const CanMessageHeaterTuningReport& msg) noexcept override; diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp index 48ee430a..9137bb14 100644 --- a/src/Platform/RepRap.cpp +++ b/src/Platform/RepRap.cpp @@ -1287,7 +1287,7 @@ void RepRap::Tick() noexcept if (heatTaskStuck || ticksInSpinState >= MaxTicksInSpinState) // if we stall for 20 seconds, save diagnostic data and reset { stopped = true; - heat->SwitchOffAll(true); + heat->SwitchOffAllLocalFromISR(); // can't call SwitchOffAll because remote heaters can't be turned off from inside a ISR platform->EmergencyDisableDrivers(); // We now save the stack when we get stuck in a spin loop |