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>
This commit is contained in:
parent
8a69e5d596
commit
8ed1696624
|
@ -83,6 +83,7 @@ class GCodeParser:
|
||||||
self.reactor = printer.get_reactor()
|
self.reactor = printer.get_reactor()
|
||||||
self.is_processing_data = False
|
self.is_processing_data = False
|
||||||
self.is_fileinput = not not printer.get_start_args().get("debuginput")
|
self.is_fileinput = not not printer.get_start_args().get("debuginput")
|
||||||
|
self.pipe_is_active = not self.is_fileinput
|
||||||
self.fd_handle = None
|
self.fd_handle = None
|
||||||
if not self.is_fileinput:
|
if not self.is_fileinput:
|
||||||
self.fd_handle = self.reactor.register_fd(self.fd,
|
self.fd_handle = self.reactor.register_fd(self.fd,
|
||||||
|
@ -328,8 +329,10 @@ class GCodeParser:
|
||||||
self.partial_input = lines.pop()
|
self.partial_input = lines.pop()
|
||||||
pending_commands = self.pending_commands
|
pending_commands = self.pending_commands
|
||||||
pending_commands.extend(lines)
|
pending_commands.extend(lines)
|
||||||
|
if not self.is_fileinput:
|
||||||
|
self.pipe_is_active = True
|
||||||
|
elif not data:
|
||||||
# Special handling for debug file input EOF
|
# Special handling for debug file input EOF
|
||||||
if not data and self.is_fileinput:
|
|
||||||
if not self.is_processing_data:
|
if not self.is_processing_data:
|
||||||
self.reactor.unregister_fd(self.fd_handle)
|
self.reactor.unregister_fd(self.fd_handle)
|
||||||
self.fd_handle = None
|
self.fd_handle = None
|
||||||
|
@ -387,12 +390,12 @@ class GCodeParser:
|
||||||
return GCodeCommand(self, command, commandline, params, False)
|
return GCodeCommand(self, command, commandline, params, False)
|
||||||
# Response handling
|
# Response handling
|
||||||
def respond_raw(self, msg):
|
def respond_raw(self, msg):
|
||||||
if self.is_fileinput:
|
if self.pipe_is_active:
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.write(self.fd, msg+"\n")
|
os.write(self.fd, msg+"\n")
|
||||||
except os.error:
|
except os.error:
|
||||||
logging.exception("Write g-code response")
|
logging.exception("Write g-code response")
|
||||||
|
self.pipe_is_active = False
|
||||||
def respond_info(self, msg, log=True):
|
def respond_info(self, msg, log=True):
|
||||||
if log:
|
if log:
|
||||||
logging.info(msg)
|
logging.info(msg)
|
||||||
|
|
Loading…
Reference in New Issue