Mbed Host Tests
module_reset_pyocd.py
Go to the documentation of this file.
1"""
2mbed SDK
3Copyright (c) 2016-2016,2018 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: Russ Butler <russ.butler@arm.com>
18"""
19
20from .host_test_plugins import HostTestPluginBase
21from pyocd.core.helpers import ConnectHelper
22
23
25
26 # Plugin interface
27 name = 'HostTestPluginResetMethod_pyOCD'
28 type = 'ResetMethod'
29 stable = True
30 capabilities = ['pyocd']
31 required_parameters = ['target_id']
32
33 def __init__(self):
34 """! ctor
35 @details We can check module version by referring to version attribute
36 import pkg_resources
37 print pkg_resources.require("mbed-host-tests")[0].version
38 '2.7'
39 """
40 HostTestPluginBase.__init__(self)
41
42 def setup(self, *args, **kwargs):
43 """! Configure plugin, this function should be called before plugin execute() method is used.
44 """
45 return True
46
47 def execute(self, capability, *args, **kwargs):
48 """! Executes capability by name
49
50 @param capability Capability name
51 @param args Additional arguments
52 @param kwargs Additional arguments
53 @details Each capability e.g. may directly just call some command line program or execute building pythonic function
54 @return Capability call return value
55 """
56 if not kwargs['target_id']:
57 self.print_plugin_error("Error: target_id not set")
58 return False
59
60 result = False
61 if self.check_parameters(capability, *args, **kwargs) is True:
62 if kwargs['target_id']:
63 if capability == 'pyocd':
64 target_id = kwargs['target_id']
65 with ConnectHelper.session_with_chosen_probe(unique_id=target_id,
66 resume_on_disconnect=False) as session:
67 session.target.reset()
68 session.target.resume()
69 result = True
70 return result
71
72
74 """! Returns plugin available in this module
75 """
print_plugin_error(self, text)
Interface helper methods - overload only if you need to have custom behaviour.
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...
execute(self, capability, *args, **kwargs)
Executes capability by name.
setup(self, *args, **kwargs)
Configure plugin, this function should be called before plugin execute() method is used.
load_plugin()
Returns plugin available in this module.