Ejemplo n.º 1
0
 def _factory_default_button_fired(self):
     confirm_prompt = prompt.CallbackPrompt(
         title="Reset to Factory Defaults?",
         actions=[prompt.close_button, prompt.reset_button],
         callback=self.reset_factory_defaults)
     confirm_prompt.text = "This will erase all settings and then reset the device.\n" \
                         + "Are you sure you want to reset to factory defaults?"
     confirm_prompt.run(block=False)
Ejemplo n.º 2
0
    def create_flash(self, flash_type):
        """
    Create flash.Flash instance and set Piksi into bootloader mode, prompting
    user to reset if necessary.

    Parameter
    ---------
    flash_type : string
      Either "STM" or "M25".
    """
        # Reset device if the application is running to put into bootloader mode.
        self.link(MsgReset())

        self.pk_boot = bootload.Bootloader(self.link)

        self._write("Waiting for bootloader handshake message from Piksi ...")
        reset_prompt = None
        handshake_received = self.pk_boot.handshake(1)

        # Prompt user to reset Piksi if we don't receive the handshake message
        # within a reasonable amount of tiime (firmware might be corrupted).
        while not handshake_received:
            reset_prompt = \
              prompt.CallbackPrompt(
                                    title="Please Reset Piksi",
                                    actions=[prompt.close_button],
                                   )

            reset_prompt.text = \
                  "You must press the reset button on your Piksi in order\n" + \
                  "to update your firmware.\n\n" + \
                  "Please press it now.\n\n"

            reset_prompt.run(block=False)

            while not reset_prompt.closed and not handshake_received:
                handshake_received = self.pk_boot.handshake(1)

            reset_prompt.kill()
            reset_prompt.wait()

        self._write("received bootloader handshake message.")
        self._write("Piksi Onboard Bootloader Version: " +
                    self.pk_boot.version)

        self.pk_flash = flash.Flash(self.link, flash_type,
                                    self.pk_boot.sbp_version)
Ejemplo n.º 3
0
  def create_flash(self, flash_type):

    # Reset device if the application is running to put into bootloader mode.
    self.link.send_message(ids.RESET, '')

    self.pk_boot = bootload.Bootloader(self.link)

    self._write("Waiting for bootloader handshake message from Piksi ...")
    reset_prompt = None
    handshake_received = self.pk_boot.wait_for_handshake(1)

    # Prompt user to reset Piksi if we don't receive the handshake message
    # within a reasonable amount of tiime (firmware might be corrupted).
    while not handshake_received:
      reset_prompt = \
        prompt.CallbackPrompt(
                              title="Please Reset Piksi",
                              actions=[prompt.close_button],
                             )

      reset_prompt.text = \
            "You must press the reset button on your Piksi in order\n" + \
            "to update your firmware.\n\n" + \
            "Please press it now.\n\n"

      reset_prompt.run(block=False)

      while not reset_prompt.closed and not handshake_received:
        handshake_received = self.pk_boot.wait_for_handshake(1)

      reset_prompt.kill()
      reset_prompt.wait()

    self.pk_boot.reply_handshake()
    self._write("received bootloader handshake message.")
    self._write("Piksi Onboard Bootloader Version: " + self.pk_boot.version)

    self.pk_flash = flash.Flash(self.link, flash_type)
Ejemplo n.º 4
0
    def _compare_versions(self):
        """
    Compares version info between received firmware version / current console
    and firmware / console info from website to decide if current firmware or
    console is out of date. Prompt user to update if so.
    """
        # Check that settings received from Piksi contain FW versions.
        try:
            self.piksi_stm_vers = \
              self.settings['system_info']['firmware_version'].value
            self.piksi_nap_vers = \
              self.settings['system_info']['nap_version'].value
        except KeyError:
            self._write(
                "\nError: Settings received from Piksi don't contain firmware version keys. Please contact Swift Navigation.\n"
            )
            return

        # Check that we received the index file from the website.
        if self.update_dl == None:
            self._write(
                "Error: No website index to use to compare versions with local firmware"
            )
            return

        # Check if console is out of date and notify user if so.
        if self.prompt:
            local_console_version = parse_version(CONSOLE_VERSION)
            remote_console_version = parse_version(self.newest_console_vers)
            self.console_outdated = remote_console_version > local_console_version

            if self.console_outdated:
                console_outdated_prompt = \
                    prompt.CallbackPrompt(
                                          title="Piksi Console Outdated",
                                          actions=[prompt.close_button],
                                         )

                console_outdated_prompt.text = \
                    "Your Piksi Console is out of date and may be incompatible\n" + \
                    "with current firmware. We highly recommend upgrading to\n" + \
                    "ensure proper behavior.\n\n" + \
                    "Please visit http://downloads.swiftnav.com to\n" + \
                    "download the newest version.\n\n" + \
                    "Local Console Version :\n\t" + \
                        CONSOLE_VERSION + \
                    "\nNewest Console Version :\n\t" + \
                        self.update_dl.index['piksi_v2.3.1']['console']['version'] + "\n"

                console_outdated_prompt.run()

        # For timing aesthetics between windows popping up.
        sleep(0.5)

        # Check if firmware is out of date and notify user if so.
        if self.prompt:
            local_stm_version = parse_version(
                self.settings['system_info']['firmware_version'].value)
            remote_stm_version = parse_version(self.newest_stm_vers)

            local_nap_version = parse_version(
                self.settings['system_info']['nap_version'].value)
            remote_nap_version = parse_version(self.newest_nap_vers)

            self.fw_outdated = remote_nap_version > local_nap_version or \
                               remote_stm_version > local_stm_version

            if self.fw_outdated:
                fw_update_prompt = \
                    prompt.CallbackPrompt(
                                          title='Firmware Update',
                                          actions=[prompt.close_button]
                                         )

                fw_update_prompt.text = \
                    "New Piksi firmware available.\n\n" + \
                    "Please use the Firmware Update tab to update.\n\n" + \
                    "Newest STM Version :\n\t%s\n\n" % \
                        self.update_dl.index['piksi_v2.3.1']['stm_fw']['version'] + \
                    "Newest SwiftNAP Version :\n\t%s\n\n" % \
                        self.update_dl.index['piksi_v2.3.1']['nap_fw']['version']

                fw_update_prompt.run()