From 35e20162ec8dc38cb69a4ae929745ab654e10186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 22 Feb 2016 13:33:34 +0100 Subject: [PATCH] Revert "Improved connecting phase" Improved connecting for some printers, destroyed it completely for others, so this needs some more work/ thought before it's ready for prime time. This reverts commit c82ec3d3afced3d6fd6e93b65d53edffe60e8552. --- src/octoprint/util/comm.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 2cea2d2a..6bea89a9 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -887,25 +887,10 @@ class MachineCom(object): connection_timeout = settings().getFloat(["serial", "timeout", "connection"]) detection_timeout = settings().getFloat(["serial", "timeout", "detection"]) - # M110 polling during connection phase + # enqueue an M105 first thing if try_hello: - # we do this repeatedly since depending on firmware/bootloader/cable it might happen - # that stuff gets lost during connection initialization, and if that stuff happens - # to be an "ok", we'll get stuck - # - # so let's make things a bit more robust here and just have it send an M110 every second - # while in "connecting" state so that we can retrigger an M110 processing if the "ok" - # for the first one gets lost - - def poll_connection(): - self._logger.debug("Performing M110 poll") - self._sendCommand("M110") - self._clear_to_send.set() - connection_poller = RepeatedTimer(1, poll_connection, - run_first=True, - condition=lambda: self._state == self.STATE_CONNECTING, - on_finish=lambda: self._logger.debug("Stopping M110 poll, no longer connecting")) - connection_poller.start() + self._sendCommand("M110") + self._clear_to_send.set() while self._monitoring_active: try: @@ -1131,10 +1116,6 @@ class MachineCom(object): ### Baudrate detection if self._state == self.STATE_DETECT_BAUDRATE: - # TODO this needs to be rewritten to make use of a repeated timer and to move it outside of the monitor thread - # makes way more sense to have it as a separate function that is part of the connection attempt, not of - # the protocol implementation - # that whole _monitor loop is soooo ugly... if line == '' or time.time() > self._timeout: if self._baudrateDetectRetry > 0: self._serial.timeout = detection_timeout @@ -1170,6 +1151,8 @@ class MachineCom(object): elif self._state == self.STATE_CONNECTING: if "start" in line and not startSeen: startSeen = True + self._sendCommand("M110") + self._clear_to_send.set() elif line.startswith("ok"): self._onConnected() elif time.time() > self._timeout: