aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
Diffstat (limited to 'klippy')
-rw-r--r--klippy/gcode.py6
-rw-r--r--klippy/mcu.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 057f845a..87b45f96 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -17,6 +17,8 @@ class GCodeParser:
self.printer = printer
self.fd = fd
printer.register_event_handler("klippy:shutdown", self.handle_shutdown)
+ printer.register_event_handler("klippy:disconnect",
+ self.handle_disconnect)
# Input handling
self.reactor = printer.get_reactor()
self.is_processing_data = False
@@ -122,10 +124,10 @@ class GCodeParser:
if self.is_fileinput:
self.printer.request_exit('error_exit')
self._respond_state("Shutdown")
+ def handle_disconnect(self):
+ self._respond_state("Disconnect")
def printer_state(self, state):
if state != 'ready':
- if state == 'disconnect':
- self._respond_state("Disconnect")
return
self.is_printer_ready = True
self.gcode_handlers = self.ready_gcode_handlers
diff --git a/klippy/mcu.py b/klippy/mcu.py
index a8e823c7..ee0cbd1a 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -423,6 +423,8 @@ class MCU:
if self._name.startswith('mcu '):
self._name = self._name[4:]
self._printer.register_event_handler("klippy:shutdown", self._shutdown)
+ self._printer.register_event_handler("klippy:disconnect",
+ self._disconnect)
# Serial port
self._serialport = config.get('serial', '/dev/ttyS0')
baud = 0
@@ -768,8 +770,6 @@ class MCU:
def printer_state(self, state):
if state == 'connect':
self._connect()
- elif state == 'disconnect':
- self._disconnect()
def __del__(self):
self._disconnect()