chiark / gitweb /
Update config wizard steps to reflect schema in M3
[cura.git] / Cura / serialCommunication.py
index efff5e0d04bbd461d512a6e21020de16b391d62d..4add5f2314d8c1efd58ac48055ecc5fae0d08a05 100644 (file)
@@ -51,9 +51,14 @@ class serialComm(object):
                pass
 
        def monitorStdin(self):
-               while not self._comm.isClosed():
-                       line = sys.stdin.readline().strip()
-                       line = line.split(':', 1)
+               while not (self._comm.isClosed() or sys.stdin.closed):
+                       line = sys.stdin.readline()
+                        # If readline returns an empty string it means that
+                        # we've hit stdin's EOF, probably because the parent was
+                        # closed, so we need to exit as well instead of spamming stderr.
+                        if line == '':
+                                break
+                       line = line.strip().split(':', 1)
                        if line[0] == 'STOP':
                                self._comm.cancelPrint()
                                self._gcodeList = ['M110']
@@ -63,6 +68,10 @@ class serialComm(object):
                                self._comm.sendCommand(line[1])
                        elif line[0] == 'START':
                                self._comm.printGCode(self._gcodeList)
+                       elif line[0] == 'PAUSE':
+                               self._comm.setPause(True)
+                       elif line[0] == 'RESUME':
+                               self._comm.setPause(False)
                        else:
                                sys.stderr.write(str(line))