Module: MobyBehaviour::FlashBehaviour

Includes:
Behaviour
Defined in:
lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb

Overview

description

This module contains implementation to control device flashing

behaviour

GenericFlashBehaviour

requires

*

input_type

*

sut_type

*

sut_version

*

objects

sut

Instance Method Summary collapse

Instance Method Details

#flashObject

description

Instructs the sut to start the flash operation with default TDriver parameters

arguments

returns

Boolean

description: Indicating that did flashing success
example: true

exceptions

BehaviourError

description: If mandatory parameters are missing

BehaviourError

description: If flashing is failed

tables

flash_prameters

title: Flash parameters
description: Flash parameters for sut
|Parameter|Description|Example|
|:flash_attempts|How many times TDriver will attempt to flash the device|<parameter name="flash_attempts" value="2" />|
|:timeout_between_command_sequence|Timeout in seconds between the switchbox commands|<parameter name="timeout_between_command_sequence" value="25" />|
|:switchbox_commands_before_flash|Commands you want to be executed before flash|<parameter name="switchbox_commands_before_flash" value="" />|
|:commands_before_flash|Flash commands before flash|<parameter name="commands_before_flash" value="" />|
|:flash_command|Intial flash command|<parameter name="flash_command" value="" />|
|:timeout_before_executing_commands_during_flash|Timeout in seconds before executing the commands during flash|<parameter name="timeout_before_executing_commands_during_flash" value="20" />|
|:switchbox_commands_during_flash|Commands you want to be executed during flash|<parameter name="switchbox_commands_during_flash" value="" />|
|:optional_parameters_after_flashing|Optional flash parameters|<parameter name="optional_parameters_after_flashing" value="" />|
|:flash_images|Images to flash|<parameter name="flash_images" value="" />|
|:sleep_time_after_flash_command|Wait time for the flash process to finish|<parameter name="sleep_time_after_flash_command" value="70" />|
|:command_after_flash|Flash command after flash|<parameter name="command_after_flash" value="" />|
|:switchbox_commands_after_failed_flash|Commands for switchbox after failed flash|<parameter name="switchbox_commands_after_failed_flash" value="" />|
|:commands_after_failed_flash|Commands after failed flash|<parameter name="commands_after_failed_flash" value="" />|
|:flash_command_success_string|If no error then no string is displayed|<parameter name="flash_command_success_string" value="" />|
|:switchbox_commands_after_flash|Commands you want to be executed after flash|<parameter name="switchbox_commands_after_flash" value="" />|


81
82
83
84
85
# File 'lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb', line 81

def flash()

  flash_images

end

#flash_images(flash_files = nil) ⇒ Object

description

Instructs the sut to start the flash operation with the configured flash files

arguments

flash_files

String
description: The location of the software image file
example: "C:/images/flash_image.img"

returns

Boolean

description: Indicating that did flashing success
example: true

raises

BehaviourError If mandatory parameters are missing BehaviourError If flashing is failed

examples

@sut.flash_images(“C:/path/image_file.img”)

tables

flash_prameters

title: Flash parameters
description: Flash parameters for sut
|Parameter|Description|Example|
|:flash_attempts|How many times TDriver will attempt to flash the device|<parameter name="flash_attempts" value="2" />|
|:timeout_between_command_sequence|Timeout in seconds between the switchbox commands|<parameter name="timeout_between_command_sequence" value="25" />|
|:switchbox_commands_before_flash|Commands you want to be executed before flash|<parameter name="switchbox_commands_before_flash" value="" />|
|:commands_before_flash|Flash commands before flash|<parameter name="commands_before_flash" value="" />|
|:flash_command|Intial flash command|<parameter name="flash_command" value="" />|
|:timeout_before_executing_commands_during_flash|Timeout in seconds before executing the commands during flash|<parameter name="timeout_before_executing_commands_during_flash" value="20" />|
|:switchbox_commands_during_flash|Commands you want to be executed during flash|<parameter name="switchbox_commands_during_flash" value="" />|
|:optional_parameters_after_flashing|Optional flash parameters|<parameter name="optional_parameters_after_flashing" value="" />|
|:flash_images|Images to flash|<parameter name="flash_images" value="" />|
|:sleep_time_after_flash_command|Wait time for the flash process to finish|<parameter name="sleep_time_after_flash_command" value="70" />|
|:command_after_flash|Flash command after flash|<parameter name="command_after_flash" value="" />|
|:switchbox_commands_after_failed_flash|Commands for switchbox after failed flash|<parameter name="switchbox_commands_after_failed_flash" value="" />|
|:commands_after_failed_flash|Commands after failed flash|<parameter name="commands_after_failed_flash" value="" />|
|:flash_command_success_string|If no error then no string is displayed|<parameter name="flash_command_success_string" value="" />|
|:switchbox_commands_after_flash|Commands you want to be executed after flash|<parameter name="switchbox_commands_after_flash" value="" />|


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb', line 124

def flash_images(flash_files = nil)
  file, line = caller.first.split(":")

  begin
    if parameter(:flaxi_flash_attempts)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_flash_attempts deprecated use :flash_attempts instead" 
      parameter[:flash_attempts]=parameter(:flaxi_flash_attempts)
    end
  rescue
  end

  begin
    if parameter(:flaxi_commands_before_flash)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_commands_before_flash deprecated use :commands_before_flash instead" 
      parameter[:commands_before_flash]=parameter(:flaxi_commands_before_flash)
    end
  rescue
  end

  begin
    if parameter(:flaxi_flash_command)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_flash_command deprecated use :flash_command instead" 
      parameter[:flash_command]=parameter(:flaxi_flash_command)
    end
  rescue
  end

  begin
    if parameter(:flaxi_optional_parameters_after_flashing)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_optional_parameters_after_flashing deprecated use :optional_parameters_after_flashing instead" 
      parameter[:optional_parameters_after_flashing]=parameter(:flaxi_optional_parameters_after_flashing)
    end
  rescue
  end

  begin
    if parameter(:flaxi_flash_images)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_flash_images deprecated use :flash_images instead" 
      parameter[:flash_images]=parameter(:flaxi_flash_images)
    end
  rescue
  end

  begin
    if parameter(:flaxi_sleep_time_after_flash_command)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_sleep_time_after_flash_command deprecated use :sleep_time_after_flash_command instead" 
      parameter[:sleep_time_after_flash_command]=parameter(:flaxi_sleep_time_after_flash_command)
    end
  rescue
  end

  begin
    if parameter(:flaxi_command_after_flash)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_command_after_flash deprecated use :command_after_flash instead" 
      parameter[:command_after_flash]=parameter(:flaxi_command_after_flash)
    end
  rescue
  end

  begin
    if parameter(:flaxi_commands_after_failed_flash)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_commands_after_failed_flash deprecated use :commands_after_failed_flash instead" 
      parameter[:commands_after_failed_flash]=parameter(:flaxi_commands_after_failed_flash)
    end
  rescue
  end

  begin
    if parameter(:flaxi_flash_command_success_string)
      $stderr.puts "#{ file.to_s }:#{ line.to_s } warning: parameter :flaxi_flash_command_success_string deprecated use :flash_command_success_string instead" 
      parameter[:flash_command_success_string]=parameter(:flaxi_flash_command_success_string)
    end
  rescue
  end
    
  if flash_files==nil
    flash_files=parameter(:flash_images)
    raise MobyBase::BehaviourError.new("flash_images", "flash_images not defined for sut in tdriver_parameters.xml") if flash_files == nil
  end

  str_flash_command=parameter(:flash_command)
  raise MobyBase::BehaviourError.new("flash_images", "flash_command not defined for sut in tdriver_parameters.xml") if str_flash_command == nil

  str_optional_parameters=parameter(:optional_parameters_after_flashing,'')
  raise MobyBase::BehaviourError.new("flash_images", "optional_parameters_after_flashing not defined for sut in tdriver_parameters.xml") if str_optional_parameters == nil

  #build flash command
  flash_command="#{str_flash_command} #{flash_files} #{str_optional_parameters}"

  #start flashing
  result = start_flashing( flash_command )
  
  raise MobyBase::BehaviourError.new("flash_images", "Flashing failed") if result.to_s == 'false'
  sleep parameter[:sleep_time_after_flash_command].to_i
end