소스 검색

Fix kill => disable_all_heaters => print_job_timer.stop (#12146)

- Remove `print_job_timer.stop()` from `disable_all_heaters`
- Call `print_job_timer.stop()` for relevant `disable_all_heaters()`.
- Split up `kill()` for watchdog interrupt safety
Marcio Teixeira 6 년 전
부모
커밋
71e19baf69

+ 2
- 3
Marlin/src/HAL/HAL_AVR/watchdog_AVR.cpp 파일 보기

63
   ISR(WDT_vect) {
63
   ISR(WDT_vect) {
64
     sei();  // With the interrupt driven serial we need to allow interrupts.
64
     sei();  // With the interrupt driven serial we need to allow interrupts.
65
     SERIAL_ERROR_START();
65
     SERIAL_ERROR_START();
66
-    SERIAL_ERRORLNPGM("Watchdog barked, please turn off the printer.");
67
-    kill(PSTR("ERR:Watchdog")); //kill blocks //up to 16 characters so it fits on a 16x2 display
68
-    while (1); //wait for user or serial reset
66
+    SERIAL_ERRORLNPGM(MSG_WATCHDOG_FIRED);
67
+    minkill();  // interrupt-safe final kill and infinite loop
69
   }
68
   }
70
 #endif // WATCHDOG_RESET_MANUAL
69
 #endif // WATCHDOG_RESET_MANUAL
71
 
70
 

+ 18
- 14
Marlin/src/Marlin.cpp 파일 보기

351
   if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) {
351
   if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) {
352
     SERIAL_ERROR_START();
352
     SERIAL_ERROR_START();
353
     SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
353
     SERIAL_ECHOLNPAIR(MSG_KILL_INACTIVE_TIME, parser.command_ptr);
354
-    kill(PSTR(MSG_KILLED));
354
+    kill();
355
   }
355
   }
356
 
356
 
357
   // Prevent steppers timing-out in the middle of M600
357
   // Prevent steppers timing-out in the middle of M600
408
     if (killCount >= KILL_DELAY) {
408
     if (killCount >= KILL_DELAY) {
409
       SERIAL_ERROR_START();
409
       SERIAL_ERROR_START();
410
       SERIAL_ERRORLNPGM(MSG_KILL_BUTTON);
410
       SERIAL_ERRORLNPGM(MSG_KILL_BUTTON);
411
-      kill(PSTR(MSG_KILLED));
411
+      kill();
412
     }
412
     }
413
   #endif
413
   #endif
414
 
414
 
609
  * Kill all activity and lock the machine.
609
  * Kill all activity and lock the machine.
610
  * After this the machine will need to be reset.
610
  * After this the machine will need to be reset.
611
  */
611
  */
612
-void kill(PGM_P lcd_msg) {
612
+void kill(PGM_P const lcd_msg/*=NULL*/) {
613
   SERIAL_ERROR_START();
613
   SERIAL_ERROR_START();
614
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
614
   SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
615
 
615
 
617
   disable_all_steppers();
617
   disable_all_steppers();
618
 
618
 
619
   #if ENABLED(EXTENSIBLE_UI)
619
   #if ENABLED(EXTENSIBLE_UI)
620
-    UI::onPrinterKilled(lcd_msg);
620
+    UI::onPrinterKilled(lcd_msg ? lcd_msg : PSTR(MSG_KILLED));
621
   #elif ENABLED(ULTRA_LCD)
621
   #elif ENABLED(ULTRA_LCD)
622
-    kill_screen(lcd_msg);
622
+    kill_screen(lcd_msg ? lcd_msg : PSTR(MSG_KILLED));
623
   #else
623
   #else
624
     UNUSED(lcd_msg);
624
     UNUSED(lcd_msg);
625
   #endif
625
   #endif
626
 
626
 
627
-  _delay_ms(600); // Wait a short time (allows messages to get out before shutting down.
628
-  cli(); // Stop interrupts
629
-
630
-  _delay_ms(250); //Wait to ensure all interrupts routines stopped
631
-  thermalManager.disable_all_heaters(); //turn off heaters again
632
-
633
   #ifdef ACTION_ON_KILL
627
   #ifdef ACTION_ON_KILL
634
     SERIAL_ECHOLNPGM("//action:" ACTION_ON_KILL);
628
     SERIAL_ECHOLNPGM("//action:" ACTION_ON_KILL);
635
   #endif
629
   #endif
636
 
630
 
631
+  minkill();
632
+}
633
+
634
+void minkill() {
635
+
636
+  _delay_ms(600); // Wait a short time (allows messages to get out before shutting down.
637
+  cli(); // Stop interrupts
638
+  _delay_ms(250); // Wait to ensure all interrupts stopped
639
+
640
+  thermalManager.disable_all_heaters(); // turn off heaters again
641
+
637
   #if HAS_POWER_SWITCH
642
   #if HAS_POWER_SWITCH
638
     PSU_OFF();
643
     PSU_OFF();
639
   #endif
644
   #endif
655
  */
660
  */
656
 void stop() {
661
 void stop() {
657
   thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
662
   thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
663
+  print_job_timer.stop();
658
 
664
 
659
   #if ENABLED(PROBING_FANS_OFF)
665
   #if ENABLED(PROBING_FANS_OFF)
660
     if (fans_paused) fans_pause(false); // put things back the way they were
666
     if (fans_paused) fans_pause(false); // put things back the way they were
979
         quickstop_stepper();
985
         quickstop_stepper();
980
         print_job_timer.stop();
986
         print_job_timer.stop();
981
         thermalManager.disable_all_heaters();
987
         thermalManager.disable_all_heaters();
982
-        #if FAN_COUNT > 0
983
-          for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
984
-        #endif
988
+        zero_fan_speeds();
985
         wait_for_heatup = false;
989
         wait_for_heatup = false;
986
         #if ENABLED(POWER_LOSS_RECOVERY)
990
         #if ENABLED(POWER_LOSS_RECOVERY)
987
           card.removeJobRecoveryFile();
991
           card.removeJobRecoveryFile();

+ 8
- 1
Marlin/src/Marlin.h 파일 보기

180
 void disable_e_steppers();
180
 void disable_e_steppers();
181
 void disable_all_steppers();
181
 void disable_all_steppers();
182
 
182
 
183
-void kill(PGM_P);
183
+void kill(PGM_P const lcd_msg=NULL);
184
+void minkill();
184
 
185
 
185
 void quickstop_stepper();
186
 void quickstop_stepper();
186
 
187
 
218
   #endif
219
   #endif
219
 #endif
220
 #endif
220
 
221
 
222
+inline void zero_fan_speeds() {
223
+  #if FAN_COUNT > 0
224
+    LOOP_L_N(i, FAN_COUNT) fan_speed[i] = 0;
225
+  #endif
226
+}
227
+
221
 #if ENABLED(USE_CONTROLLER_FAN)
228
 #if ENABLED(USE_CONTROLLER_FAN)
222
   extern uint8_t controllerfan_speed;
229
   extern uint8_t controllerfan_speed;
223
 #endif
230
 #endif

+ 1
- 0
Marlin/src/core/language.h 파일 보기

131
 #define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
131
 #define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
132
 #define MSG_COUNT_X                         " Count X:"
132
 #define MSG_COUNT_X                         " Count X:"
133
 #define MSG_COUNT_A                         " Count A:"
133
 #define MSG_COUNT_A                         " Count A:"
134
+#define MSG_WATCHDOG_FIRED                  "Watchdog timeout. Reset required."
134
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"
135
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"
135
 #define MSG_ERR_STOPPED                     "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
136
 #define MSG_ERR_STOPPED                     "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
136
 #define MSG_BUSY_PROCESSING                 "busy: processing"
137
 #define MSG_BUSY_PROCESSING                 "busy: processing"

+ 1
- 1
Marlin/src/feature/I2CPositionEncoder.cpp 파일 보기

164
 
164
 
165
     #ifdef I2CPE_ERR_THRESH_ABORT
165
     #ifdef I2CPE_ERR_THRESH_ABORT
166
       if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) {
166
       if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) {
167
-        //kill("Significant Error");
167
+        //kill(PSTR("Significant Error"));
168
         SERIAL_ECHOPGM("Axis error greater than set threshold, aborting!");
168
         SERIAL_ECHOPGM("Axis error greater than set threshold, aborting!");
169
         SERIAL_ECHOLN(error);
169
         SERIAL_ECHOLN(error);
170
         safe_delay(5000);
170
         safe_delay(5000);

+ 1
- 1
Marlin/src/gcode/control/M108_M112_M410.cpp 파일 보기

41
  * M112: Emergency Stop
41
  * M112: Emergency Stop
42
  */
42
  */
43
 void GcodeSuite::M112() {
43
 void GcodeSuite::M112() {
44
-  kill(PSTR(MSG_KILLED));
44
+  kill();
45
 }
45
 }
46
 
46
 
47
 /**
47
 /**

+ 3
- 1
Marlin/src/gcode/control/M80_M81.cpp 파일 보기

23
 #include "../gcode.h"
23
 #include "../gcode.h"
24
 #include "../../module/temperature.h"
24
 #include "../../module/temperature.h"
25
 #include "../../module/stepper.h"
25
 #include "../../module/stepper.h"
26
+#include "../../module/printcounter.h" // for print_job_timer
26
 
27
 
27
 #include "../../inc/MarlinConfig.h"
28
 #include "../../inc/MarlinConfig.h"
28
 
29
 
95
  */
96
  */
96
 void GcodeSuite::M81() {
97
 void GcodeSuite::M81() {
97
   thermalManager.disable_all_heaters();
98
   thermalManager.disable_all_heaters();
99
+  print_job_timer.stop();
98
   planner.finish_and_disable();
100
   planner.finish_and_disable();
99
 
101
 
100
   #if FAN_COUNT > 0
102
   #if FAN_COUNT > 0
101
-    for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
103
+    zero_fan_speeds();
102
     #if ENABLED(PROBING_FANS_OFF)
104
     #if ENABLED(PROBING_FANS_OFF)
103
       fans_paused = false;
105
       fans_paused = false;
104
       ZERO(paused_fan_speed);
106
       ZERO(paused_fan_speed);

+ 1
- 1
Marlin/src/gcode/queue.cpp 파일 보기

391
               wait_for_user = false;
391
               wait_for_user = false;
392
             #endif
392
             #endif
393
           }
393
           }
394
-          if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
394
+          if (strcmp(command, "M112") == 0) kill();
395
           if (strcmp(command, "M410") == 0) quickstop_stepper();
395
           if (strcmp(command, "M410") == 0) quickstop_stepper();
396
         #endif
396
         #endif
397
 
397
 

+ 1
- 3
Marlin/src/lcd/malyanlcd.cpp 파일 보기

254
         quickstop_stepper();
254
         quickstop_stepper();
255
         print_job_timer.stop();
255
         print_job_timer.stop();
256
         thermalManager.disable_all_heaters();
256
         thermalManager.disable_all_heaters();
257
-        #if FAN_COUNT > 0
258
-          for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
259
-        #endif
257
+        zero_fan_speeds();
260
         wait_for_heatup = false;
258
         wait_for_heatup = false;
261
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
259
         write_to_lcd_P(PSTR("{SYS:STARTED}"));
262
       #endif
260
       #endif

+ 1
- 3
Marlin/src/lcd/ultralcd.cpp 파일 보기

1918
   #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
1918
   #endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
1919
 
1919
 
1920
   void lcd_cooldown() {
1920
   void lcd_cooldown() {
1921
-    #if FAN_COUNT > 0
1922
-      for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
1923
-    #endif
1921
+    zero_fan_speeds();
1924
     thermalManager.disable_all_heaters();
1922
     thermalManager.disable_all_heaters();
1925
     lcd_return_to_status();
1923
     lcd_return_to_status();
1926
   }
1924
   }

+ 6
- 1
Marlin/src/module/endstops.cpp 파일 보기

36
   #include HAL_PATH(../HAL, endstop_interrupts.h)
36
   #include HAL_PATH(../HAL, endstop_interrupts.h)
37
 #endif
37
 #endif
38
 
38
 
39
+#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
40
+  #include "../module/printcounter.h" // for print_job_timer
41
+#endif
42
+
39
 Endstops endstops;
43
 Endstops endstops;
40
 
44
 
41
 // public:
45
 // public:
359
         card.sdprinting = false;
363
         card.sdprinting = false;
360
         card.closefile();
364
         card.closefile();
361
         quickstop_stepper();
365
         quickstop_stepper();
362
-        thermalManager.disable_all_heaters(); // switch off all heaters.
366
+        thermalManager.disable_all_heaters();
367
+        print_job_timer.stop();
363
       }
368
       }
364
     #endif
369
     #endif
365
   }
370
   }

+ 3
- 6
Marlin/src/module/temperature.cpp 파일 보기

304
 
304
 
305
     SERIAL_ECHOLNPGM(MSG_PID_AUTOTUNE_START);
305
     SERIAL_ECHOLNPGM(MSG_PID_AUTOTUNE_START);
306
 
306
 
307
-    disable_all_heaters(); // switch off all heaters.
307
+    disable_all_heaters();
308
 
308
 
309
     SHV(soft_pwm_amount, bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
309
     SHV(soft_pwm_amount, bias = d = (MAX_BED_POWER) >> 1, bias = d = (PID_MAX) >> 1);
310
 
310
 
779
   #endif
779
   #endif
780
 
780
 
781
   #if ENABLED(EMERGENCY_PARSER)
781
   #if ENABLED(EMERGENCY_PARSER)
782
-    if (emergency_parser.killed_by_M112) kill(PSTR(MSG_KILLED));
782
+    if (emergency_parser.killed_by_M112) kill();
783
   #endif
783
   #endif
784
 
784
 
785
   if (!temp_meas_ready) return;
785
   if (!temp_meas_ready) return;
949
       SERIAL_ERROR_START();
949
       SERIAL_ERROR_START();
950
       SERIAL_ERROR((int)e);
950
       SERIAL_ERROR((int)e);
951
       SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER_NUM);
951
       SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER_NUM);
952
-      kill(PSTR(MSG_KILLED));
952
+      kill();
953
       return 0.0;
953
       return 0.0;
954
     }
954
     }
955
 
955
 
1551
     pause(false);
1551
     pause(false);
1552
   #endif
1552
   #endif
1553
 
1553
 
1554
-  // If all heaters go down then for sure our print job has stopped
1555
-  print_job_timer.stop();
1556
-
1557
   #define DISABLE_HEATER(NR) { \
1554
   #define DISABLE_HEATER(NR) { \
1558
     setTargetHotend(0, NR); \
1555
     setTargetHotend(0, NR); \
1559
     soft_pwm_amount[NR] = 0; \
1556
     soft_pwm_amount[NR] = 0; \

+ 1
- 1
Marlin/src/sd/cardreader.cpp 파일 보기

394
         SERIAL_ERROR_START();
394
         SERIAL_ERROR_START();
395
         SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
395
         SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
396
         SERIAL_ERRORLN((int)SD_PROCEDURE_DEPTH);
396
         SERIAL_ERRORLN((int)SD_PROCEDURE_DEPTH);
397
-        kill(PSTR(MSG_KILLED));
397
+        kill();
398
         return;
398
         return;
399
       }
399
       }
400
 
400
 

+ 1
- 1
Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp 파일 보기

38
 
38
 
39
 // The USB library needs to be called periodically to detect USB thumbdrive
39
 // The USB library needs to be called periodically to detect USB thumbdrive
40
 // insertion and removals. Call this idle() function periodically to allow
40
 // insertion and removals. Call this idle() function periodically to allow
41
-// the USB libary to monitor for such events. This function also takes care
41
+// the USB library to monitor for such events. This function also takes care
42
 // of initializing the USB library for the first time.
42
 // of initializing the USB library for the first time.
43
 
43
 
44
 void Sd2Card::idle() {
44
 void Sd2Card::idle() {

Loading…
취소
저장