Better catch errors in first run wizard.
parent
5c7c2c20da
commit
db6c7eaa67
|
@ -174,6 +174,11 @@ class UltimakerCheckupPage(InfoPage):
|
|||
def OnRun(self):
|
||||
wx.CallAfter(self.AddProgressText, "Connecting to machine...")
|
||||
self.comm = machineCom.MachineCom()
|
||||
|
||||
if not self.comm.isOpen():
|
||||
wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine")
|
||||
wx.CallAfter(self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable")
|
||||
return
|
||||
|
||||
wx.CallAfter(self.AddProgressText, "Checking start message...")
|
||||
if self.DoCommCommandWithTimeout(None, 'start') == False:
|
||||
|
@ -288,10 +293,10 @@ class UltimakerCheckupPage(InfoPage):
|
|||
t.start()
|
||||
while True:
|
||||
line = self.comm.readline()
|
||||
if line == '':
|
||||
if line == '' or line == None:
|
||||
self.comm.close()
|
||||
return False
|
||||
print line
|
||||
print line.rstrip()
|
||||
if line.startswith(replyStart):
|
||||
break
|
||||
t.cancel()
|
||||
|
@ -369,6 +374,10 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
|
|||
self.extrudeButton.Enable(False)
|
||||
currentEValue = float(self.stepsPerEInput.GetValue())
|
||||
self.comm = machineCom.MachineCom()
|
||||
if not self.comm.isOpen():
|
||||
wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine")
|
||||
wx.CallAfter(self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable")
|
||||
return
|
||||
while True:
|
||||
line = self.comm.readline()
|
||||
if line == '':
|
||||
|
@ -392,6 +401,10 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
|
|||
|
||||
def OnHeatRun(self):
|
||||
self.comm = machineCom.MachineCom()
|
||||
if not self.comm.isOpen():
|
||||
wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine")
|
||||
wx.CallAfter(self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable")
|
||||
return
|
||||
while True:
|
||||
line = self.comm.readline()
|
||||
if line == '':
|
||||
|
|
|
@ -153,12 +153,13 @@ class MachineCom():
|
|||
programmer = stk500v2.Stk500v2()
|
||||
for port in serialList():
|
||||
try:
|
||||
print "Connecting to: %s %i" % (port, baudrate)
|
||||
programmer.connect(port)
|
||||
programmer.close()
|
||||
print "Connecting to: %s %i" % (port, baudrate)
|
||||
self.serial = Serial(port, baudrate, timeout=2)
|
||||
break
|
||||
except ispBase.IspError:
|
||||
print "Error while connecting to %s %i" % (port, baudrate)
|
||||
pass
|
||||
except:
|
||||
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
|
||||
|
@ -170,6 +171,7 @@ class MachineCom():
|
|||
self.serial = Serial(port, baudrate, timeout=2)
|
||||
except:
|
||||
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
|
||||
print self.serial
|
||||
|
||||
def readline(self):
|
||||
if self.serial == None:
|
||||
|
@ -184,6 +186,12 @@ class MachineCom():
|
|||
self.serial.close()
|
||||
self.serial = None
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def isOpen(self):
|
||||
return self.serial != None
|
||||
|
||||
def sendCommand(self, cmd):
|
||||
if self.serial == None:
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue