Exemplo n.º 1
0
    def preferences_clicked(self, widget):
        board_combo = self.builder.get_object("board_combo")
        sport_combo = self.builder.get_object("sport_combo")
        baud_combo = self.builder.get_object("baud_combo")
        dialog = self.builder.get_object("preferences_dialog")
        jpeg_check = self.builder.get_object("jpeg_check")

        # Fill serial ports combo
        sport_combo.get_model().clear()
        serial_ports = self.list_serial_ports()
        for i in serial_ports:
            sport_combo.append_text(i)

        if len(serial_ports):
            sport_combo.set_active(0)

        jpeg_check.set_active(self.enable_jpeg)

        # Save config
        if dialog.run() == gtk.RESPONSE_OK:
            self.config.set("main", "board", board_combo.get_active_text())
            self.config.set("main", "serial_port", sport_combo.get_active_text())
            self.config.set("main", "baudrate", baud_combo.get_active_text())
            self.config.set("main", "enable_jpeg", jpeg_check.get_active())
            self.enable_jpeg = jpeg_check.get_active()
            self.save_config()

        # Enable/Disable JPEG
        if (self.connected):
            openmv.enable_jpeg(self.enable_jpeg)

        dialog.hide()
Exemplo n.º 2
0
    def preferences_clicked(self, widget):
        board_combo = self.builder.get_object("board_combo")
        sport_combo = self.builder.get_object("sport_combo")
        baud_combo = self.builder.get_object("baud_combo")
        dialog = self.builder.get_object("preferences_dialog")
        jpeg_check = self.builder.get_object("jpeg_check")

        # Fill serial ports combo
        sport_combo.get_model().clear()
        serial_ports = self.list_serial_ports()
        for i in serial_ports:
            sport_combo.append_text(i)

        if len(serial_ports):
            sport_combo.set_active(0)

        jpeg_check.set_active(self.enable_jpeg)

        # Save config
        if dialog.run() == gtk.RESPONSE_OK:
            self.config.set("main", "board", board_combo.get_active_text())
            self.config.set("main", "serial_port",
                            sport_combo.get_active_text())
            self.config.set("main", "baudrate", baud_combo.get_active_text())
            self.config.set("main", "enable_jpeg", jpeg_check.get_active())
            self.enable_jpeg = jpeg_check.get_active()
            self.save_config()

        # Enable/Disable JPEG
        if (self.connected):
            openmv.enable_jpeg(self.enable_jpeg)

        dialog.hide()
Exemplo n.º 3
0
    def connect(self):
        connected = False
        openmv.disconnect()
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"),
                            baudrate=self.baudrate,
                            timeout=0.050)
                connected = True
                break
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = (
                    "Failed to open serial port.\n"
                    "Please install OpenMV's udev rules first:\n\n"
                    "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                    "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,
                                     "%s%s" % (error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.

        # check firmware version
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)
        print("fw_version:%s\nide_version:%s" % (str(fw_ver), str(ide_ver)))

        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR
                or fw_ver[1] != FIRMWARE_VERSION_MINOR):
            self.connected = False
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware version mismatch!\n"
                "Please update the firmware image and/or the IDE!")
        else:
            self.connected = True
            self._update_title()
            map(lambda x: x.set_sensitive(True), self.controls)

            # Interrupt running code
            openmv.stop_script()

            # Enable JPEG transfers
            openmv.enable_jpeg(self.enable_jpeg)

        # Disable connect button
        self.connect_button.set_sensitive(False)
Exemplo n.º 4
0
    def connect(self):
        connected = False
        openmv.disconnect()
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.050)
                connected = True
                break
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = ("Failed to open serial port.\n"
                             "Please install OpenMV's udev rules first:\n\n"
                             "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                             "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1*2) # SD Cards can cause big hicups.

        # check firmware version
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCH)
        print("fw_version:%s\nide_version:%s" %(str(fw_ver), str(ide_ver)))

        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR or fw_ver[1] != FIRMWARE_VERSION_MINOR):
            self.connected = False
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                    "Firmware version mismatch!\n"
                    "Please update the firmware image and/or the IDE!")
        else:
            self.connected = True
            self._update_title()
            map(lambda x:x.set_sensitive(True), self.controls)

            # Interrupt running code
            openmv.stop_script()

            # Enable JPEG transfers
            openmv.enable_jpeg(self.enable_jpeg)

        # Disable connect button
        self.connect_button.set_sensitive(False)
Exemplo n.º 5
0
    def preferences_clicked(self, widget):
        board_combo = self.builder.get_object("board_combo")
        sport_combo = self.builder.get_object("sport_combo")
        baud_combo = self.builder.get_object("baud_combo")
        dialog = self.builder.get_object("preferences_dialog")
        jpeg_check = self.builder.get_object("jpeg_check")

        # Set selected board
        board_combo.get_model().clear()
        config_board = self.config.get("main", "board")
        for i in range(0, len(OPENMV_BOARDS)):
            board = OPENMV_BOARDS[i]
            board_combo.append_text(board)
            if (board == config_board):
                board_combo.set_active(i)

        # Fill serial ports combo
        sport_combo.get_model().clear()
        serial_ports = self.list_serial_ports()
        config_port = self.config.get("main", "serial_port")
        for i in range(0, len(serial_ports)):
            port = serial_ports[i]
            sport_combo.append_text(port)
            if (port == config_port):
                sport_combo.set_active(i)

        jpeg_check.set_active(self.enable_jpeg)

        # Save config
        if dialog.run() == gtk.RESPONSE_OK:
            self.config.set("main", "board", board_combo.get_active_text())
            self.config.set("main", "serial_port",
                            sport_combo.get_active_text())
            self.config.set("main", "baudrate", baud_combo.get_active_text())
            self.config.set("main", "enable_jpeg", jpeg_check.get_active())
            self.enable_jpeg = jpeg_check.get_active()
            self.save_config()

        # Enable/Disable JPEG
        if (self.connected):
            openmv.enable_jpeg(self.enable_jpeg)

        dialog.hide()
Exemplo n.º 6
0
    def preferences_clicked(self, widget):
        board_combo = self.builder.get_object("board_combo")
        sport_combo = self.builder.get_object("sport_combo")
        baud_combo = self.builder.get_object("baud_combo")
        dialog = self.builder.get_object("preferences_dialog")
        jpeg_check = self.builder.get_object("jpeg_check")

        # Set selected board
        board_combo.get_model().clear()
        config_board = self.config.get("main", "board")
        for i in range(0, len(OPENMV_BOARDS)):
            board = OPENMV_BOARDS[i]
            board_combo.append_text(board)
            if (board == config_board):
                board_combo.set_active(i)

        # Fill serial ports combo
        sport_combo.get_model().clear()
        serial_ports = self.list_serial_ports()
        config_port = self.config.get("main", "serial_port")
        for i in range(0, len(serial_ports)):
            port = serial_ports[i]
            sport_combo.append_text(port)
            if (port == config_port):
                sport_combo.set_active(i)

        jpeg_check.set_active(self.enable_jpeg)

        # Save config
        if dialog.run() == gtk.RESPONSE_OK:
            self.config.set("main", "board", board_combo.get_active_text())
            self.config.set("main", "serial_port", sport_combo.get_active_text())
            self.config.set("main", "baudrate", baud_combo.get_active_text())
            self.config.set("main", "enable_jpeg", jpeg_check.get_active())
            self.enable_jpeg = jpeg_check.get_active()
            self.save_config()

        # Enable/Disable JPEG
        if (self.connected):
            openmv.enable_jpeg(self.enable_jpeg)

        dialog.hide()
Exemplo n.º 7
0
    def connect(self):
        connected = False
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"), baudrate=self.baudrate, timeout=0.050)
                connected = True
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = ("Failed to open serial port.\n"
                             "Please install OpenMV's udev rules first:\n\n"
                             "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                             "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,"%s%s"%(error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(0.3)

        # add terminal update callback
        gobject.gobject.timeout_add(30, omvgtk.update_terminal)

        # check firmware version
        self.fw_mismatch = False
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR,
                   FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)

        print("fw_version:" + str(fw_ver))
        print("ide_version:" + str(ide_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            # If ABI versions don't match, nothing todo here...
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                            "Firmware ABI version mismatch!\n"
                            "Please update the IDE and/or FW manually\n")
            return
        elif (FIRMWARE_VERSION_MINOR > fw_ver[1]
                or FIRMWARE_VERSION_PATCH > fw_ver[2]):
            self.fw_mismatch = True
            self.show_message_dialog(gtk.MESSAGE_ERROR,
                    "Firmware version mismatch!\n"
                    "An older firmware version has been detected.\n"
                    "Please update the firmware!")

        if (self.fw_mismatch):
            self.connected = True
            self.connect_button.set_sensitive(False)
            self.fwupdate_button.set_sensitive(True)
            return

        # interrupt any running code
        openmv.stop_script()

        # set enable JPEG
        openmv.enable_jpeg(self.enable_jpeg)

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x:x.set_sensitive(True), self.controls)
Exemplo n.º 8
0
    def connect(self):
        connected = False
        for i in range(10):
            try:
                # opens CDC port.
                # Set small timeout when connecting
                openmv.init(self.config.get("main", "serial_port"),
                            baudrate=self.baudrate,
                            timeout=0.050)
                connected = True
                break
            except Exception as e:
                connected = False
                sleep(0.100)

        if not connected:
            # create fresh config if needed
            if platform.system() == "Linux" and not os.path.isfile(UDEV_PATH):
                error_msg = (
                    "Failed to open serial port.\n"
                    "Please install OpenMV's udev rules first:\n\n"
                    "sudo cp openmv/udev/50-openmv.rules /etc/udev/rules.d/\n"
                    "sudo udevadm control --reload-rules\n\n")
            else:
                error_msg = ("Failed to open serial port.\n"
                             "Please check the preferences Dialog.\n")

            self.show_message_dialog(gtk.MESSAGE_ERROR,
                                     "%s%s" % (error_msg, e))
            return

        # Set higher timeout after connecting for lengthy transfers.
        openmv.set_timeout(1 * 2)  # SD Cards can cause big hicups.

        # add terminal update callback
        gobject.gobject.timeout_add(30, omvgtk.update_terminal)

        # check firmware version
        self.fw_mismatch = False
        fw_ver = openmv.fw_version()
        ide_ver = (FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR,
                   FIRMWARE_VERSION_PATCH)

        print("fw_version:" + str(fw_ver))
        print("ide_version:" + str(ide_ver))
        if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
            # If ABI versions don't match, nothing todo here...
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware ABI version mismatch!\n"
                "Please update the IDE and/or FW manually\n")
            return
        elif (FIRMWARE_VERSION_MINOR > fw_ver[1]
              or FIRMWARE_VERSION_PATCH > fw_ver[2]):
            self.fw_mismatch = True
            self.show_message_dialog(
                gtk.MESSAGE_ERROR, "Firmware version mismatch!\n"
                "An older firmware version has been detected.\n"
                "Please update the firmware!")

        if (self.fw_mismatch):
            self.connected = True
            self.connect_button.set_sensitive(False)
            self.fwupdate_button.set_sensitive(True)
            return

        # interrupt any running code
        openmv.stop_script()

        # set enable JPEG
        openmv.enable_jpeg(self.enable_jpeg)

        self.connected = True
        self._update_title()
        self.connect_button.set_sensitive(False)
        map(lambda x: x.set_sensitive(True), self.controls)