Mbed Host Tests
module_reset_silabs.py
Go to the documentation of this file.
1 """
2 mbed SDK
3 Copyright (c) 2011-2015 ARM Limited
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
18 """
19 
20 from .host_test_plugins import HostTestPluginBase
21 
22 
24 
25  # Plugin interface
26  name = 'HostTestPluginResetMethod_SiLabs'
27  type = 'ResetMethod'
28  capabilities = ['eACommander', 'eACommander-usb']
29  required_parameters = ['disk']
30  stable = True
31 
32  def __init__(self):
33  """ ctor
34  """
35  HostTestPluginBase.__init__(self)
36 
37  def setup(self, *args, **kwargs):
38  """ Configure plugin, this function should be called before plugin execute() method is used.
39  """
40  # Note you need to have eACommander.exe on your system path!
41  self.EACOMMANDER_CMD = 'eACommander.exe'
42  return True
43 
44  def execute(self, capability, *args, **kwargs):
45  """! Executes capability by name
46 
47  @param capability Capability name
48  @param args Additional arguments
49  @param kwargs Additional arguments
50 
51  @details Each capability e.g. may directly just call some command line program or execute building pythonic function
52 
53  @return Capability call return value
54  """
55  result = False
56  if self.check_parameters(capability, *args, **kwargs) is True:
57  disk = kwargs['disk'].rstrip('/\\')
58 
59  if capability == 'eACommander':
60  # For this copy method 'disk' will be 'serialno' for eACommander command line parameters
61  # Note: Commands are executed in the order they are specified on the command line
62  cmd = [self.EACOMMANDER_CMD,
63  '--serialno', disk,
64  '--resettype', '2', '--reset',]
65  result = self.run_command(cmd)
66  elif capability == 'eACommander-usb':
67  # For this copy method 'disk' will be 'usb address' for eACommander command line parameters
68  # Note: Commands are executed in the order they are specified on the command line
69  cmd = [self.EACOMMANDER_CMD,
70  '--usb', disk,
71  '--resettype', '2', '--reset',]
72  result = self.run_command(cmd)
73  return result
74 
75 
77  """ Returns plugin available in this module
78  """
mbed_host_tests.host_tests_plugins.module_reset_silabs.HostTestPluginResetMethod_SiLabs.setup
def setup(self, *args, **kwargs)
Definition: module_reset_silabs.py:37
mbed_host_tests.host_tests_plugins.module_reset_silabs.HostTestPluginResetMethod_SiLabs
Definition: module_reset_silabs.py:23
mbed_host_tests.host_tests_plugins.module_reset_silabs.HostTestPluginResetMethod_SiLabs.execute
def execute(self, capability, *args, **kwargs)
Executes capability by name.
Definition: module_reset_silabs.py:44
mbed_host_tests.host_tests_plugins.host_test_plugins.HostTestPluginBase
Base class for all plugins used with host tests.
Definition: host_test_plugins.py:32
mbed_host_tests.host_tests_plugins.host_test_plugins.HostTestPluginBase.run_command
def run_command(self, cmd, shell=True)
Runs command from command line.
Definition: host_test_plugins.py:227
mbed_host_tests.host_tests_plugins.module_reset_silabs.HostTestPluginResetMethod_SiLabs.EACOMMANDER_CMD
EACOMMANDER_CMD
Definition: module_reset_silabs.py:41
mbed_host_tests.host_tests_plugins.host_test_plugins.HostTestPluginBase.check_parameters
def check_parameters(self, capability, *args, **kwargs)
This function should be ran each time we call execute() to check if none of the required parameters i...
Definition: host_test_plugins.py:211
mbed_host_tests.host_tests_plugins.module_reset_silabs.HostTestPluginResetMethod_SiLabs.__init__
def __init__(self)
Definition: module_reset_silabs.py:32
mbed_host_tests.host_tests_plugins.module_reset_silabs.load_plugin
def load_plugin()
Definition: module_reset_silabs.py:76