def _analyze_output(self, data): """ Analyze in real time the output log from flash tool command execution and switch the device state when needed :type data: str :param data: string to analyze """ # FLash initialization flash_mode_start_trigger = ["Please reboot your phone device"] # Flash start here flash_mode_trigger = ["Device synchronized"] # Final verdict at end of script flash_mode_stop_trigger = ["Success!"] flash_error_trigger = ["Error opening device"] for d in data: self._logger.debug(d) # Search in logging trigger for flashing event if d != "": if any(word in d for word in flash_mode_start_trigger): # Switch the device in FLASH MODE state if not already in if self._flash_tool_state == "FLASH_INIT_STATE": # Activate usb host line to allow FTE2 to connect device as soon as it # is ready (device in DNX or COS mode) if self._switch_device_state_fct( "COS_MODE_ON") == Global.SUCCESS: self._logger.debug( "Changing flash state to FLASH_MODE_START") self._flash_tool_state = "FLASH_MODE_START" # Log it self._logger.info( "FTE2: Starting flashing procedure") else: self.exec_result = False self.error_message = "FTE2: Issue can not enable usb host line on the device" self._flash_tool_state = "UNUSED" FlashToolBase._stop(self) if any(word in d for word in flash_mode_trigger): # Change the device state => Stop the flash mode as now started if self._flash_tool_state == "FLASH_MODE_START": # Change the device state => Stop the flash mode as now started self._logger.debug( "Changing flash state to FLASH_MODE") self._flash_tool_state = "FLASH_MODE" # Log it self._logger.info( "FTE2: Flashing procedure in progress") if any(word in d for word in flash_mode_stop_trigger): self._logger.info( "FTE2: Flashing procedure done successfully") # Change the device state => Stop the flash mode as it finish if self._flash_tool_state == "FLASH_MODE": code, message = self._switch_device_state_fct( "WAIT_BOOT") if code == Global.SUCCESS: self._logger.debug( "Changing flash state to FLASH_MODE_STOP") self._flash_tool_state = "FLASH_MODE_STOP" self.exec_result = True else: self.exec_result = False self.error_message = "FTE2: Issue can not check board status after flash success (%s)" \ % str(message) self._flash_tool_state = "UNUSED" FlashToolBase._stop(self) if any(word in d for word in flash_error_trigger): self._logger.error( "FTE2: An error occur during flash procedure !") # Change the device state => Stop the flash mode as it finish self.exec_result = False self.error_message = "FTE2: An error occur during flash procedure ! (%s)" \ % str(d) self._flash_tool_state = "UNUSED" FlashToolBase._stop(self)
def _analyze_output(self, data): """ Analyze in real time the output log from flash tool command execution and switch the device state when needed :type data: str :param data: string to analyze """ # FLash initialization start_ifw_flash_trigger = [ "Detecting Intel Device - Attempt ", "Please plug and reboot the board" ] # Flash start here ifw_flash_trigger = [ "IFW flash started", "Flashing IFWI", "Initiating download..." ] # Final verdict at end of script flash_success_trigger = ["complete the flashing procedure"] for d in data: self._logger.debug(d) # Search in logging trigger for flashing event if d != "": # Trigger for Flash initialization (FLASH_INIT_STATE -> FLASH_MODE_START) if any(word in d for word in start_ifw_flash_trigger): # Switch the device in FLASH_MODE_START state if not already in if self._flash_tool_state == "FLASH_INIT_STATE": # Change the device state => Trig the flash mode (reboot device) if self._switch_device_state_fct( "FLASH_SWITCH_OFF") == Global.SUCCESS: # if reboot ok should flash, see next step self._logger.debug( "Changing flash state to FLASH_MODE_START") self._flash_tool_state = "FLASH_MODE_START" # Log it self._logger.info( "EFT: Starting flashing procedure") else: msg = "EFT: Issue can not switch off the device" self._logger.error(msg) self._logger.debug( "Changing flash state to FLASH_MODE_STOP") self._flash_tool_state = "FLASH_MODE_STOP" self.exec_result = False self.error_message = msg FlashToolBase._stop(self) else: self._logger.warning( "EFT: Wrong flash tool state %s when \"%s\" should be %s" % (self._flash_tool_state, start_ifw_flash_trigger, "FLASH_INIT_STATE")) # Trigger for Flash Start (FLASH_MODE_START -> FLASH_MODE) if any(word in d for word in ifw_flash_trigger): # Change the device state => Stop the flash mode as now started if self._flash_tool_state == "FLASH_MODE_START": # Change the device state => Stop the flash mode as now started self._logger.debug( "Changing flash state to FLASH_MODE") self._flash_tool_state = "FLASH_MODE" # Log it self._logger.info( "EFT: Flashing procedure in progress") else: self._logger.warning( "EFT: Wrong flash tool state %s when \"%s\" should be %s" % (self._flash_tool_state, ifw_flash_trigger, "FLASH_MODE_START")) # Trigger final flash verdict (FLASH_MODE -> FLASH_MODE_STOP) if any(word in d for word in flash_success_trigger): self._logger.info( "EFT: Flashing procedure done successfully") # Change the device state => Stop the flash mode as it finish if self._flash_tool_state == "FLASH_MODE": if self._switch_device_state_fct( "WAIT_BOOT") == Global.SUCCESS: # If boot ok, then full flash procedure is ok self._logger.debug( "Changing flash state to FLASH_MODE_STOP") self._flash_tool_state = "FLASH_MODE_STOP" # Set final exec result self.exec_result = True else: self._logger.debug( "Changing flash state to UNUSED") self._flash_tool_state = "UNUSED" # Set final exec result and error message self.exec_result = False self.error_message = "EFT: Issue can not check board status after flash success" FlashToolBase._stop(self) else: self._logger.warning( "EFT: Wrong flash tool state %s when \"%s\" should be %s" % (self._flash_tool_state, flash_success_trigger[0], "FLASH_MODE"))