chiark / gitweb /
Better catch errors in first run wizard.
[cura.git] / Cura / gui / machineCom.py
index 5157fbe87d8e76975b215ee5dcfb939a9825476c..73837d48adf2e3023c27714527dba26c102f9c72 100644 (file)
@@ -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