BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
serial_nc_tx_auto.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 00018 import sys 00019 import uuid 00020 import time 00021 import string 00022 from sys import stdout 00023 00024 class SerialNCTXTest(): 00025 00026 def test(self, selftest): 00027 selftest.mbed.flush(); 00028 # Wait 0.5 seconds to ensure mbed is listening 00029 time.sleep(0.5) 00030 00031 selftest.mbed.serial_write("S"); 00032 00033 strip_chars = string.whitespace + "\0" 00034 00035 out_str = selftest.mbed.serial_readline() 00036 selftest.notify("HOST: " + out_str) 00037 00038 if not out_str: 00039 selftest.notify("HOST: No output detected") 00040 return selftest.RESULT_IO_SERIAL 00041 00042 out_str_stripped = out_str.strip(strip_chars) 00043 00044 if out_str_stripped != "TX OK - Expected": 00045 selftest.notify("HOST: Unexpected output. Expected 'TX OK - Expected' but received '%s'" % out_str_stripped) 00046 return selftest.RESULT_FAILURE 00047 00048 out_str = selftest.mbed.serial_readline() 00049 00050 # If no characters received, pass the test 00051 if not out_str: 00052 selftest.notify("HOST: No further output detected") 00053 return selftest.RESULT_SUCCESS 00054 else: 00055 out_str_stripped = out_str.strip(strip_chars) 00056 00057 if out_str_stripped == "TX OK - Unexpected": 00058 selftest.notify("HOST: Unexpected output returned indicating TX still functioning") 00059 else: 00060 selftest.notify("HOST: Extraneous output '%s' detected indicating unknown error" % out_str_stripped) 00061 00062 return selftest.RESULT_FAILURE
Generated on Tue Jul 12 2022 12:22:19 by
