aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-04-23 18:24:58 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-04-23 18:35:15 -0400
commit76bafadb7155dc3acf0bd8b50ded74e6dc79e71f (patch)
tree7d91070b5f3d5b7f49e240cd90f29caf5150f3ed /klippy/extras
parent3ef7c00b73a547aff475606b369773ab834201a1 (diff)
downloadkutter-76bafadb7155dc3acf0bd8b50ded74e6dc79e71f.tar.gz
kutter-76bafadb7155dc3acf0bd8b50ded74e6dc79e71f.tar.xz
kutter-76bafadb7155dc3acf0bd8b50ded74e6dc79e71f.zip
virtual_sdcard: Add logging on start, stop, stats, and shutdown
Add additional logging to the virtual_sdcard support. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/virtual_sdcard.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py
index 1d0eaf15..5a3a09a2 100644
--- a/klippy/extras/virtual_sdcard.py
+++ b/klippy/extras/virtual_sdcard.py
@@ -26,6 +26,21 @@ class VirtualSD:
def printer_state(self, state):
if state == 'shutdown' and self.work_timer is not None:
self.must_pause_work = True
+ try:
+ readpos = max(self.file_position - 1024, 0)
+ readcount = self.file_position - readpos
+ self.current_file.seek(readpos)
+ data = self.current_file.read(readcount + 128)
+ except:
+ logging.exception("virtual_sdcard shutdown read")
+ return
+ logging.info("Virtual sdcard (%d): %s\nUpcoming (%d): %s",
+ readpos, repr(data[:readcount]),
+ self.file_position, repr(data[readcount:]))
+ def stats(self, eventtime):
+ if self.work_timer is None:
+ return False, ""
+ return True, "sd_pos=%d" % (self.file_position,)
def get_file_list(self):
dname = self.sdcard_dirname
try:
@@ -113,6 +128,7 @@ class VirtualSD:
self.file_position, self.file_size))
# Background work timer
def work_handler(self, eventtime):
+ logging.info("Starting SD card print (position %d)", self.file_position)
self.reactor.unregister_timer(self.work_timer)
try:
self.current_file.seek(self.file_position)
@@ -136,6 +152,7 @@ class VirtualSD:
# End of file
self.current_file.close()
self.current_file = None
+ logging.info("Finished SD card print")
self.gcode.respond("Done printing file")
break
lines = data.split('\n')
@@ -155,6 +172,7 @@ class VirtualSD:
logging.exception("virtual_sdcard dispatch")
break
self.file_position += len(lines.pop()) + 1
+ logging.info("Exiting SD card print (position %d)", self.file_position)
self.work_timer = None
return self.reactor.NEVER