Browse Source

Add an emergency-command parser to MarlinSerial (supporting M108)

Add an emergency-command parser to MarlinSerial's RX interrupt.

The parser tries to find and execute M108,M112,M410 before the commands disappear in the RX-buffer.

To avoid false positives for M117, comments and commands followed by filenames (M23, M28, M30, M32, M33) are filtered.

This enables Marlin to receive and react on the Emergency command at all times - regardless of whether the buffers are full or not. It remains to convince hosts to send the commands. To inform the hosts about the new feature a new entry in the M115-report was made. "`EMERGENCY_CODES:M112,M108,M410;`".

The parser is fast. It only ever needs two switch decisions and one assignment of the new state for every character.

One problem remains. If the host has sent an incomplete line before sending an emergency command the emergency command could be omitted when the parser is in `state_IGNORE`.
In that case the host should send "\ncommand\n"

Also introduces M108 to break the waiting for the heaters in M109, M190 and M303.

Rename `cancel_heatup` to `wait_for_heatup` to better see the purpose.
AnHardt 8 years ago
parent
commit
a129078927

+ 6
- 0
Marlin/Conditionals.h View File

@@ -284,6 +284,12 @@
284 284
     #define HardwareSerial_h // trick to disable the standard HWserial
285 285
   #endif
286 286
 
287
+  #if ENABLED(EMERGENCY_PARSER)
288
+    #define EMERGENCY_PARSER_CAPABILITIES " EMERGENCY_CODES:M108,M112,M410"
289
+  #else
290
+    #define EMERGENCY_PARSER_CAPABILITIES ""
291
+  #endif
292
+
287 293
   #include "Arduino.h"
288 294
 
289 295
   /**

+ 6
- 0
Marlin/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 1
- 0
Marlin/Marlin.h View File

@@ -288,6 +288,7 @@ extern float sw_endstop_min[3]; // axis[n].sw_endstop_min
288 288
 extern float sw_endstop_max[3]; // axis[n].sw_endstop_max
289 289
 extern bool axis_known_position[3]; // axis[n].is_known
290 290
 extern bool axis_homed[3]; // axis[n].is_homed
291
+extern bool wait_for_heatup;
291 292
 
292 293
 // GCode support for external objects
293 294
 bool code_seen(char);

+ 158
- 0
Marlin/MarlinSerial.cpp View File

@@ -30,6 +30,7 @@
30 30
 
31 31
 #include "Marlin.h"
32 32
 #include "MarlinSerial.h"
33
+#include "stepper.h"
33 34
 
34 35
 #ifndef USBCON
35 36
 // this next line disables the entire HardwareSerial.cpp,
@@ -54,6 +55,10 @@ FORCE_INLINE void store_char(unsigned char c) {
54 55
       rx_buffer.head = i;
55 56
     }
56 57
   CRITICAL_SECTION_END;
58
+
59
+  #if ENABLED(EMERGENCY_PARSER)
60
+    emergency_parser(c);
61
+  #endif
57 62
 }
58 63
 
59 64
 
@@ -310,3 +315,156 @@ MarlinSerial customizedSerial;
310 315
 #if defined(USBCON) && ENABLED(BLUETOOTH)
311 316
   HardwareSerial bluetoothSerial;
312 317
 #endif
318
+
319
+#if ENABLED(EMERGENCY_PARSER)
320
+
321
+  // Currently looking for: M108, M112, M410
322
+  // If you alter the parser please don't forget to update the capabilities in Conditionals.h
323
+
324
+  void emergency_parser(unsigned char c) {
325
+
326
+    enum e_parser_state {
327
+      state_RESET,
328
+      state_M,
329
+      state_M1,
330
+      state_M10,
331
+      state_M11,
332
+      state_M2,
333
+      state_M3,
334
+      state_M4,
335
+      state_M41,
336
+      state_IGNORE // to '\n'
337
+    };
338
+
339
+    static e_parser_state state = state_RESET;
340
+
341
+    switch (state) {
342
+      case state_RESET:
343
+        switch (c) {
344
+          case 'M':
345
+            state = state_M;
346
+            break;
347
+          case ';':
348
+            state = state_IGNORE;
349
+            break;
350
+          default: state = state_RESET;
351
+        }
352
+      break;
353
+
354
+      case state_M:
355
+        switch (c) {
356
+          case '1':
357
+            state = state_M1;
358
+            break;
359
+          case '2':
360
+            state = state_M2;
361
+            break;
362
+          case '3':
363
+            state = state_M3;
364
+            break;
365
+          case '4':
366
+            state = state_M4;
367
+            break;
368
+          case ';':
369
+            state = state_IGNORE;
370
+            break;
371
+          default: state = state_RESET;
372
+        }
373
+      break;
374
+
375
+      case state_M1:
376
+        switch (c) {
377
+          case '0':
378
+            state = state_M10;
379
+            break;
380
+          case '1':
381
+            state = state_M11;
382
+            break;
383
+          case ';':
384
+            state = state_IGNORE;
385
+            break;
386
+          default: state = state_RESET;
387
+        }
388
+      break;
389
+
390
+      case state_M2:
391
+        switch (c) {
392
+          case '3': // M23
393
+          case '8': // M28
394
+          case ';':
395
+            state = state_IGNORE;
396
+            break;
397
+          default: state = state_RESET;
398
+        }
399
+      break;
400
+
401
+      case state_M3:
402
+        switch (c) {
403
+          case '0': // M30
404
+          case '2': // M32
405
+          case '3': // M33
406
+          case ';':
407
+            state = state_IGNORE;
408
+            break;
409
+          default: state = state_RESET;
410
+        }
411
+      break;
412
+
413
+      case state_M10:
414
+        switch (c) {
415
+          case '8': // M108
416
+            { state = state_RESET; wait_for_heatup = false; }
417
+            break;
418
+          case ';':
419
+            state = state_IGNORE;
420
+            break;
421
+          default: state = state_RESET;
422
+        }
423
+      break;
424
+
425
+      case state_M11:
426
+        switch (c) {
427
+          case '2': // M112
428
+            state = state_RESET; kill(PSTR(MSG_KILLED));
429
+            break;
430
+          case '7': // M117
431
+          case ';':
432
+            state = state_IGNORE;
433
+            break;
434
+          default: state = state_RESET;
435
+        }
436
+      break;
437
+
438
+      case state_M4:
439
+        switch (c) {
440
+          case '1':
441
+            state = state_M41;
442
+            break;
443
+          case ';':
444
+            state = state_IGNORE;
445
+            break;
446
+          default: state = state_RESET;
447
+        }
448
+      break;
449
+
450
+      case state_M41:
451
+        switch (c) {
452
+          case '0':
453
+            { state = state_RESET; stepper.quick_stop(); }
454
+            break;
455
+          case ';':
456
+            state = state_IGNORE;
457
+            break;
458
+          default: state = state_RESET;
459
+        }
460
+      break;
461
+
462
+      case state_IGNORE:
463
+        if (c == '\n') state = state_RESET;
464
+      break;
465
+
466
+      default:
467
+        state = state_RESET;
468
+    }
469
+  }
470
+#endif

+ 9
- 0
Marlin/MarlinSerial.h View File

@@ -101,6 +101,11 @@ struct ring_buffer {
101 101
   extern ring_buffer rx_buffer;
102 102
 #endif
103 103
 
104
+#if ENABLED(EMERGENCY_PARSER)
105
+  #include "language.h"
106
+  void emergency_parser(unsigned char c);
107
+#endif
108
+
104 109
 class MarlinSerial { //: public Stream
105 110
 
106 111
   public:
@@ -141,6 +146,10 @@ class MarlinSerial { //: public Stream
141 146
             rx_buffer.head = i;
142 147
           }
143 148
         CRITICAL_SECTION_END;
149
+
150
+        #if ENABLED(EMERGENCY_PARSER)
151
+          emergency_parser(c);
152
+        #endif
144 153
       }
145 154
     }
146 155
 

+ 41
- 24
Marlin/Marlin_main.cpp View File

@@ -160,7 +160,7 @@
160 160
  * M105 - Read current temp
161 161
  * M106 - Fan on
162 162
  * M107 - Fan off
163
- * M108 - Cancel heatup and wait for the hotend and bed, this G-code is asynchronously handled in the get_serial_commands() parser
163
+ * M108 - Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
164 164
  * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
165 165
  *        Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
166 166
  *        IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
@@ -1105,9 +1105,12 @@ inline void get_serial_commands() {
1105 1105
         }
1106 1106
       }
1107 1107
 
1108
-      // If command was e-stop process now
1109
-      if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
1110
-      if (strcmp(command, "M108") == 0) wait_for_heatup = false;
1108
+      #if DISABLED(EMERGENCY_PARSER)
1109
+        // If command was e-stop process now
1110
+        if (strcmp(command, "M108") == 0) wait_for_heatup = false;
1111
+        if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
1112
+        if (strcmp(command, "M410") == 0) stepper.quick_stop();
1113
+      #endif
1111 1114
 
1112 1115
       #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
1113 1116
         last_command_time = ms;
@@ -4533,10 +4536,14 @@ inline void gcode_M105() {
4533 4536
 
4534 4537
 #endif // FAN_COUNT > 0
4535 4538
 
4536
-/**
4537
- * M108: Cancel heatup and wait for the hotend and bed, this G-code is asynchronously handled in the get_serial_commands() parser
4538
- */
4539
-inline void gcode_M108() { wait_for_heatup = false; }
4539
+#if DISABLED(EMERGENCY_PARSER)
4540
+
4541
+  /**
4542
+   * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
4543
+   */
4544
+  inline void gcode_M108() { wait_for_heatup = false; }
4545
+
4546
+#endif
4540 4547
 
4541 4548
 /**
4542 4549
  * M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
@@ -4811,7 +4818,9 @@ inline void gcode_M111() {
4811 4818
 /**
4812 4819
  * M112: Emergency Stop
4813 4820
  */
4814
-inline void gcode_M112() { kill(PSTR(MSG_KILLED)); }
4821
+#if DISABLED(EMERGENCY_PARSER)
4822
+  inline void gcode_M112() { kill(PSTR(MSG_KILLED)); }
4823
+#endif
4815 4824
 
4816 4825
 #if ENABLED(HOST_KEEPALIVE_FEATURE)
4817 4826
 
@@ -5991,13 +6000,15 @@ inline void gcode_M400() { stepper.synchronize(); }
5991 6000
  * This will stop the carriages mid-move, so most likely they
5992 6001
  * will be out of sync with the stepper position after this.
5993 6002
  */
5994
-inline void gcode_M410() {
5995
-  stepper.quick_stop();
5996
-  #if DISABLED(DELTA) && DISABLED(SCARA)
5997
-    set_current_position_from_planner();
5998
-  #endif
5999
-}
6000 6003
 
6004
+#if DISABLED(EMERGENCY_PARSER)
6005
+  inline void gcode_M410() {
6006
+    stepper.quick_stop();
6007
+    #if DISABLED(DELTA) && DISABLED(SCARA)
6008
+      set_current_position_from_planner();
6009
+    #endif
6010
+  }
6011
+#endif
6001 6012
 
6002 6013
 #if ENABLED(MESH_BED_LEVELING)
6003 6014
 
@@ -6953,9 +6964,11 @@ void process_next_command() {
6953 6964
         gcode_M111();
6954 6965
         break;
6955 6966
 
6956
-      case 112: // M112: Emergency Stop
6957
-        gcode_M112();
6958
-        break;
6967
+      #if DISABLED(EMERGENCY_PARSER)
6968
+        case 112: // M112: Emergency Stop
6969
+          gcode_M112();
6970
+          break;
6971
+      #endif
6959 6972
 
6960 6973
       #if ENABLED(HOST_KEEPALIVE_FEATURE)
6961 6974
 
@@ -6974,9 +6987,11 @@ void process_next_command() {
6974 6987
         KEEPALIVE_STATE(NOT_BUSY);
6975 6988
         return; // "ok" already printed
6976 6989
 
6977
-      case 108:
6978
-        gcode_M108();
6979
-        break;
6990
+      #if DISABLED(EMERGENCY_PARSER)
6991
+        case 108:
6992
+          gcode_M108();
6993
+          break;
6994
+      #endif
6980 6995
 
6981 6996
       case 109: // M109: Wait for temperature
6982 6997
         gcode_M109();
@@ -7261,9 +7276,11 @@ void process_next_command() {
7261 7276
           break;
7262 7277
       #endif // ENABLED(FILAMENT_WIDTH_SENSOR)
7263 7278
 
7264
-      case 410: // M410 quickstop - Abort all the planned moves.
7265
-        gcode_M410();
7266
-        break;
7279
+      #if DISABLED(EMERGENCY_PARSER)
7280
+        case 410: // M410 quickstop - Abort all the planned moves.
7281
+          gcode_M410();
7282
+          break;
7283
+      #endif
7267 7284
 
7268 7285
       #if ENABLED(MESH_BED_LEVELING)
7269 7286
         case 420: // M420 Enable/Disable Mesh Bed Leveling

+ 7
- 0
Marlin/SanityCheck.h View File

@@ -579,6 +579,13 @@
579 579
 #endif
580 580
 
581 581
 /**
582
+ * emergency-command parser
583
+ */
584
+#if ENABLED(EMERGENCY_PARSER) && ENABLED(USBCON)
585
+  #error "EMERGENCY_PARSER does not work on boards with AT90USB processors (USBCON)."
586
+#endif
587
+
588
+ /**
582 589
  * Warnings for old configurations
583 590
  */
584 591
 #if WATCH_TEMP_PERIOD > 500

+ 6
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -526,6 +526,12 @@ const unsigned int dropsegments = 2; //everything with less than this number of
526 526
 #define MAX_CMD_SIZE 96
527 527
 #define BUFSIZE 4
528 528
 
529
+// Enable an emergency-command parser to intercept certain commands as they
530
+// enter the serial receive buffer, so they cannot be blocked.
531
+// Currently handles M108, M112, M410
532
+// Does not work on boards using AT90USB (USBCON) processors!
533
+//#define EMERGENCY_PARSER
534
+
529 535
 // Bad Serial-connections can miss a received command by sending an 'ok'
530 536
 // Therefore some clients abort after 30 seconds in a timeout.
531 537
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 26
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 8
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -528,6 +528,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
528 528
 #define MAX_CMD_SIZE 96
529 529
 #define BUFSIZE 4
530 530
 
531
+// Enable an emergency-command parser to intercept certain commands as they
532
+// enter the serial receive buffer, so they cannot be blocked.
533
+// Currently handles M108, M112, M410
534
+// Does not work on boards using AT90USB (USBCON) processors!
535
+//#define EMERGENCY_PARSER
536
+
531 537
 // Bad Serial-connections can miss a received command by sending an 'ok'
532 538
 // Therefore some clients abort after 30 seconds in a timeout.
533 539
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

@@ -522,6 +522,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
522 522
 #define MAX_CMD_SIZE 96
523 523
 #define BUFSIZE 4
524 524
 
525
+// Enable an emergency-command parser to intercept certain commands as they
526
+// enter the serial receive buffer, so they cannot be blocked.
527
+// Currently handles M108, M112, M410
528
+// Does not work on boards using AT90USB (USBCON) processors!
529
+//#define EMERGENCY_PARSER
530
+
525 531
 // Bad Serial-connections can miss a received command by sending an 'ok'
526 532
 // Therefore some clients abort after 30 seconds in a timeout.
527 533
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -522,6 +522,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
522 522
 #define MAX_CMD_SIZE 96
523 523
 #define BUFSIZE 4
524 524
 
525
+// Enable an emergency-command parser to intercept certain commands as they
526
+// enter the serial receive buffer, so they cannot be blocked.
527
+// Currently handles M108, M112, M410
528
+// Does not work on boards using AT90USB (USBCON) processors!
529
+//#define EMERGENCY_PARSER
530
+
525 531
 // Bad Serial-connections can miss a received command by sending an 'ok'
526 532
 // Therefore some clients abort after 30 seconds in a timeout.
527 533
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -521,6 +521,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
521 521
 #define MAX_CMD_SIZE 96
522 522
 #define BUFSIZE 4
523 523
 
524
+// Enable an emergency-command parser to intercept certain commands as they
525
+// enter the serial receive buffer, so they cannot be blocked.
526
+// Currently handles M108, M112, M410
527
+// Does not work on boards using AT90USB (USBCON) processors!
528
+//#define EMERGENCY_PARSER
529
+
524 530
 // Bad Serial-connections can miss a received command by sending an 'ok'
525 531
 // Therefore some clients abort after 30 seconds in a timeout.
526 532
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -526,6 +526,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
526 526
 #define MAX_CMD_SIZE 96
527 527
 #define BUFSIZE 4
528 528
 
529
+// Enable an emergency-command parser to intercept certain commands as they
530
+// enter the serial receive buffer, so they cannot be blocked.
531
+// Currently handles M108, M112, M410
532
+// Does not work on boards using AT90USB (USBCON) processors!
533
+//#define EMERGENCY_PARSER
534
+
529 535
 // Bad Serial-connections can miss a received command by sending an 'ok'
530 536
 // Therefore some clients abort after 30 seconds in a timeout.
531 537
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -522,6 +522,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
522 522
 #define MAX_CMD_SIZE 96
523 523
 #define BUFSIZE 4
524 524
 
525
+// Enable an emergency-command parser to intercept certain commands as they
526
+// enter the serial receive buffer, so they cannot be blocked.
527
+// Currently handles M108, M112, M410
528
+// Does not work on boards using AT90USB (USBCON) processors!
529
+//#define EMERGENCY_PARSER
530
+
525 531
 // Bad Serial-connections can miss a received command by sending an 'ok'
526 532
 // Therefore some clients abort after 30 seconds in a timeout.
527 533
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 6
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -520,6 +520,12 @@ const unsigned int dropsegments = 5; //everything with less than this number of
520 520
 #define MAX_CMD_SIZE 96
521 521
 #define BUFSIZE 4
522 522
 
523
+// Enable an emergency-command parser to intercept certain commands as they
524
+// enter the serial receive buffer, so they cannot be blocked.
525
+// Currently handles M108, M112, M410
526
+// Does not work on boards using AT90USB (USBCON) processors!
527
+//#define EMERGENCY_PARSER
528
+
523 529
 // Bad Serial-connections can miss a received command by sending an 'ok'
524 530
 // Therefore some clients abort after 30 seconds in a timeout.
525 531
 // Some other clients start sending commands while receiving a 'wait'.

+ 1
- 1
Marlin/language.h View File

@@ -128,7 +128,7 @@
128 128
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
129 129
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
130 130
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
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 "\n"
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 EMERGENCY_PARSER_CAPABILITIES "\n"
132 132
 #define MSG_COUNT_X                         " Count X: "
133 133
 #define MSG_COUNT_A                         " Count A: "
134 134
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"

+ 4
- 1
Marlin/temperature.cpp View File

@@ -238,8 +238,10 @@ unsigned char Temperature::soft_pwm[HOTENDS];
238 238
       soft_pwm_bed = bias = d = (MAX_BED_POWER) / 2;
239 239
     #endif
240 240
 
241
+    wait_for_heatup = true;
242
+
241 243
     // PID Tuning loop
242
-    for (;;) {
244
+    while (wait_for_heatup) {
243 245
 
244 246
       millis_t ms = millis();
245 247
 
@@ -421,6 +423,7 @@ unsigned char Temperature::soft_pwm[HOTENDS];
421 423
       }
422 424
       lcd_update();
423 425
     }
426
+    if (!wait_for_heatup) disable_all_heaters();
424 427
   }
425 428
 
426 429
 #endif // HAS_PID_HEATING

Loading…
Cancel
Save