aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/gcode.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-08-04 14:42:07 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-08-06 14:21:08 -0400
commit8ed1696624ea76427bf1c13ae61a5f2289eb2e6b (patch)
tree25825b04bd8f37ea1eb2227ed28526a07fb7655e /klippy/gcode.py
parent8a69e5d596f8f38d85a03d1cd24bdbe32a8b3b84 (diff)
downloadkutter-8ed1696624ea76427bf1c13ae61a5f2289eb2e6b.tar.gz
kutter-8ed1696624ea76427bf1c13ae61a5f2289eb2e6b.tar.xz
kutter-8ed1696624ea76427bf1c13ae61a5f2289eb2e6b.zip
gcode: Only write to the gcode pseudo-tty if it appears to be active
If there isn't a reader of the output pipe it can lead to the generation of a large number of errors. Only attempt to write if it appears the pipe is active. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r--klippy/gcode.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index d517a3f0..3428ce4f 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -83,6 +83,7 @@ class GCodeParser:
self.reactor = printer.get_reactor()
self.is_processing_data = False
self.is_fileinput = not not printer.get_start_args().get("debuginput")
+ self.pipe_is_active = not self.is_fileinput
self.fd_handle = None
if not self.is_fileinput:
self.fd_handle = self.reactor.register_fd(self.fd,
@@ -328,8 +329,10 @@ class GCodeParser:
self.partial_input = lines.pop()
pending_commands = self.pending_commands
pending_commands.extend(lines)
- # Special handling for debug file input EOF
- if not data and self.is_fileinput:
+ if not self.is_fileinput:
+ self.pipe_is_active = True
+ elif not data:
+ # Special handling for debug file input EOF
if not self.is_processing_data:
self.reactor.unregister_fd(self.fd_handle)
self.fd_handle = None
@@ -387,12 +390,12 @@ class GCodeParser:
return GCodeCommand(self, command, commandline, params, False)
# Response handling
def respond_raw(self, msg):
- if self.is_fileinput:
- return
- try:
- os.write(self.fd, msg+"\n")
- except os.error:
- logging.exception("Write g-code response")
+ if self.pipe_is_active:
+ try:
+ os.write(self.fd, msg+"\n")
+ except os.error:
+ logging.exception("Write g-code response")
+ self.pipe_is_active = False
def respond_info(self, msg, log=True):
if log:
logging.info(msg)