1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
3 # Serial communication with the printer for printing is done from a separate process,
4 # this to ensure that the PIL does not block the serial printing.
10 from Cura.util import machineCom
12 class serialComm(object):
13 def __init__(self, portName):
17 self._comm = machineCom.MachineCom(portName, callbackObject=self)
19 def mcLog(self, message):
20 sys.stdout.write('log:%s\n' % (message))
22 def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):
23 sys.stdout.write('temp:%s\n' % str(temp))
25 def mcStateChange(self, state):
26 if self._comm is None:
28 sys.stdout.write('state:%d:%s\n' % (state, self._comm.getStateString()))
30 def mcMessage(self, message):
31 sys.stdout.write('message:%s\n' % (message))
33 def mcProgress(self, lineNr):
34 sys.stdout.write('progress:%d\n' % (lineNr))
36 def mcZChange(self, newZ):
37 sys.stdout.write('changeZ:%d\n' % (newZ))
39 def monitorStdin(self):
41 while not self._comm.isClosed():
42 line = sys.stdin.readline().strip()
43 line = line.split(':', 1)
45 self._comm.cancelPrint()
48 self._gcodeList.append(line[1])
49 elif line[0] == 'START':
50 self._comm.printGCode(self._gcodeList)
52 sys.stderr.write(str(line))
55 if len(sys.argv) != 2:
57 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
58 portName = sys.argv[1]
59 comm = serialComm(portName)
62 if __name__ == '__main__':