aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-09-24 18:10:24 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-09-30 21:27:46 -0400
commite9505697fb587d7fa46f4c598cb13d20042879d1 (patch)
tree601b3b968ed196a5b136d15c703a10245b3ef888 /klippy/gcode.py
parent47f303317bddd6a3dc8b3fddaabeeefeae69bd99 (diff)
downloadkutter-e9505697fb587d7fa46f4c598cb13d20042879d1.tar.gz
kutter-e9505697fb587d7fa46f4c598cb13d20042879d1.tar.xz
kutter-e9505697fb587d7fa46f4c598cb13d20042879d1.zip
gcode: Keep a log of incoming gcode data and report it on a shutdown
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r--klippy/gcode.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 529bd1dc..37dd3b23 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -3,7 +3,7 @@
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import os, re, logging
+import os, re, logging, collections
# Parse out incoming GCode and find and translate head movements
class GCodeParser:
@@ -18,6 +18,7 @@ class GCodeParser:
self.input_commands = [""]
self.need_register_fd = False
self.bytes_read = 0
+ self.input_log = collections.deque([], 50)
# Busy handling
self.busy_timer = self.reactor.register_timer(self.busy_handler)
self.busy_state = None
@@ -71,6 +72,9 @@ class GCodeParser:
def shutdown(self):
self.is_shutdown = True
self.build_handlers()
+ logging.info("Dumping gcode input %d blocks" % (len(self.input_log),))
+ for eventtime, data in self.input_log:
+ logging.info("Read %f: %s" % (eventtime, repr(data)))
# Parse input into commands
args_r = re.compile('([a-zA-Z*])')
def process_commands(self, eventtime):
@@ -117,6 +121,7 @@ class GCodeParser:
self.need_register_fd = True
return
data = os.read(self.fd, 4096)
+ self.input_log.append((eventtime, data))
self.bytes_read += len(data)
lines = data.split('\n')
lines[0] = self.input_commands[0] + lines[0]