Clone of official tools

Committer:
Anders Blomdell
Date:
Thu Feb 04 17:17:13 2021 +0100
Revision:
47:21ae3e5a7128
Parent:
13:ab47a20b66f0
Add a few normpath calls

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:66f3b5499f7f 1 """
screamer 0:66f3b5499f7f 2 mbed SDK
screamer 0:66f3b5499f7f 3 Copyright (c) 2011-2013 ARM Limited
screamer 0:66f3b5499f7f 4
screamer 0:66f3b5499f7f 5 Licensed under the Apache License, Version 2.0 (the "License");
screamer 0:66f3b5499f7f 6 you may not use this file except in compliance with the License.
screamer 0:66f3b5499f7f 7 You may obtain a copy of the License at
screamer 0:66f3b5499f7f 8
screamer 0:66f3b5499f7f 9 http://www.apache.org/licenses/LICENSE-2.0
screamer 0:66f3b5499f7f 10
screamer 0:66f3b5499f7f 11 Unless required by applicable law or agreed to in writing, software
screamer 0:66f3b5499f7f 12 distributed under the License is distributed on an "AS IS" BASIS,
screamer 0:66f3b5499f7f 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 0:66f3b5499f7f 14 See the License for the specific language governing permissions and
screamer 0:66f3b5499f7f 15 limitations under the License.
screamer 0:66f3b5499f7f 16 """
screamer 0:66f3b5499f7f 17
screamer 0:66f3b5499f7f 18 import sys
screamer 0:66f3b5499f7f 19 import uuid
screamer 0:66f3b5499f7f 20 import time
screamer 0:66f3b5499f7f 21 import string
screamer 0:66f3b5499f7f 22 from sys import stdout
screamer 0:66f3b5499f7f 23
screamer 0:66f3b5499f7f 24 class SerialNCTXTest():
screamer 0:66f3b5499f7f 25
screamer 0:66f3b5499f7f 26 def test(self, selftest):
screamer 0:66f3b5499f7f 27 selftest.mbed.flush();
screamer 13:ab47a20b66f0 28 # Wait 0.5 seconds to ensure mbed is listening
screamer 13:ab47a20b66f0 29 time.sleep(0.5)
screamer 13:ab47a20b66f0 30
screamer 0:66f3b5499f7f 31 selftest.mbed.serial_write("S");
screamer 0:66f3b5499f7f 32
screamer 0:66f3b5499f7f 33 strip_chars = string.whitespace + "\0"
screamer 0:66f3b5499f7f 34
screamer 0:66f3b5499f7f 35 out_str = selftest.mbed.serial_readline()
screamer 0:66f3b5499f7f 36 selftest.notify("HOST: " + out_str)
screamer 0:66f3b5499f7f 37
screamer 0:66f3b5499f7f 38 if not out_str:
screamer 0:66f3b5499f7f 39 selftest.notify("HOST: No output detected")
screamer 0:66f3b5499f7f 40 return selftest.RESULT_IO_SERIAL
screamer 0:66f3b5499f7f 41
screamer 0:66f3b5499f7f 42 out_str_stripped = out_str.strip(strip_chars)
screamer 0:66f3b5499f7f 43
screamer 0:66f3b5499f7f 44 if out_str_stripped != "TX OK - Expected":
screamer 0:66f3b5499f7f 45 selftest.notify("HOST: Unexpected output. Expected 'TX OK - Expected' but received '%s'" % out_str_stripped)
screamer 0:66f3b5499f7f 46 return selftest.RESULT_FAILURE
screamer 0:66f3b5499f7f 47
screamer 0:66f3b5499f7f 48 out_str = selftest.mbed.serial_readline()
screamer 0:66f3b5499f7f 49
screamer 0:66f3b5499f7f 50 # If no characters received, pass the test
screamer 0:66f3b5499f7f 51 if not out_str:
screamer 0:66f3b5499f7f 52 selftest.notify("HOST: No further output detected")
screamer 0:66f3b5499f7f 53 return selftest.RESULT_SUCCESS
screamer 0:66f3b5499f7f 54 else:
screamer 0:66f3b5499f7f 55 out_str_stripped = out_str.strip(strip_chars)
screamer 0:66f3b5499f7f 56
screamer 0:66f3b5499f7f 57 if out_str_stripped == "TX OK - Unexpected":
screamer 0:66f3b5499f7f 58 selftest.notify("HOST: Unexpected output returned indicating TX still functioning")
screamer 0:66f3b5499f7f 59 else:
screamer 0:66f3b5499f7f 60 selftest.notify("HOST: Extraneous output '%s' detected indicating unknown error" % out_str_stripped)
screamer 0:66f3b5499f7f 61
screamer 0:66f3b5499f7f 62 return selftest.RESULT_FAILURE