Skip to content

Commit

Permalink
Fix the resend history after power panic
Browse files Browse the repository at this point in the history
  • Loading branch information
TojikCZ committed May 3, 2024
1 parent 337ea32 commit 36d1291
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
10 changes: 0 additions & 10 deletions prusa/link/printer_adapter/command_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,10 @@ def _run_command(self):
raise CommandFailed("No PP file exists, cannot recover.")

d_code = get_d3_code(*EEPROMParams.EEPROM_FILE_POSITION.value)
log.info("dcode EEPROM_FILE_POSITION value %s", d_code)
match = self.do_matchable(d_code, D3_OUTPUT_REGEX).match()
log.info("Match %s", match)
if match is None:
raise CommandFailed("Failed to get file position")
line_number = _parse_little_endian_uint32(match)
log.info("line_number %s", line_number)
self.serial_queue.set_message_number(line_number)
if not self.file_printer.pp_exists:
log.warning("Cannot recover from power panic, "
Expand All @@ -703,18 +700,11 @@ def _run_command(self):
with open(self.model.file_printer.pp_file_path, "r",
encoding="UTF-8") as pp_file:
pp_data = PPData(**json.load(pp_file))
log.info("pp_data %s", pp_data)

gcode_number = (pp_data.gcode_number
+ (line_number - pp_data.message_number))
log.info("pp_data.gcode_number %s +(line_number %s - "
"pp_data.message_number %s)",
pp_data.gcode_number, line_number,
pp_data.message_number)
path = pp_data.file_path
log.info("pp_data.file_path %s", pp_data.file_path)
connect_path = pp_data.connect_path
log.info("pp_data.connect_path %s", pp_data.connect_path)

if not os.path.isfile(path):
raise CommandFailed(
Expand Down
3 changes: 2 additions & 1 deletion prusa/link/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def _parse_little_endian_uint32(match):

def power_panic_delay(cfg):
"""Adds a dynamic delay depending on power panic details.
This is needed so the printer reaches a stable state before we reset it."""
This is needed so the printer reaches a stable state before we reset it.
Only for USB connection"""
pp_file_path = cfg.daemon.power_panic_file
if not os.path.exists(pp_file_path):
return
Expand Down

0 comments on commit 36d1291

Please sign in to comment.