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:
|
class GCodeParser:
|
||||||
error = homing.CommandError
|
error = homing.CommandError
|
||||||
RETRY_TIME = 0.100
|
RETRY_TIME = 0.100
|
||||||
def __init__(self, printer, fd):
|
def __init__(self, printer):
|
||||||
self.printer = 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:ready", self._handle_ready)
|
||||||
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
||||||
printer.register_event_handler("klippy:disconnect",
|
printer.register_event_handler("klippy:disconnect",
|
||||||
|
|
|
@ -48,7 +48,7 @@ Printer is shutdown
|
||||||
class Printer:
|
class Printer:
|
||||||
config_error = configfile.error
|
config_error = configfile.error
|
||||||
command_error = homing.CommandError
|
command_error = homing.CommandError
|
||||||
def __init__(self, input_fd, bglogger, start_args):
|
def __init__(self, bglogger, start_args):
|
||||||
self.bglogger = bglogger
|
self.bglogger = bglogger
|
||||||
self.start_args = start_args
|
self.start_args = start_args
|
||||||
self.reactor = reactor.Reactor()
|
self.reactor = reactor.Reactor()
|
||||||
|
@ -59,7 +59,7 @@ class Printer:
|
||||||
self.event_handlers = {}
|
self.event_handlers = {}
|
||||||
self.objects = collections.OrderedDict()
|
self.objects = collections.OrderedDict()
|
||||||
self.objects['webhooks'] = webhooks.WebHooks(self)
|
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):
|
def get_start_args(self):
|
||||||
return self.start_args
|
return self.start_args
|
||||||
def get_reactor(self):
|
def get_reactor(self):
|
||||||
|
@ -260,20 +260,19 @@ def main():
|
||||||
opts.error("Incorrect number of arguments")
|
opts.error("Incorrect number of arguments")
|
||||||
start_args = {'config_file': args[0], 'start_reason': 'startup'}
|
start_args = {'config_file': args[0], 'start_reason': 'startup'}
|
||||||
|
|
||||||
input_fd = bglogger = None
|
|
||||||
|
|
||||||
debuglevel = logging.INFO
|
debuglevel = logging.INFO
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
debuglevel = logging.DEBUG
|
debuglevel = logging.DEBUG
|
||||||
if options.debuginput:
|
if options.debuginput:
|
||||||
start_args['debuginput'] = options.debuginput
|
start_args['debuginput'] = options.debuginput
|
||||||
debuginput = open(options.debuginput, 'rb')
|
debuginput = open(options.debuginput, 'rb')
|
||||||
input_fd = debuginput.fileno()
|
start_args['gcode_fd'] = debuginput.fileno()
|
||||||
else:
|
else:
|
||||||
input_fd = util.create_pty(options.inputtty)
|
start_args['gcode_fd'] = util.create_pty(options.inputtty)
|
||||||
if options.debugoutput:
|
if options.debugoutput:
|
||||||
start_args['debugoutput'] = options.debugoutput
|
start_args['debugoutput'] = options.debugoutput
|
||||||
start_args.update(options.dictionary)
|
start_args.update(options.dictionary)
|
||||||
|
bglogger = None
|
||||||
if options.logfile:
|
if options.logfile:
|
||||||
start_args['log_file'] = options.logfile
|
start_args['log_file'] = options.logfile
|
||||||
bglogger = queuelogger.setup_bg_logging(options.logfile, debuglevel)
|
bglogger = queuelogger.setup_bg_logging(options.logfile, debuglevel)
|
||||||
|
@ -298,7 +297,7 @@ def main():
|
||||||
if bglogger is not None:
|
if bglogger is not None:
|
||||||
bglogger.clear_rollover_info()
|
bglogger.clear_rollover_info()
|
||||||
bglogger.set_rollover_info('versions', versions)
|
bglogger.set_rollover_info('versions', versions)
|
||||||
printer = Printer(input_fd, bglogger, start_args)
|
printer = Printer(bglogger, start_args)
|
||||||
res = printer.run()
|
res = printer.run()
|
||||||
if res in ['exit', 'error_exit']:
|
if res in ['exit', 'error_exit']:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue