From 5c8a231ed6a14f6b12f930926002527a3f518e06 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 6 Jun 2021 17:43:22 +0200 Subject: [PATCH] Move autoreporting out of the temperature ISR Code running in the temperature ISR needs to be fully reentrant, which is hard to track down. Move autoreporting to the main processing loop. This can make the autoreporting slower or pause at times, but removes the reentrant restriction, which allows us to use printf_P. --- Firmware/Marlin_main.cpp | 50 +++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 92df0122..2e0fc270 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1727,6 +1727,32 @@ void serial_read_stream() { } } + +/** + * Output autoreport values according to features requested in M155 + */ +#if defined(AUTO_REPORT) +static void host_autoreport() +{ + if (autoReportFeatures.TimerExpired()) + { + if(autoReportFeatures.Temp()){ + gcode_M105(active_extruder); + } + if(autoReportFeatures.Pos()){ + gcode_M114(); + } +#if defined(AUTO_REPORT) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) + if(autoReportFeatures.Fans()){ + gcode_M123(); + } +#endif //AUTO_REPORT and (FANCHECK and TACH_0 or TACH_1) + autoReportFeatures.TimerStart(); + } +} +#endif //AUTO_REPORT + + /** * Output a "busy" message at regular intervals * while the machine is not accepting commands. @@ -1738,27 +1764,6 @@ void host_keepalive() { if (farm_mode) return; long ms = _millis(); -#if defined(AUTO_REPORT) - { - if (autoReportFeatures.TimerExpired()) - { - if(autoReportFeatures.Temp()){ - gcode_M105(active_extruder); - } - if(autoReportFeatures.Pos()){ - gcode_M114(); - } - #if defined(AUTO_REPORT) && (defined(FANCHECK) && (((defined(TACH_0) && (TACH_0 >-1)) || (defined(TACH_1) && (TACH_1 > -1))))) - if(autoReportFeatures.Fans()){ - gcode_M123(); - } -#endif //AUTO_REPORT and (FANCHECK and TACH_0 or TACH_1) - autoReportFeatures.TimerStart(); - } - } -#endif //AUTO_REPORT - - if (host_keepalive_interval && busy_state != NOT_BUSY) { if ((ms - prev_busy_signal_ms) < (long)(1000L * host_keepalive_interval)) return; switch (busy_state) { @@ -1918,6 +1923,9 @@ void loop() } #endif //TMC2130 mmu_loop(); +#if defined(AUTO_REPORT) + host_autoreport(); +#endif //AUTO_REPORT } #define DEFINE_PGM_READ_ANY(type, reader) \