Mbed Host Tests
module_copy_ublox.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
20import os
21from .host_test_plugins import HostTestPluginBase
22
23
25
26 # Plugin interface
27 name = 'HostTestPluginCopyMethod_ublox'
28 type = 'CopyMethod'
29 capabilities = ['ublox']
30 required_parameters = ['image_path']
31
32 def is_os_supported(self, os_name=None):
33 """! In this implementation this plugin only is supporeted under Windows machines
34 """
35 # If no OS name provided use host OS name
36 if not os_name:
37 os_name = self.mbed_os_support()
38
39 # This plugin only works on Windows
40 if os_name and os_name.startswith('Windows'):
41 return True
42 return False
43
44 def setup(self, *args, **kwargs):
45 """! Configure plugin, this function should be called before plugin execute() method is used.
46 """
47 self.FLASH_ERASE = 'FlashErase.exe'
48 return True
49
50 def execute(self, capability, *args, **kwargs):
51 """! Executes capability by name
52
53 @param capability Capability name
54 @param args Additional arguments
55 @param kwargs Additional arguments
56
57 @details Each capability e.g. may directly just call some command line program or execute building pythonic function
58
59 @return Capability call return value
60 """
61 result = False
62 if self.check_parameters(capability, *args, **kwargs) is True:
63 image_path = os.path.normpath(kwargs['image_path'])
64 if capability == 'ublox':
65 # Example:
66 # FLASH_ERASE -c 2 -s 0xD7000 -l 0x20000 -f "binary_file.bin"
67 cmd = [self.FLASH_ERASE,
68 '-c',
69 'A',
70 '-s',
71 '0xD7000',
72 '-l',
73 '0x20000',
74 '-f', image_path
75 ]
76 result = self.run_command(cmd)
77 return result
78
79
81 """ Returns plugin available in this module
82 """
run_command(self, cmd, shell=True)
Runs command from command line.
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...
is_os_supported(self, os_name=None)
In this implementation this plugin only is supporeted under Windows machines.
setup(self, *args, **kwargs)
Configure plugin, this function should be called before plugin execute() method is used.
execute(self, capability, *args, **kwargs)
Executes capability by name.