示例#1
0
    def _update_stm_firmware_fired(self):
        """
        Handle update_stm_firmware button. Starts thread so as not to block the GUI
        thread.
        """
        ins_settings = self.settings.get('ins', None)
        ins_output_mode = None
        if ins_settings is not None:
            ins_output_mode = ins_settings.get('output_mode').value

        if (ins_output_mode is not None) and not (ins_output_mode.startswith('Disabled') or ins_output_mode.startswith('disabled')):
            ins_disable_prompt = \
                prompt.CallbackPrompt(
                    title="Unsupported Update Request",
                    actions=[prompt.close_button],
                )
            ins_disable_prompt.text = \
                "\n\n" + \
                "Updating firmware is not supported when INS is active.\n\n" + \
                "Please change the 'output mode' INS setting to 'Disabled'\n" + \
                "before updating firmware.\n\n"
            ins_disable_prompt.run(block=False)
            return

        if self.connection_info['mode'] != 'TCP/IP':
            self._write(
                "\n"
                "-----------------------------------------------\n"
                "USB Flashdrive Upgrade Procedure\n"
                "-----------------------------------------------\n"
                "\n"
                "1.\tInsert the USB flash drive provided with your Piksi Multi into your computer.\n"
                "  \tSelect the flash drive root directory as the firmware download destination using the directory chooser above.\n"
                "  \tPress the \"Download Latest Firmware\" button. This will download the latest Piksi Multi firmware file onto\n"
                "  \tthe USB flashdrive.\n"
                "2.\tEject the drive from your computer and plug it into the USB Host port of the Piksi Multi evaluation board.\n"
                "3.\tReset your Piksi Multi and it will upgrade to the version on the USB flash drive.\n"
                "  \tThis should take less than 5 minutes.\n"
                "4.\tWhen the upgrade completes you will be prompted to remove the USB flash drive and reset your Piksi Multi.\n"
                "5.\tVerify that the firmware version has upgraded via inspection of the Current Firmware Version box\n"
                "  \ton the Update Tab of the Swift Console.\n")

            confirm_prompt = prompt.CallbackPrompt(
                title="Update device over serial connection?",
                actions=[prompt.close_button, prompt.continue_via_serial_button],
                callback=self._update_stm_firmware_fn)
            confirm_prompt.text = "\n" \
                                  + "    Upgrading your device via UART / RS232 may take up to 30 minutes.     \n" \
                                  + "                                                                          \n" \
                                  + "    If the device you are upgrading has an accessible USB host port, it   \n" \
                                    "    is recommended to instead  follow the \'USB Flashdrive Upgrade        \n" \
                                    "    Procedure\' that now appears in the Firmware upgrade status box.      \n" \
                                  + "\n" \
                                  + "    Are you sure you want to continue upgrading over serial?"
            confirm_prompt.run(block=False)
        else:
            self._update_stm_firmware_fn()
示例#2
0
    def _update_stm_firmware_fn(self):
        try:
            if self._firmware_update_thread.is_alive():
                return
        except AttributeError:
            pass

        current_fw_version = parse_version(self.piksi_stm_vers)
        re_result = re.search('.*-(v[0-9]*\.[0-9]*\.[0-9]*.*).bin$',
                              self.stm_fw.status)
        intended_version = parse_version(str(re_result.group(1)))
        # If the current firmware is not yet beyond 2.0.0, and we are loading beyond 2.0.0
        # warn the user that this upgrade is not possible. But always allow development version
        if (current_fw_version.isdev is
                False) and (intended_version.isdev is False) and (
                    current_fw_version < parse_version("v2.0.0")) and (
                        intended_version > parse_version("v2.0.0")):
            confirm_prompt = prompt.CallbackPrompt(
                title="Update to v2.0.0",
                actions=[prompt.close_button, prompt.ok_button],
                callback=self._replace_with_version_2)
            confirm_prompt.text = "\n" \
                                  + "    Upgrading to firmware v2.1.0 or later requires that the device be     \n" \
                                  + "    running firmware v2.0.0 or later. Please upgrade to firmware          \n" \
                                  + "    version 2.0.0.                                                        \n" \
                                  + "                                                                          \n" \
                                  + "    Would you like to download firmware version v2.0.0 now?               \n" \
                                  + "                                                                          \n"
            confirm_prompt.run(block=False)
            return
        self._firmware_update_thread = Thread(
            target=self.manage_firmware_updates, args=("STM", ))
        self._firmware_update_thread.start()
示例#3
0
    def _wait_for_any_write_failures(self, parser):
        """Checks for any settings write failures for which a successful write is expected.
        If no failures have occurred, we prompt the user whether to save settings to the device's flash.

           Args:
                parser (dict): A dict of dicts with setting sections then names for keys
        """
        write_failures = 0
        for section, settings in parser.items():
            for setting, _ in settings.items():
                if self.settings[section][setting].write_failure:
                    write_failures += 1
                    self.settings[section][setting].write_failure = False
        if write_failures == 0:
            print("Successfully imported settings from file.")
            confirm_prompt = prompt.CallbackPrompt(
                title="Save to device flash?",
                actions=[prompt.close_button, prompt.ok_button],
                callback=self._settings_save_button_fired)
            confirm_prompt.text = "\n" \
                                  "  Settings import from file complete.  Click OK to save the settings  \n" \
                                  "  to the device's persistent storage.  \n"
            confirm_prompt.run(block=False)
        else:
            print("Unable to import settings from file: {0} settings write failures occurred.".format(write_failures))
示例#4
0
 def _import_fail(self):
     confirm_prompt = prompt.CallbackPrompt(
         title="Failed to import settings from file",
         actions=[prompt.close_button])
     confirm_prompt.text = "\n" \
         "  Verify that config file is not overwriting active connection settings.  \n"
     confirm_prompt.run(block=False)
示例#5
0
 def _read_all_fail(self):
     confirm_prompt = prompt.CallbackPrompt(
         title="Failed to read settings from device",
         actions=[prompt.close_button])
     confirm_prompt.text = "\n" \
         "  Check connection and refresh settings.  \n"
     confirm_prompt.run(block=False)
示例#6
0
 def _display_ins_settings_hint(self):
     """
     Display helpful hint messages to help a user set up inertial product
     """
     settings_list = self._determine_smoothpose_recommended_settings()
     if len(settings_list) > 0:
         confirm_prompt = prompt.CallbackPrompt(
             title="Update Recommended Inertial Navigation Settings?",
             actions=[prompt.close_button, prompt.update_button],
             callback=self.update_required_smoothpose_settings)
         confirm_prompt.settings_list = settings_list
         confirm_prompt.text = "\n\n" \
                               "    In order to enable INS output, it is necessary to enable and configure the imu.    \n" \
                               "    Your current settings indicate that your imu raw ouptut is disabled and/or improperly configured.    \n\n" \
                               "    Choose \"Update\" to allow the console to change the following settings on your device to help enable INS output.    \n" \
                               "    Choose \"Close\" to ignore this recommendation and not update any device settings.    \n\n"
         # from objbrowser import browse
         # browse(confirm_prompt)
         confirm_prompt.view.content.content[0].content.append(
             Item(
                 "settings_list",
                 editor=TabularEditor(adapter=SimpleChangeAdapter(),
                                      editable_labels=False,
                                      auto_update=True,
                                      editable=False),
                 # Only make pop-up as tall as necessary
                 height=-(len(confirm_prompt.settings_list) * 25 + 40),
                 label='Recommended Settings'))
         confirm_prompt.run(block=False)
         while (confirm_prompt.thread.is_alive()):
             # Wait until first popup is closed before opening second popup
             time.sleep(1)
     # even if we didn't need to change any settings, we still have to save settings and restart
     self.display_ins_output_hint()
示例#7
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)
示例#8
0
    def _display_ins_settings_hint(self):
        """
        Display helpful hint messages to help a user set up inertial product
        """
        settings_list = self._determine_smoothpose_recommended_settings()
        if len(settings_list) > 0:
            confirm_prompt = prompt.CallbackPrompt(
                title="Update Recommended Inertial Navigation Settings?",
                actions=[prompt.close_button, prompt.update_button],
                callback=self.update_required_smoothpose_settings)
            confirm_prompt.settings_list = settings_list
            confirm_prompt.text = "\n\n" \
                                  "    In order to enable INS output, it is necessary to enable and configure the imu.    \n" \
                                  "    Your current settings indicate that your imu raw ouptut is disabled and/or improperly configured.    \n\n" \
                                  "    Choose \"Update\" to allow the console to change the following settings on your device to help enable INS output.    \n" \
                                  "    Choose \"Close\" to ignore this recommendation and not update any device settings.    \n\n"
            # from objbrowser import browse
            # browse(confirm_prompt)
            confirm_prompt.view.content.content[0].content.append(
                Item(
                    "settings_list",
                    editor=TabularEditor(adapter=SimpleChangeAdapter(),
                                         editable_labels=False,
                                         auto_update=True,
                                         editable=False),
                    # Only make pop-up as tall as necessary
                    height=-(len(confirm_prompt.settings_list) * 25 + 40),
                    label='Recommended Settings'))
            confirm_prompt.run(block=False)
            while (confirm_prompt.thread.is_alive()):
                # Wait until first popup is closed before opening second popup
                time.sleep(1)
        confirm_prompt2 = prompt.CallbackPrompt(
            title="Restart Device?",
            actions=[prompt.close_button, prompt.ok_button],
            callback=self._save_and_reset)

        confirm_prompt2.text = "\n\n" \
                               "    In order for the \"Ins Output Mode\" setting to take effect, it is necessary to save the    \n" \
                               "    current settings to device flash and then power cycle your device.    \n\n" \
                               "    Choose \"OK\" to immediately save settings to device flash and send the software reset command.    \n" \
                               "    The software reset will temporarily interrupt the console's connection to the device but it   \n" \
                               "    will recover on its own.    \n\n"

        confirm_prompt2.run(block=False)
示例#9
0
 def _import_success(self, count):
     print("Successfully imported {} settings from file.".format(count))
     confirm_prompt = prompt.CallbackPrompt(
         title="Save to device flash?",
         actions=[prompt.close_button, prompt.ok_button],
         callback=self._settings_save_button_fired)
     confirm_prompt.text = "\n" \
         "  Settings import from file complete.  Click OK to save the settings  \n" \
         "  to the device's persistent storage.  \n"
     confirm_prompt.run(block=False)
示例#10
0
 def prompt(self):
     confirm_prompt = prompt.CallbackPrompt(
         title="Update device over serial connection?",
         actions=[prompt.close_button])
     confirm_prompt.text = "\n" \
                           + "    Upgrading your device via UART / RS232 may take up to 30 minutes.     \n" \
                           + "    \n" \
                           + "    If the device you are upgrading has an accessible USB port,     \n" \
                           + "    it is recommended to follow the USB upgrade procedure.    \n" \
                           + "\n" \
                           + "    Are you sure you want to continue upgrading over serial?"
     confirm_prompt.run(block=False)
示例#11
0
    def display_ins_output_hint(self):
        confirm_prompt2 = prompt.CallbackPrompt(
            title="Restart Device?",
            actions=[prompt.close_button, prompt.ok_button],
            callback=self._save_and_reset)

        confirm_prompt2.text = "\n\n" \
                               "    In order for the \"Ins Output Mode\" setting to take effect, it is necessary to save the    \n" \
                               "    current settings to device flash and then power cycle your device.    \n\n" \
                               "    Choose \"OK\" to immediately save settings to device flash and send the software reset command.    \n" \
                               "    The software reset will temporarily interrupt the console's connection to the device but it   \n" \
                               "    will recover on its own.    \n\n"

        confirm_prompt2.run(block=False)
示例#12
0
    def revert_to_prior_value(self, section, name, old, new, error_value):
        '''Revert setting to old value in the case we can't confirm new value'''

        if self.readonly:
            return

        self.skip_write_req = True
        self.value = old
        self.skip_write_req = False

        invalid_setting_prompt = prompt.CallbackPrompt(
            title="Settings Write Error: {}.{}".format(section, name),
            actions=[prompt.close_button], )
        if error_value == SettingsWriteResponseCodes.SETTINGS_WR_TIMEOUT:
            invalid_setting_prompt.text = \
                ("\n   Unable to confirm that {0} was set to {1}.\n"
                 "   Message timed out.\n"
                 "   Ensure that the new setting value did not interrupt console communication.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_VALUE_REJECTED:
            invalid_setting_prompt.text += \
                ("   Ensure the range and formatting of the entry are correct.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_SETTING_REJECTED:
            invalid_setting_prompt.text += \
                ("   {0} is not a valid setting.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_PARSE_FAILED:
            invalid_setting_prompt.text += \
                ("   Could not parse value: {1}.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_READ_ONLY:
            invalid_setting_prompt.text += \
                ("   {0} is read-only.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_MODIFY_DISABLED:
            invalid_setting_prompt.text += \
                ("   Modifying {0} is currently disabled.\n"
                 "   Error Value: {2}")
        elif error_value == SettingsWriteResponseCodes.SETTINGS_WR_SERVICE_FAILED:
            invalid_setting_prompt.text += \
                ("   Service failed while changing setting. See logs.\n"
                 "   Error Value: {2}")
        else:
            invalid_setting_prompt.text += \
                ("   Unknown Error.\n"
                 "   Error Value: {2}")
        invalid_setting_prompt.text = invalid_setting_prompt.text.format(self.name, new, error_value)
        invalid_setting_prompt.run()
示例#13
0
    def revert_after_delay(self, delay, name, old, new, popop=True):
        '''Revert setting to old value after delay in seconds has elapsed'''
        time.sleep(delay)
        if not self.confirmed_set:
            self.revert_in_progress = True
            self.value = old
            invalid_setting_prompt = prompt.CallbackPrompt(
                title="Settings Write Error",
                actions=[prompt.close_button], )
            invalid_setting_prompt.text = \
                ("\n   Unable to confirm that {0} was set to {1}.\n"
                 "   Ensure the range and formatting of the entry are correct.\n"
                 "   Ensure that the new setting value did not interrupt console communication.").format(self.name, new)
            invalid_setting_prompt.run()

        self.confirmed_set = False
示例#14
0
 def revert_to_prior_value(self, name, old, new):
     '''Revert setting to old value in the case we can't confirm new value'''
     self.revert_in_progress = True
     self.value = old
     self.revert_in_progress = False
     # reset confirmed_set to make sure setting is editable again
     self.confirmed_set = True
     self.write_failure = True
     invalid_setting_prompt = prompt.CallbackPrompt(
         title="Settings Write Error",
         actions=[prompt.close_button], )
     invalid_setting_prompt.text = \
         ("\n   Unable to confirm that {0} was set to {1}.\n"
          "   Ensure the range and formatting of the entry are correct.\n"
          "   Ensure that the new setting value did not interrupt console communication.").format(self.name, new)
     invalid_setting_prompt.run()
示例#15
0
 def _auto_survey_fired(self):
     confirm_prompt = prompt.CallbackPrompt(
         title="Auto populate surveyed position?",
         actions=[prompt.close_button, prompt.auto_survey_button],
         callback=self.auto_survey_fn)
     confirm_prompt.text = "\n" \
                         + "This will set the Surveyed Position section to the \n" \
                         + "mean of the SPP positions of the last 1000 SPP samples.\n \n" \
                         + "The fields that will be auto-populated are: \n" \
                         + "Surveyed Lat \n" \
                         + "Surveyed Lon \n" \
                         + "Surveyed Alt \n \n" \
                         + "The surveyed position will be an approximate value. \n" \
                         + "This may affect the relative accuracy of Piksi. \n \n" \
                         + "Are you sure you want to auto-populate the Surveyed Position section?"
     confirm_prompt.run(block=False)
示例#16
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(flags=0))

        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)
示例#17
0
    def revert_to_prior_value(self,
                              name,
                              old,
                              new,
                              error_value=SBP_WRITE_STATUS.TIMED_OUT):
        '''Revert setting to old value in the case we can't confirm new value'''

        if self.readonly:
            return

        self._prevent_revert_thread = True
        self.value = old
        self._prevent_revert_thread = False
        # reset confirmed_set to make sure setting is editable again
        self.confirmed_set = True
        self.write_failure = True
        invalid_setting_prompt = prompt.CallbackPrompt(
            title="Settings Write Error",
            actions=[prompt.close_button],
        )
        if error_value == SBP_WRITE_STATUS.TIMED_OUT:
            invalid_setting_prompt.text = \
                ("\n   Unable to confirm that {0} was set to {1}.\n"
                 "   Message timed out.\n"
                 "   Ensure that the new setting value did not interrupt console communication.\n"
                 "   Error Value: {2}")
        else:
            invalid_setting_prompt.text = \
                ("\n   Unable to set {0} to {1}.\n")

        if error_value == SBP_WRITE_STATUS.VALUE_REJECTED:
            invalid_setting_prompt.text += \
                ("   Ensure the range and formatting of the entry are correct.\n"
                 "   Error Value: {2}")
        elif error_value == SBP_WRITE_STATUS.SETTING_REJECTED:
            invalid_setting_prompt.text += \
                ("   {0} is not a valid setting.\n"
                 "   Error Value: {2}")
        elif error_value == SBP_WRITE_STATUS.PARSE_FAILED:
            invalid_setting_prompt.text += \
                ("   Could not parse value: {1}.\n"
                 "   Error Value: {2}")
        elif error_value == SBP_WRITE_STATUS.READ_ONLY:
            invalid_setting_prompt.text += \
                ("   {0} is read-only.\n"
                 "   Error Value: {2}")
        elif error_value == SBP_WRITE_STATUS.MODIFY_DISABLED:
            invalid_setting_prompt.text += \
                ("   Modifying {0} is currently disabled.\n"
                 "   Error Value: {2}")
        elif error_value == SBP_WRITE_STATUS.SERVICE_FAILED:
            invalid_setting_prompt.text += \
                ("   Service failed while changing setting. See logs.\n"
                 "   Error Value: {2}")
        else:
            invalid_setting_prompt.text += \
                ("   Unknown Error.\n"
                 "   Error Value: {2}")
        invalid_setting_prompt.text = invalid_setting_prompt.text.format(
            self.name, new, error_value)
        invalid_setting_prompt.run()
示例#18
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_hw_rev = \
              HW_REV_LOOKUP[self.settings['system_info']['hw_revision'].value]
            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

        self.is_v2 = self.piksi_hw_rev.startswith('piksi_v2')
        if self.is_v2:
            self.stm_fw.set_flash_type('STM')
        else:
            self.stm_fw.set_flash_type('bin')

        self._get_latest_version_info()

        # 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

            # we want to warn users using v2 regardless of version logic
            if self.console_outdated or self.is_v2:
                if not self.is_v2:
                    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://support.swiftnav.com to\n" + \
                        "download the latest version.\n\n" + \
                        "Local Console Version :\n\t" + \
                            "v" + CONSOLE_VERSION + \
                        "\nLatest Console Version :\n\t" + \
                            self.update_dl.index[self.piksi_hw_rev]['console']['version'] + "\n"
                else:
                    console_outdated_prompt = \
                    prompt.CallbackPrompt(
                                          title="Piksi Console Incompatible",
                                          actions=[prompt.close_button],
                                          )
                    console_outdated_prompt.text = \
                        "Your Piksi Console is incompatible with your hardware revision.\n" + \
                        "We highly recommend using a compatible console version\n" + \
                        "to ensure proper behavior.\n\n" + \
                        "Please visit http://support.swiftnav.com to\n" + \
                        "download the latest compatible version.\n\n" + \
                        "Current Hardware revision :\n\t" + \
                             self.piksi_hw_rev + \
                        "\nLast supported Console Version: \n\t" + \
                            self.update_dl.index[self.piksi_hw_rev]['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]
                                         )

                if self.update_dl.index[self.piksi_hw_rev].has_key('fw'):
                    fw_update_prompt.text = \
                      "New Piksi firmware available.\n\n" + \
                      "Please use the Firmware Update tab to update.\n\n" + \
                      "Newest Firmware Version :\n\t%s\n\n" % \
                          self.update_dl.index[self.piksi_hw_rev]['fw']['version']
                else:
                    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[self.piksi_hw_rev]['stm_fw']['version'] + \
                      "Newest SwiftNAP Version :\n\t%s\n\n" % \
                          self.update_dl.index[self.piksi_hw_rev]['nap_fw']['version']

                fw_update_prompt.run()
示例#19
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. Informs user if
        firmware successfully upgraded.
        """
        # Check that settings received from Piksi contain FW versions.
        try:
            self.piksi_hw_rev = HW_REV_LOOKUP[self.settings['system_info']
                                              ['hw_revision'].value]
            self.piksi_stm_vers = self.settings['system_info'][
                'firmware_version'].value
        except KeyError:
            self._write(
                "\nWarning: Settings received from Piksi do not contain firmware version information. Unable to determine software update status.\n"
            )
            return

        self.is_v2 = self.piksi_hw_rev.startswith('piksi_v2')

        self._get_latest_version_info()

        # Check that we received the index file from the website.
        if self.update_dl is None:
            self._write(
                "\nWarning: Unable to fetch firmware release index from Swift to determine update status.\n"
            )
            return
        # Get local stm version
        local_stm_version = None
        local_serial_number = None
        try:
            local_stm_version = self.settings['system_info'][
                'firmware_version'].value
            local_serial_number = self.settings['system_info'][
                'serial_number'].value
        except:  # noqa
            pass
        # 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

            # we want to warn users using v2 regardless of version logic
            if self.console_outdated or self.is_v2:
                if not self.is_v2:
                    console_outdated_prompt = \
                        prompt.CallbackPrompt(
                            title="Swift Console Outdated",
                            actions=[prompt.close_button],
                        )
                    console_outdated_prompt.text = \
                        "Your 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://support.swiftnav.com to\n" + \
                        "download the latest version.\n\n" + \
                        "Local Console Version :\n\t" + \
                        CONSOLE_VERSION + \
                        "\nLatest Console Version :\n\t" + \
                        self.update_dl.index[self.piksi_hw_rev]['console']['version'] + "\n"
                else:
                    console_outdated_prompt = \
                        prompt.CallbackPrompt(
                            title="Swift Console Incompatible",
                            actions=[prompt.close_button],
                        )
                    console_outdated_prompt.text = \
                        "Your console is incompatible with your hardware revision.\n" + \
                        "We highly recommend using a compatible console version\n" + \
                        "to ensure proper behavior.\n\n" + \
                        "Please visit http://support.swiftnav.com to\n" + \
                        "download the latest compatible version.\n\n" + \
                        "Current Hardware revision :\n\t" + \
                        self.piksi_hw_rev + \
                        "\nLast supported Console Version: \n\t" + \
                        self.update_dl.index[self.piksi_hw_rev]['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.
            remote_stm_version = self.newest_stm_vers

            self.fw_outdated = remote_stm_version > local_stm_version
            if local_stm_version.startswith('DEV'):
                self.fw_outdated = False

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

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

                fw_update_prompt.run()

        # Check if firmware successfully upgraded and notify user if so.
        if ((self.last_call_fw_version is not None
             and self.last_call_fw_version != local_stm_version)
                and (self.last_call_sn is None or local_serial_number is None
                     or self.last_call_sn == local_serial_number)):
            fw_success_str = "Firmware successfully upgraded from %s to %s." % \
                             (self.last_call_fw_version, local_stm_version)
            print(fw_success_str)
            self._write(fw_success_str)

        # Record firmware version reported each time this callback is called.
        self.last_call_fw_version = local_stm_version
        self.last_call_sn = local_serial_number
示例#20
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" + \
                        "v" + 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()