Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-tools by
serial_nc_rx_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 SerialNCRXTest(): 00025 00026 def test(self, selftest): 00027 selftest.mbed.flush(); 00028 selftest.mbed.serial_write("E"); 00029 00030 strip_chars = string.whitespace + "\0" 00031 00032 out_str = selftest.mbed.serial_readline() 00033 00034 if not out_str: 00035 selftest.notify("HOST: No output detected") 00036 return selftest.RESULT_IO_SERIAL 00037 00038 out_str_stripped = out_str.strip(strip_chars) 00039 00040 if out_str_stripped != "RX OK - Expected": 00041 selftest.notify("HOST: Unexpected output. Expected 'RX OK - Expected' but received '%s'" % out_str_stripped) 00042 return selftest.RESULT_FAILURE 00043 00044 # Wait 0.5 seconds to ensure mbed is listening 00045 time.sleep(0.5) 00046 00047 # Send character, mbed shouldn't receive 00048 selftest.mbed.serial_write("U"); 00049 00050 out_str = selftest.mbed.serial_readline() 00051 00052 # If no characters received, pass the test 00053 if not out_str: 00054 selftest.notify("HOST: No further output detected") 00055 return selftest.RESULT_SUCCESS 00056 else: 00057 out_str_stripped = out_str.strip(strip_chars) 00058 00059 if out_str_stripped == "RX OK - Unexpected": 00060 selftest.notify("HOST: Unexpected output returned indicating RX still functioning") 00061 else: 00062 selftest.notify("HOST: Extraneous output '%s' detected indicating unknown error" % out_str_stripped) 00063 00064 return selftest.RESULT_FAILURE
Generated on Thu Aug 11 2022 22:20:37 by
1.7.2
