gcode: Pass the pseudo-tty fd via the start_args system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
b66dd1a60f
commit
0d930bf871
|
@ -70,9 +70,9 @@ class GCodeCommand:
|
|||
class GCodeParser:
|
||||
error = homing.CommandError
|
||||
RETRY_TIME = 0.100
|
||||
def __init__(self, printer, fd):
|
||||
def __init__(self, printer):
|
||||
self.printer = printer
|
||||
self.fd = fd
|
||||
self.fd = printer.get_start_args().get("gcode_fd")
|
||||
printer.register_event_handler("klippy:ready", self._handle_ready)
|
||||
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
||||
printer.register_event_handler("klippy:disconnect",
|
||||
|
|
|
@ -48,7 +48,7 @@ Printer is shutdown
|
|||
class Printer:
|
||||
config_error = configfile.error
|
||||
command_error = homing.CommandError
|
||||
def __init__(self, input_fd, bglogger, start_args):
|
||||
def __init__(self, bglogger, start_args):
|
||||
self.bglogger = bglogger
|
||||
self.start_args = start_args
|
||||
self.reactor = reactor.Reactor()
|
||||
|
@ -59,7 +59,7 @@ class Printer:
|
|||
self.event_handlers = {}
|
||||
self.objects = collections.OrderedDict()
|
||||
self.objects['webhooks'] = webhooks.WebHooks(self)
|
||||
self.objects['gcode'] = gcode.GCodeParser(self, input_fd)
|
||||
self.objects['gcode'] = gcode.GCodeParser(self)
|
||||
def get_start_args(self):
|
||||
return self.start_args
|
||||
def get_reactor(self):
|
||||
|
@ -260,20 +260,19 @@ def main():
|
|||
opts.error("Incorrect number of arguments")
|
||||
start_args = {'config_file': args[0], 'start_reason': 'startup'}
|
||||
|
||||
input_fd = bglogger = None
|
||||
|
||||
debuglevel = logging.INFO
|
||||
if options.verbose:
|
||||
debuglevel = logging.DEBUG
|
||||
if options.debuginput:
|
||||
start_args['debuginput'] = options.debuginput
|
||||
debuginput = open(options.debuginput, 'rb')
|
||||
input_fd = debuginput.fileno()
|
||||
start_args['gcode_fd'] = debuginput.fileno()
|
||||
else:
|
||||
input_fd = util.create_pty(options.inputtty)
|
||||
start_args['gcode_fd'] = util.create_pty(options.inputtty)
|
||||
if options.debugoutput:
|
||||
start_args['debugoutput'] = options.debugoutput
|
||||
start_args.update(options.dictionary)
|
||||
bglogger = None
|
||||
if options.logfile:
|
||||
start_args['log_file'] = options.logfile
|
||||
bglogger = queuelogger.setup_bg_logging(options.logfile, debuglevel)
|
||||
|
@ -298,7 +297,7 @@ def main():
|
|||
if bglogger is not None:
|
||||
bglogger.clear_rollover_info()
|
||||
bglogger.set_rollover_info('versions', versions)
|
||||
printer = Printer(input_fd, bglogger, start_args)
|
||||
printer = Printer(bglogger, start_args)
|
||||
res = printer.run()
|
||||
if res in ['exit', 'error_exit']:
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue