mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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