Mbed Host Tests
module_reset_stlink.py
Go to the documentation of this file.
1"""
2mbed SDK
3Copyright (c) 2011-2015 ARM Limited
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16
17Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
18"""
19
20from .host_test_plugins import HostTestPluginBase
21
22
23class HostTestPluginResetMethod_Stlink(HostTestPluginBase):
24
25 # Plugin interface
26 name = 'HostTestPluginResetMethod_Stlink'
27 type = 'ResetMethod'
28 capabilities = ['stlink']
29 required_parameters = []
30 stable = False
31
32 def __init__(self):
33 """ ctor
34 """
35 HostTestPluginBase.__init__(self)
36
37 def is_os_supported(self, os_name=None):
38 """! In this implementation this plugin only is supporeted under Windows machines
39 """
40 # If no OS name provided use host OS name
41 if not os_name:
42 os_name = self.mbed_os_support()
43
44 # This plugin only works on Windows
45 if os_name and os_name.startswith('Windows'):
46 return True
47 return False
48
49 def setup(self, *args, **kwargs):
50 """! Configure plugin, this function should be called before plugin execute() method is used.
51 """
52 # Note you need to have eACommander.exe on your system path!
53 self.ST_LINK_CLI = 'ST-LINK_CLI.exe'
54 return True
55
56 def execute(self, capability, *args, **kwargs):
57 """! Executes capability by name
58
59 @param capability Capability name
60 @param args Additional arguments
61 @param kwargs Additional arguments
62
63 @details Each capability e.g. may directly just call some command line program or execute building pythonic function
64
65 @return Capability call return value
66 """
67 result = False
68 if self.check_parameters(capability, *args, **kwargs) is True:
69 if capability == 'stlink':
70 # Example:
71 # ST-LINK_CLI.exe -Rst -Run
72 cmd = [self.ST_LINK_CLI,
73 '-Rst', '-Run']
74 result = self.run_command(cmd)
75 return result
76
77
79 """ Returns plugin available in this module
80 """
def run_command(self, cmd, shell=True)
Runs command from command line.
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...