Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 stop_and_save_print_to_ram should not overwrite valid partial backup #4410

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9735,16 +9735,8 @@ void ThermalStop(bool allow_recovery)

// we cannot make a distinction for the host here, the pause must be instantaneous
// so we call the lcd_pause_print to save the print state internally. Thermal errors
// disable heaters and save the original temperatures to saved_*, which will get
// overwritten by stop_and_save_print_to_ram. For this corner-case, re-instate the
// original values after the pause handler is called.
uint8_t bed_temp = saved_bed_temperature;
uint16_t ext_temp = saved_extruder_temperature;
uint8_t fan_speed = saved_fan_speed;
// disable heaters and save the original temperatures to saved_*
lcd_pause_print();
saved_bed_temperature = bed_temp;
saved_extruder_temperature = ext_temp;
saved_fan_speed = fan_speed;
}
wavexx marked this conversation as resolved.
Show resolved Hide resolved
} else {
// We got a hard thermal error and/or there is no print going on. Just stop.
Expand Down Expand Up @@ -10792,14 +10784,15 @@ void stop_and_save_print_to_ram(float z_move, float e_move)

planner_abort_hard(); //abort printing

memcpy(saved_pos, current_position, sizeof(saved_pos));
if (!isPartialBackupAvailable) {
refresh_print_state_in_ram();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A problem I see here with this approach, is that now set_temp_error saves current_position before planner_abort_hard() is called, so current_position is not correct during a thermal error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gudnimg Is this solved?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I havent had a good opportunity to look into this. I was too sick to do any productive things previous weekend

I will hopefully look at this again soon (and other PRs)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gudnimg is this solved?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the PR needs to be reworked to address this. I think we should postpone this after 3.14


if (pos_invalid) saved_pos[X_AXIS] = X_COORD_INVALID;

saved_feedmultiply2 = feedmultiply; //save feedmultiply
saved_extruder_temperature = (uint16_t)degTargetHotend(active_extruder);
saved_bed_temperature = (uint8_t)degTargetBed();
saved_extruder_relative_mode = axis_relative_modes & E_AXIS_MASK;
saved_fan_speed = fanSpeed;
// Reset partial backup flag, we have a full back-up now
clear_print_state_in_ram();

cmdqueue_reset(); //empty cmdqueue
card.sdprinting = false;
// card.closefile();
Expand Down
4 changes: 1 addition & 3 deletions Firmware/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ void set_temp_error(TempErrorSource source, uint8_t index, TempErrorType type)
{
// save the original target temperatures for recovery before disabling heaters
if(!temp_error_state.error && !saved_printing) {
saved_bed_temperature = target_temperature_bed;
saved_extruder_temperature = target_temperature[index];
saved_fan_speed = fanSpeed;
refresh_print_state_in_ram();
}

// keep disabling heaters and keep fans on as long as the condition is asserted
Expand Down
Loading