master
Guillaume Seguin 2012-08-03 23:47:03 +02:00
parent 898a43e5e5
commit 6a006d785f
1 changed files with 31 additions and 33 deletions

View File

@ -292,7 +292,7 @@ class printcore():
#callback for printing done
def _sendnext(self):
if(not self.printer):
if not self.printer:
return
while self.printer and self.printing and not self.clear:
time.sleep(0.001)
@ -300,19 +300,19 @@ class printcore():
if not (self.printing and self.printer and self.online):
self.clear = True
return
if(self.resendfrom<self.lineno and self.resendfrom>-1):
if self.resendfrom < self.lineno and self.resendfrom > -1:
self._send(self.sentlines[self.resendfrom],self.resendfrom,False)
self.resendfrom += 1
return
self.resendfrom = -1
for i in self.priqueue[:]:
self._send(i)
del(self.priqueue[0])
del self.priqueue[0]
return
if(self.printing and self.queueindex<len(self.mainqueue)):
if self.printing and self.queueindex < len(self.mainqueue):
tline = self.mainqueue[self.queueindex]
tline = tline.split(";")[0]
if(len(tline)>0):
if len(tline) > 0:
self._send(tline, self.lineno, True)
self.lineno += 1
else:
@ -321,26 +321,24 @@ class printcore():
else:
self.printing = False
self.clear = True
if(not self.paused):
if not self.paused:
self.queueindex = 0
self.lineno = 0
self._send("M110", -1, True)
def _send(self, command, lineno = 0, calcchecksum = False):
if(calcchecksum):
if calcchecksum:
prefix = "N" + str(lineno) + " " + command
command = prefix + "*" + str(self._checksum(prefix))
if("M110" not in command):
if "M110" not in command:
self.sentlines[lineno] = command
if(self.printer):
self.sent+=[command]
if self.printer:
self.sent.append(command)
if self.loud:
print "SENT: ",command
if self.sendcb is not None:
try:
self.sendcb(command)
except:
pass
try: self.sendcb(command)
except: pass
try:
self.printer.write(str(command+"\n"))
except SerialException, e: