mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

UserRevisionLine numberNew contents of line
be_bryan 0:b74591d5ab33 1 """
be_bryan 0:b74591d5ab33 2 mbed SDK
be_bryan 0:b74591d5ab33 3 Copyright (c) 2011-2013 ARM Limited
be_bryan 0:b74591d5ab33 4
be_bryan 0:b74591d5ab33 5 Licensed under the Apache License, Version 2.0 (the "License");
be_bryan 0:b74591d5ab33 6 you may not use this file except in compliance with the License.
be_bryan 0:b74591d5ab33 7 You may obtain a copy of the License at
be_bryan 0:b74591d5ab33 8
be_bryan 0:b74591d5ab33 9 http://www.apache.org/licenses/LICENSE-2.0
be_bryan 0:b74591d5ab33 10
be_bryan 0:b74591d5ab33 11 Unless required by applicable law or agreed to in writing, software
be_bryan 0:b74591d5ab33 12 distributed under the License is distributed on an "AS IS" BASIS,
be_bryan 0:b74591d5ab33 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
be_bryan 0:b74591d5ab33 14 See the License for the specific language governing permissions and
be_bryan 0:b74591d5ab33 15 limitations under the License.
be_bryan 0:b74591d5ab33 16 """
be_bryan 0:b74591d5ab33 17
be_bryan 0:b74591d5ab33 18 import os
be_bryan 0:b74591d5ab33 19 from host_test_plugins import HostTestPluginBase
be_bryan 0:b74591d5ab33 20 from time import sleep
be_bryan 0:b74591d5ab33 21
be_bryan 0:b74591d5ab33 22 # Note: This plugin is not fully functional, needs improvements
be_bryan 0:b74591d5ab33 23
be_bryan 0:b74591d5ab33 24 class HostTestPluginResetMethod_MPS2(HostTestPluginBase):
be_bryan 0:b74591d5ab33 25 """ Plugin used to reset ARM_MPS2 platform
be_bryan 0:b74591d5ab33 26 Supports:
be_bryan 0:b74591d5ab33 27 reboot.txt - startup from standby state, reboots when in run mode.
be_bryan 0:b74591d5ab33 28 shutdown.txt - shutdown from run mode.
be_bryan 0:b74591d5ab33 29 reset.txt - reset FPGA during run mode.
be_bryan 0:b74591d5ab33 30 """
be_bryan 0:b74591d5ab33 31 def touch_file(self, file):
be_bryan 0:b74591d5ab33 32 """ Touch file and set timestamp to items
be_bryan 0:b74591d5ab33 33 """
be_bryan 0:b74591d5ab33 34 tfile = file+'.tmp'
be_bryan 0:b74591d5ab33 35 fhandle = open(tfile, 'a')
be_bryan 0:b74591d5ab33 36 try:
be_bryan 0:b74591d5ab33 37 fhandle.close()
be_bryan 0:b74591d5ab33 38 finally:
be_bryan 0:b74591d5ab33 39 os.rename(tfile, file)
be_bryan 0:b74591d5ab33 40 return True
be_bryan 0:b74591d5ab33 41
be_bryan 0:b74591d5ab33 42 # Plugin interface
be_bryan 0:b74591d5ab33 43 name = 'HostTestPluginResetMethod_MPS2'
be_bryan 0:b74591d5ab33 44 type = 'ResetMethod'
be_bryan 0:b74591d5ab33 45 capabilities = ['mps2-reboot', 'mps2-reset']
be_bryan 0:b74591d5ab33 46 required_parameters = ['disk']
be_bryan 0:b74591d5ab33 47
be_bryan 0:b74591d5ab33 48 def setup(self, *args, **kwargs):
be_bryan 0:b74591d5ab33 49 """ Prepare / configure plugin to work.
be_bryan 0:b74591d5ab33 50 This method can receive plugin specific parameters by kwargs and
be_bryan 0:b74591d5ab33 51 ignore other parameters which may affect other plugins.
be_bryan 0:b74591d5ab33 52 """
be_bryan 0:b74591d5ab33 53 return True
be_bryan 0:b74591d5ab33 54
be_bryan 0:b74591d5ab33 55 def execute(self, capabilitity, *args, **kwargs):
be_bryan 0:b74591d5ab33 56 """ Executes capability by name.
be_bryan 0:b74591d5ab33 57 Each capability may directly just call some command line
be_bryan 0:b74591d5ab33 58 program or execute building pythonic function
be_bryan 0:b74591d5ab33 59 """
be_bryan 0:b74591d5ab33 60 return True
be_bryan 0:b74591d5ab33 61 result = False
be_bryan 0:b74591d5ab33 62 if self.check_parameters(capabilitity, *args, **kwargs) is True:
be_bryan 0:b74591d5ab33 63 disk = kwargs['disk']
be_bryan 0:b74591d5ab33 64
be_bryan 0:b74591d5ab33 65 if capabilitity == 'mps2-reboot' and self.touch_file(disk + 'reboot.txt'):
be_bryan 0:b74591d5ab33 66 sleep(20)
be_bryan 0:b74591d5ab33 67 result = True
be_bryan 0:b74591d5ab33 68
be_bryan 0:b74591d5ab33 69 elif capabilitity == 'mps2-reset' and self.touch_file(disk + 'reboot.txt'):
be_bryan 0:b74591d5ab33 70 sleep(20)
be_bryan 0:b74591d5ab33 71 result = True
be_bryan 0:b74591d5ab33 72
be_bryan 0:b74591d5ab33 73 return result
be_bryan 0:b74591d5ab33 74
be_bryan 0:b74591d5ab33 75 def load_plugin():
be_bryan 0:b74591d5ab33 76 """ Returns plugin available in this module
be_bryan 0:b74591d5ab33 77 """
be_bryan 0:b74591d5ab33 78 return HostTestPluginResetMethod_MPS2()