aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-27 17:45:58 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-29 21:57:49 -0500
commit535c7b99b43baf50272c71fcaf52b10f1a707175 (patch)
treece25fa2918e650c5da0ce8724f79602dfb370780 /klippy/mcu.py
parent5d805ba55059750e79c8b507d164c55a14c6d737 (diff)
downloadkutter-535c7b99b43baf50272c71fcaf52b10f1a707175.tar.gz
kutter-535c7b99b43baf50272c71fcaf52b10f1a707175.tar.xz
kutter-535c7b99b43baf50272c71fcaf52b10f1a707175.zip
serialhdl: Make SerialReader.connect() blocking
Use the greenlet mechanism to wait for the connection to come up in the serial connect() method. This simplifies the calling code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index d279a847..11581f55 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -342,15 +342,8 @@ class MCU:
self._steppersync = self.ffi_lib.steppersync_alloc(
self.serial.serialqueue, stepqueues, len(stepqueues), count)
def connect(self):
- state_params = {}
- def handle_serial_state(params):
- state_params.update(params)
- self.serial.register_callback(handle_serial_state, '#state')
- self.serial.connect()
- while state_params.get('#state') != 'connected':
- self._printer.reactor.pause(time.time() + 0.05)
- self.serial.unregister_callback('#state')
- logging.info("serial connected")
+ if not self._is_fileoutput:
+ self.serial.connect()
self._mcu_freq = float(self.serial.msgparser.config['CLOCK_FREQ'])
self.register_msg(self.handle_shutdown, 'shutdown')
self.register_msg(self.handle_shutdown, 'is_shutdown')
@@ -358,7 +351,6 @@ class MCU:
def connect_file(self, debugoutput, dictionary, pace=False):
self._is_fileoutput = True
self.serial.connect_file(debugoutput, dictionary)
- self._mcu_freq = float(self.serial.msgparser.config['CLOCK_FREQ'])
def dummy_send_config():
for c in self._config_cmds:
self.send(self.create_command(c))