BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers module_copy_silabs.py Source File

module_copy_silabs.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2011-2013 ARM Limited
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 from __future__ import print_function
00018 
00019 from time import sleep
00020 from .host_test_plugins import HostTestPluginBase
00021 
00022 
00023 class HostTestPluginCopyMethod_Silabs(HostTestPluginBase):
00024 
00025     # Plugin interface
00026     name = 'HostTestPluginCopyMethod_Silabs'
00027     type = 'CopyMethod'
00028     capabilities = ['eACommander', 'eACommander-usb']
00029     required_parameters = ['image_path', 'destination_disk', 'program_cycle_s']
00030 
00031     def setup(self, *args, **kwargs):
00032         """ Configure plugin, this function should be called before plugin execute() method is used.
00033         """
00034         self.EACOMMANDER_CMD = 'eACommander.exe'
00035         return True
00036 
00037     def execute(self, capabilitity, *args, **kwargs):
00038         """ Executes capability by name.
00039             Each capability may directly just call some command line
00040             program or execute building pythonic function
00041         """
00042         result = False
00043         if self.check_parameters(capabilitity, *args, **kwargs) is True:
00044             image_path = kwargs['image_path']
00045             destination_disk = kwargs['destination_disk']
00046             program_cycle_s = kwargs['program_cycle_s']
00047             if capabilitity == 'eACommander':
00048                 cmd = [self.EACOMMANDER_CMD,
00049                        '--serialno', destination_disk,
00050                        '--flash', image_path,
00051                        '--resettype', '2', '--reset']
00052                 result = self.run_command(cmd)
00053             elif capabilitity == 'eACommander-usb':
00054                 cmd = [self.EACOMMANDER_CMD,
00055                        '--usb', destination_disk,
00056                        '--flash', image_path]
00057                 result = self.run_command(cmd)
00058 
00059             # Allow mbed to cycle
00060             sleep(program_cycle_s)
00061 
00062         return result
00063 
00064 
00065 def load_plugin ():
00066     """ Returns plugin available in this module
00067     """
00068     return HostTestPluginCopyMethod_Silabs()