BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
module_reset_mps2.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 import os 00020 from time import sleep 00021 from .host_test_plugins import HostTestPluginBase 00022 00023 # Note: This plugin is not fully functional, needs improvements 00024 00025 class HostTestPluginResetMethod_MPS2 (HostTestPluginBase): 00026 """ Plugin used to reset ARM_MPS2 platform 00027 Supports: 00028 reboot.txt - startup from standby state, reboots when in run mode. 00029 shutdown.txt - shutdown from run mode. 00030 reset.txt - reset FPGA during run mode. 00031 """ 00032 def touch_file (self, file): 00033 """ Touch file and set timestamp to items 00034 """ 00035 tfile = file+'.tmp' 00036 fhandle = open(tfile, 'a') 00037 try: 00038 fhandle.close() 00039 finally: 00040 os.rename(tfile, file) 00041 return True 00042 00043 # Plugin interface 00044 name = 'HostTestPluginResetMethod_MPS2' 00045 type = 'ResetMethod' 00046 capabilities = ['mps2-reboot', 'mps2-reset'] 00047 required_parameters = ['disk'] 00048 00049 def setup (self, *args, **kwargs): 00050 """ Prepare / configure plugin to work. 00051 This method can receive plugin specific parameters by kwargs and 00052 ignore other parameters which may affect other plugins. 00053 """ 00054 return True 00055 00056 def execute (self, capabilitity, *args, **kwargs): 00057 """ Executes capability by name. 00058 Each capability may directly just call some command line 00059 program or execute building pythonic function 00060 """ 00061 return True 00062 result = False 00063 if self.check_parameters(capabilitity, *args, **kwargs) is True: 00064 disk = kwargs['disk'] 00065 00066 if capabilitity == 'mps2-reboot' and self.touch_file (disk + 'reboot.txt'): 00067 sleep(20) 00068 result = True 00069 00070 elif capabilitity == 'mps2-reset' and self.touch_file (disk + 'reboot.txt'): 00071 sleep(20) 00072 result = True 00073 00074 return result 00075 00076 def load_plugin (): 00077 """ Returns plugin available in this module 00078 """ 00079 return HostTestPluginResetMethod_MPS2()
Generated on Tue Jul 12 2022 12:22:13 by
