Make serial port access more rebust.
parent
5ae8e44022
commit
16c8c4f588
|
@ -299,7 +299,7 @@ class UltimakerCheckupPage(InfoPage):
|
||||||
self.comm.close()
|
self.comm.close()
|
||||||
return False
|
return False
|
||||||
print line.rstrip()
|
print line.rstrip()
|
||||||
if line.startswith(replyStart):
|
if replyStart in line:
|
||||||
break
|
break
|
||||||
t.cancel()
|
t.cancel()
|
||||||
return line.rstrip()
|
return line.rstrip()
|
||||||
|
@ -385,7 +385,7 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
|
||||||
line = self.comm.readline()
|
line = self.comm.readline()
|
||||||
if line == '':
|
if line == '':
|
||||||
return
|
return
|
||||||
if line.startswith('start'):
|
if 'start' in line:
|
||||||
break
|
break
|
||||||
#Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
|
#Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
@ -417,7 +417,7 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
|
||||||
self.heatButton.Enable(True)
|
self.heatButton.Enable(True)
|
||||||
self.extrudeButton.Enable(True)
|
self.extrudeButton.Enable(True)
|
||||||
return
|
return
|
||||||
if line.startswith('start'):
|
if 'start' in line:
|
||||||
break
|
break
|
||||||
#Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
|
#Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
|
@ -358,7 +358,7 @@ class printWindow(wx.Frame):
|
||||||
self.feedrateRatioSupport = self.supportSpeedSelect.GetValue() / 100.0
|
self.feedrateRatioSupport = self.supportSpeedSelect.GetValue() / 100.0
|
||||||
|
|
||||||
def AddTermLog(self, line):
|
def AddTermLog(self, line):
|
||||||
self.termLog.AppendText(line)
|
self.termLog.AppendText(unicode(line, 'utf-8', 'replace'))
|
||||||
|
|
||||||
def OnTermEnterLine(self, e):
|
def OnTermEnterLine(self, e):
|
||||||
line = self.termInput.GetValue()
|
line = self.termInput.GetValue()
|
||||||
|
|
|
@ -34,7 +34,7 @@ def baudrateList():
|
||||||
|
|
||||||
class VirtualPrinter():
|
class VirtualPrinter():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.readList = ['start\n', 'Marlin: Virtual Marlin!\n']
|
self.readList = ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n']
|
||||||
self.temp = 0.0
|
self.temp = 0.0
|
||||||
self.targetTemp = 0.0
|
self.targetTemp = 0.0
|
||||||
self.lastTempAt = time.time()
|
self.lastTempAt = time.time()
|
||||||
|
@ -135,7 +135,7 @@ class MachineCom():
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
starttime = time.time()
|
starttime = time.time()
|
||||||
for line in ser:
|
for line in ser:
|
||||||
if line.startswith('start'):
|
if 'start' in line:
|
||||||
ser.close()
|
ser.close()
|
||||||
ser = Serial(port, baudrate, timeout=2)
|
ser = Serial(port, baudrate, timeout=2)
|
||||||
ser.setDTR(1)
|
ser.setDTR(1)
|
||||||
|
@ -151,7 +151,11 @@ class MachineCom():
|
||||||
def readline(self):
|
def readline(self):
|
||||||
if self.serial == None:
|
if self.serial == None:
|
||||||
return None
|
return None
|
||||||
|
try:
|
||||||
ret = self.serial.readline()
|
ret = self.serial.readline()
|
||||||
|
except:
|
||||||
|
print "Unexpected error while reading serial port:", sys.exc_info()[0]
|
||||||
|
ret = ''
|
||||||
#if ret != '':
|
#if ret != '':
|
||||||
# print "Recv: " + ret.rstrip()
|
# print "Recv: " + ret.rstrip()
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue