Browse Source

Merge pull request #4214 from thinkyhead/fix_clear_command_queue

Allow the command queue to be cleared by commands, lcd menus
Scott Lahteine 9 years ago
parent
commit
90d8bb53e8
1 changed files with 9 additions and 6 deletions
  1. 9
    6
      Marlin/Marlin_main.cpp

+ 9
- 6
Marlin/Marlin_main.cpp View File

284
 
284
 
285
 static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
285
 static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
286
 
286
 
287
-static char* current_command, *current_command_args;
288
-static int cmd_queue_index_r = 0;
289
-static int cmd_queue_index_w = 0;
290
-static int commands_in_queue = 0;
291
 static char command_queue[BUFSIZE][MAX_CMD_SIZE];
287
 static char command_queue[BUFSIZE][MAX_CMD_SIZE];
288
+static char* current_command, *current_command_args;
289
+static uint8_t cmd_queue_index_r = 0,
290
+               cmd_queue_index_w = 0,
291
+               commands_in_queue = 0;
292
 
292
 
293
 #if ENABLED(INCH_MODE_SUPPORT)
293
 #if ENABLED(INCH_MODE_SUPPORT)
294
   float linear_unit_factor = 1.0;
294
   float linear_unit_factor = 1.0;
990
 
990
 
991
     #endif // SDSUPPORT
991
     #endif // SDSUPPORT
992
 
992
 
993
-    commands_in_queue--;
994
-    cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE;
993
+    // The queue may be reset by a command handler or by code invoked by idle() within a handler
994
+    if (commands_in_queue) {
995
+      --commands_in_queue;
996
+      cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE;
997
+    }
995
   }
998
   }
996
   endstops.report_state();
999
   endstops.report_state();
997
   idle();
1000
   idle();

Loading…
Cancel
Save