def manage_multi_firmware_update(self): # Set up progress dialog and transfer file to Piksi using SBP FileIO progress_dialog = PulsableProgressDialog(len(self.stm_fw.blob)) progress_dialog.title = "Transferring image file" GUI.invoke_later(progress_dialog.open) self._write("Transferring image file...") try: FileIO(self.link).write("upgrade.image_set.bin", self.stm_fw.blob, progress_cb=progress_dialog.progress) except Exception as e: self._write("Failed to transfer image file to Piksi: %s\n" % e) progress_dialog.close() return try: progress_dialog.close() except AttributeError: pass # Setup up pulsed progress dialog and commit to flash progress_dialog = PulsableProgressDialog(100, True) progress_dialog.title = "Committing to flash" GUI.invoke_later(progress_dialog.open) self._write("Committing file to flash...") def log_cb(msg, **kwargs): self._write(msg.text) self.link.add_callback(log_cb, SBP_MSG_LOG) code = shell_command(self.link, "upgrade_tool upgrade.image_set.bin", 240) self.link.remove_callback(log_cb, SBP_MSG_LOG) progress_dialog.close() if code != 0: self._write('Failed to perform upgrade (code = %d)' % code) return self._write('Resetting Piksi...') self.link(MsgReset(flags=0))
def manage_multi_firmware_update(self): # Set up progress dialog and transfer file to Piksi using SBP FileIO progress_dialog = PulsableProgressDialog(len(self.stm_fw.blob)) progress_dialog.title = "Transferring file - stay on this window to progress" self._write( "Transferring image file - you must keep progress bar window active for the file transfer to progress" ) if not progress_dialog.open_in_gui_thread(): self._write("Failed to open progress dialog.\n") return try: FileIO(self.link).write("upgrade.image_set.bin", self.stm_fw.blob, progress_cb=progress_dialog.progress) except Exception as e: self._write("Failed to transfer image file to Piksi: %s\n" % e) progress_dialog.close() return try: progress_dialog.close() except AttributeError: pass # Setup up pulsed progress dialog and commit to flash progress_dialog = PulsableProgressDialog(100, True) progress_dialog.title = "Committing to flash" if not progress_dialog.open_in_gui_thread(): self._write("Failed to open progress dialog.\n") return def log_cb(msg, **kwargs): self._write(msg.text) self.link.add_callback(log_cb, SBP_MSG_LOG) code = shell_command(self.link, "upgrade_tool upgrade.image_set.bin", 600, progress_cb=progress_dialog.progress) self.link.remove_callback(log_cb, SBP_MSG_LOG) progress_dialog.close() if code != 0: self._write('Failed to perform upgrade (code = %d)' % code) if code == -255: self._write('Shell command timed out. Please try again.') return self._write('Resetting Piksi...') self.link(MsgReset(flags=0))
def manage_multi_firmware_update(self): self.blob_size = float(len(self.stm_fw.blob)) self.pcent_complete = 0 # Set up progress dialog and transfer file to Piksi using SBP FileIO self._clear_stream() self._write("Transferring image to device...\n\n00.0 of {:2.1f} MB trasnferred".format( self.blob_size * 1e-6)) try: FileIO(self.link).write( b"upgrade.image_set.bin", self.stm_fw.blob, progress_cb=self.file_transfer_progress_cb) except Exception as e: self._write("Failed to transfer image file to Piksi: %s\n" % e) self._write("Upgrade Aborted.") import traceback print(traceback.format_exc()) return -1 self.stream.scrollback_write( "Image transfer complete: {:2.1f} MB transferred.\n".format(self.blob_size * 1e-6)) # Setup up pulsed progress dialog and commit to flash self._write("Committing file to Flash...\n") self.link.add_callback(self.log_cb, SBP_MSG_LOG) code = shell_command( self.link, b"upgrade_tool upgrade.image_set.bin", 200) self.link.remove_callback(self.log_cb, SBP_MSG_LOG) if code != 0: self._write('Failed to perform upgrade (code = %d)' % code) if code == -255: self._write('Shell command timed out. Please try again.') return self._write("Upgrade Complete.") self._write('Resetting Piksi...') self.link(MsgReset(flags=0))
def manage_multi_firmware_update(self): self.blob_size = float(len(self.stm_fw.blob)) self.pcent_complete = 0 # Set up progress dialog and transfer file to Piksi using SBP FileIO self._clear_stream() self._write("Transferring image to device...\n\n00.0 of {:2.1f} MB trasnferred".format(self.blob_size * 1e-6)) try: FileIO(self.link).write( b"upgrade.image_set.bin", self.stm_fw.blob, progress_cb=self.file_transfer_progress_cb) except Exception as e: self._write("Failed to transfer image file to Piksi: %s\n" % e) self._write("Upgrade Aborted.") import traceback print(traceback.format_exc()) return -1 self.stream.scrollback_write("Image transfer complete: {:2.1f} MB transferred.\n".format(self.blob_size * 1e-6)) # Setup up pulsed progress dialog and commit to flash self._write("Committing file to Flash...\n") self.link.add_callback(self.log_cb, SBP_MSG_LOG) code = shell_command( self.link, b"upgrade_tool upgrade.image_set.bin", 200) self.link.remove_callback(self.log_cb, SBP_MSG_LOG) if code != 0: self._write('Failed to perform upgrade (code = %d)' % code) if code == -255: self._write('Shell command timed out. Please try again.') return self._write("Upgrade Complete.") self._write('Resetting Piksi...') self.link(MsgReset(flags=0))