From 0f6b9b40512eca03abbc930ae337a87ddf9323d6 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Oct 2019 21:09:28 +0200 Subject: [PATCH] Unroll the stack in restore_print_from_ram_and_continue While handling moves in a recursive plan, such a filament check, ensure restore_print_from_ram_and_continue unwinds the stack by aborting early from any call that waits on the planner. This currently only handles G1 moves, but hard-coded behavior that can trigger recursive behavior (such as filament change) will probably have to be checked too. --- Firmware/Marlin_main.cpp | 6 ++++++ Firmware/planner.cpp | 2 +- Firmware/planner.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 19d79953..46fef27a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8363,6 +8363,8 @@ void clamp_to_software_endstops(float target[3]) current_position[Z_AXIS] + t * dz, current_position[E_AXIS] + t * de, feed_rate, extruder); + if (waiting_inside_plan_buffer_line_print_aborted) + return; } } // The rest of the path. @@ -8390,6 +8392,8 @@ void prepare_move() plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply*(1./(60.f*100.f)), active_extruder); #endif } + if (waiting_inside_plan_buffer_line_print_aborted) + return; for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; @@ -10264,10 +10268,12 @@ void restore_print_from_ram_and_continue(float e_move) else { //not sd printing nor usb printing } + SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this lcd_setstatuspgm(_T(WELCOME_MSG)); saved_printing_type = PRINTING_TYPE_NONE; saved_printing = false; + waiting_inside_plan_buffer_line_print_aborted = true; //unroll the stack } void print_world_coordinates() diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index 752d0725..63058d2c 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -666,8 +666,8 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. + waiting_inside_plan_buffer_line_print_aborted = false; if (block_buffer_tail == next_buffer_head) { - waiting_inside_plan_buffer_line_print_aborted = false; do { manage_heater(); // Vojtech: Don't disable motors inside the planner! diff --git a/Firmware/planner.h b/Firmware/planner.h index 7904c45a..4977265b 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -238,6 +238,7 @@ FORCE_INLINE bool planner_queue_full() { // wait for the steppers to stop, // update planner's current position and the current_position of the front end. extern void planner_abort_hard(); +extern bool waiting_inside_plan_buffer_line_print_aborted; #ifdef PREVENT_DANGEROUS_EXTRUDE void set_extrude_min_temp(float temp);