From 9b2d166c6cd0424053328c8516e6f616f1785bb9 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 25 Mar 2013 14:01:48 -0400 Subject: [PATCH] Prevents manual commands from interupting other commands --- octoprint/util/comm.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index e5382cd..67cacbe 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -197,7 +197,7 @@ class MachineCom(object): self._currentLine = 1 self._resendDelta = None self._lastLines = [] - + self._sending = False self.thread = threading.Thread(target=self._monitor) self.thread.daemon = True self.thread.start() @@ -537,6 +537,10 @@ class MachineCom(object): def _sendCommand(self, cmd, sendChecksum=False): cmd = cmd.upper() + #Wait for current send to finish. + while self._sending: + pass + self._sending = True if self._serial is None: return if 'M109' in cmd or 'M190' in cmd: @@ -621,6 +625,8 @@ class MachineCom(object): self._log("Unexpected error while writing serial port: %s" % (getExceptionString())) self._errorValue = getExceptionString() self.close(True) + #clear sending flag + self._sending = False def _sendNext(self): if self._gcodePos >= len(self._gcodeList):