Skip to content

Commit

Permalink
STEAPP-521: Add virtual_sdcard dump to bug report. (#136)
Browse files Browse the repository at this point in the history
* STEAPP-521: A line has been added to the log that caused an error.

* STEAPP-521: added to the log entry of commands that are unknown to klipper.

* STEAPP-521: Added a dump of the data causing the exception and writing this data to a log file.

* added dump data to loging file.
  • Loading branch information
SokolovJek authored Jul 25, 2023
1 parent 725bb48 commit 93ce759
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions klippy/extras/virtual_sdcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def work_handler(self, eventtime):
gcode_mutex = self.gcode.get_mutex()
partial_input = ""
lines = []
data = ''
error_message = None
while not self.must_pause_work:
if not lines:
Expand Down Expand Up @@ -275,14 +276,14 @@ def work_handler(self, eventtime):
self.print_stats.set_layer(current_layer=layer_number)
self.gcode.run_script(line)
except self.gcode.error as e:
error_message = str(e)
error_message = str('Error: %s,\nLine: %s\nData caused the error: %s.' % (e, line, str(data)))
try:
self.gcode.run_script(self.on_error_gcode.render())
except:
logging.exception("virtual_sdcard on_error")
break
except:
logging.exception("virtual_sdcard dispatch")
logging.exception("virtual_sdcard dispatch. %s" % str(data))
break
self.cmd_from_sd = False
self.file_position = self.next_file_position
Expand All @@ -302,6 +303,7 @@ def work_handler(self, eventtime):
if error_message is not None:
self.get_layer_count = True
self.print_stats.note_error(error_message)
logging.error(error_message)
elif self.current_file is not None:
self.print_stats.note_pause()
else:
Expand Down
9 changes: 6 additions & 3 deletions klippy/gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, gcode, command, commandline, params, need_ack):
self._need_ack = need_ack
# Method wrappers
self.respond_info = gcode.respond_info
self.respond_warning = gcode.respond_warning
self.respond_raw = gcode.respond_raw
def get_command(self):
return self._command
Expand Down Expand Up @@ -199,12 +200,14 @@ def _process_commands(self, commands, need_ack=True):
try:
handler(gcmd)
except self.error as e:
self._respond_error(str(e))
self._respond_error('Internal error on command: "%s", error: "%s\n"' % (
origline, str(e)))
self.printer.send_event("gcode:command_error")
if not need_ack:
raise
except:
msg = 'Internal error on command:"%s"' % (cmd,)
msg = 'Internal error on command:"%s", origline"%s"' % (
cmd, origline)
logging.exception(msg)
self.printer.invoke_shutdown(msg)
self._respond_error(msg)
Expand Down Expand Up @@ -295,7 +298,7 @@ def cmd_default(self, gcmd):
not gcmd.get_float('S', 1.) or self.is_fileinput)):
# Don't warn about requests to turn off fan when fan not present
return
gcmd.respond_info('Unknown command:"%s"' % (cmd,))
gcmd.respond_warning('Unknown command:"%s"' % (cmd,))
def _cmd_mux(self, command, gcmd):
key, values = self.mux_commands[command]
if None in values:
Expand Down

0 comments on commit 93ce759

Please sign in to comment.