Exemplo n.º 1
0
 def refresh_port_list(self):
     """ Populates the list of available serial ports in the machine.
     May not work under windows at all. Would then require the user to
     provide the proper port. Either via command line or typing it into the
     combobox.
     """
     candidate = None
     for i in range(self.combo_serialports.count()):
         self.combo_serialports.removeItem(0)
     for p in utils.get_port_list():
         if len(p) > 2 and "USB" in p[2]:
             candidate = p
         self.combo_serialports.addItem(p[0])
     if candidate:
         self.combo_serialports.setCurrentIndex(self.combo_serialports.findText(candidate[0]))
Exemplo n.º 2
0
    def auto_connect(self, port=6):
        """
        Try to connect to specific port. If no port specified, try to connect
        to all ports on the port_list. If any of them replies correctly, stop
        and be happy about the connection!
        """
        if port:
            if isinstance(port, basestring):
                port_list = [(port, port)]
            else:
                port_list = [port]
        else:
            port_list = utils.get_port_list()

        for p in port_list:
            try:
                if self.open_serial(p[1]) and self.test_connection():
                    self.serial_port = p[1]
                    self.connected = True
                    return self.connected
            except Exception, e:
                self.log.error(str(e))
                self.log.error('Port is broken or handshake invalid')
Exemplo n.º 3
0
    def auto_connect(self, port=None):
        """
        Try to connect to specific port. If no port specified, try to connect
        to all ports on the port_list. If any of them replies correctly, stop
        and be happy about the connection!
        """
        if port:
            if isinstance(port, basestring):
                port_list = [(port, port)]
            else:
                port_list = [port]
        else:
            port_list = utils.get_port_list()

        for p in port_list:
            try:
                if self.open_serial(p[1]) and self.test_connection():
                    self.serial_port = p[1]
                    self.connected = True
                    return self.connected
            except Exception, e:
                self.log.error(str(e))
                self.log.error('Port is broken or handshake invalid')