Ejemplo n.º 1
0
    def refresh_ports(self):
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()
        try:
            ports = get_serial_ports(vid=0x16d0,
                                     pid=0x09e5)  # RED Brick serial console
        except:
            ports = []

        for port in ports:
            self.combo_serial_port.addItem(port.description, port.path)

        self.combo_serial_port.setEnabled(self.combo_serial_port.count() > 0)

        self.connect_button.setEnabled(False)
        if self.combo_serial_port.count() == 0:
            self.combo_serial_port.addItem('No serial port found')
        else:
            self.combo_serial_port.insertItem(0, 'Select...')
            self.combo_serial_port.insertSeparator(1)
            self.combo_serial_port.setCurrentIndex(0)
            if current_text != '':
                index = self.combo_serial_port.findText(current_text)
                if index >= 0:
                    self.combo_serial_port.setCurrentIndex(index)
Ejemplo n.º 2
0
    def refresh_ports(self):
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()
        try:
            ports = get_serial_ports()
        except:
            ports = []

        for port in ports:
            if len(port[1]) > 0 and port[0] != port[1]:
                self.combo_serial_port.addItem(
                    '{0} - {1}'.format(port[0], port[1]), port[0])
            else:
                self.combo_serial_port.addItem(port[0], port[0])

        self.combo_serial_port.setEnabled(self.combo_serial_port.count() > 0)

        self.connect_button.setEnabled(False)
        if self.combo_serial_port.count() == 0:
            self.combo_serial_port.addItem('No serial port found')
        else:
            self.combo_serial_port.insertItem(0, 'Select...')
            self.combo_serial_port.insertSeparator(1)
            self.combo_serial_port.setCurrentIndex(0)
            if current_text != '':
                index = self.combo_serial_port.findText(current_text)
                if index >= 0:
                    self.combo_serial_port.setCurrentIndex(index)
Ejemplo n.º 3
0
    def refresh_ports(self):
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()
        try:
            ports = get_serial_ports()
        except:
            ports = []

        for port in ports:
            if len(port[1]) > 0 and port[0] != port[1]:
                self.combo_serial_port.addItem('{0} - {1}'.format(port[0], port[1]), port[0])
            else:
                self.combo_serial_port.addItem(port[0], port[0])

        self.combo_serial_port.setEnabled(self.combo_serial_port.count() > 0)

        self.connect_button.setEnabled(False)
        if self.combo_serial_port.count() == 0:
            self.combo_serial_port.addItem('No serial port found')
        else:
            self.combo_serial_port.insertItem(0, 'Select...')
            self.combo_serial_port.insertSeparator(1)
            self.combo_serial_port.setCurrentIndex(0)
            if current_text != '':
                index = self.combo_serial_port.findText(current_text)
                if index >= 0:
                    self.combo_serial_port.setCurrentIndex(index)
Ejemplo n.º 4
0
    def refresh_serial_ports(self):
        progress = self.create_progress_bar('Discovering')
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()

        try:
            progress.setLabelText('Discovering serial ports')
            progress.setMaximum(0)
            progress.setValue(0)
            progress.show()

            ports = get_serial_ports()
        except:
            progress.cancel()
            self.combo_serial_port.addItem(NO_BOOTLOADER)
            self.update_ui_state()
            self.popup_fail('Brick', 'Could not discover serial ports')
        else:
            preferred_index = None

            for port in ports:
                if preferred_index is None:
                    if 'ttyACM' in port[0] or \
                       'ttyUSB' in port[0] or \
                       'usbmodemfd' in port[0] or \
                       'AT91 USB to Serial Converter' in port[1] or \
                       'GPS Camera Detect' in port[1]:
                        preferred_index = self.combo_serial_port.count()

                if len(port[1]) > 0 and port[0] != port[1]:
                    self.combo_serial_port.addItem(u'{0} - {1}'.format(port[0], port[1]), port[0])
                else:
                    self.combo_serial_port.addItem(port[0], port[0])

            if self.combo_serial_port.count() == 0:
                self.combo_serial_port.addItem(NO_BOOTLOADER)
            elif preferred_index is not None:
                self.combo_serial_port.setCurrentIndex(preferred_index)
            else:
                index = self.combo_serial_port.findText(current_text)
                if index >= 0:
                    self.combo_serial_port.setCurrentIndex(index)

            self.update_ui_state()

        progress.cancel()
Ejemplo n.º 5
0
    def refresh_ports(self):
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()
        try:
            ports = get_serial_ports()
        except:
            ports = []

        preferred_index = None

        for port in ports:
            if preferred_index is None:
                if 'ttyACM' in port[0] or \
                   'ttyUSB' in port[0] or \
                   'RED Brick' in port[1] or \
                   'usbmodem' in port[0]:
                    preferred_index = self.combo_serial_port.count()

            if len(port[1]) > 0 and port[0] != port[1]:
                self.combo_serial_port.addItem(
                    u'{0} - {1}'.format(port[0], port[1]), port[0])
            else:
                self.combo_serial_port.addItem(port[0], port[0])

        self.combo_serial_port.setEnabled(self.combo_serial_port.count() > 0)

        if self.combo_serial_port.count() == 0:
            self.combo_serial_port.addItem('No serial port found')
            self.connect_button.setEnabled(False)
        elif preferred_index is not None:
            self.combo_serial_port.setCurrentIndex(preferred_index)
            self.connect_button.setEnabled(True)
        else:
            self.connect_button.setEnabled(True)
            index = self.combo_serial_port.findText(current_text)
            if index >= 0:
                self.combo_serial_port.setCurrentIndex(index)
Ejemplo n.º 6
0
    def refresh_ports(self):
        current_text = self.combo_serial_port.currentText()
        self.combo_serial_port.clear()
        try:
            ports = get_serial_ports()
        except:
            ports = []

        preferred_index = None

        for port in ports:
            if preferred_index is None:
                if 'ttyACM' in port[0] or \
                   'ttyUSB' in port[0] or \
                   'RED Brick' in port[1] or \
                   'usbmodem' in port[0]:
                    preferred_index = self.combo_serial_port.count()

            if len(port[1]) > 0 and port[0] != port[1]:
                self.combo_serial_port.addItem(u'{0} - {1}'.format(port[0], port[1]), port[0])
            else:
                self.combo_serial_port.addItem(port[0], port[0])

        self.combo_serial_port.setEnabled(self.combo_serial_port.count() > 0)

        if self.combo_serial_port.count() == 0:
            self.combo_serial_port.addItem('No serial port found')
            self.connect_button.setEnabled(False)
        elif preferred_index is not None:
            self.combo_serial_port.setCurrentIndex(preferred_index)
            self.connect_button.setEnabled(True)
        else:
            self.connect_button.setEnabled(True)
            index = self.combo_serial_port.findText(current_text)
            if index >= 0:
                self.combo_serial_port.setCurrentIndex(index)