dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 """
nexpaq 1:55a6170b404f 2 mbed SDK
nexpaq 1:55a6170b404f 3 Copyright (c) 2011-2013 ARM Limited
nexpaq 1:55a6170b404f 4
nexpaq 1:55a6170b404f 5 Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 1:55a6170b404f 6 you may not use this file except in compliance with the License.
nexpaq 1:55a6170b404f 7 You may obtain a copy of the License at
nexpaq 1:55a6170b404f 8
nexpaq 1:55a6170b404f 9 http://www.apache.org/licenses/LICENSE-2.0
nexpaq 1:55a6170b404f 10
nexpaq 1:55a6170b404f 11 Unless required by applicable law or agreed to in writing, software
nexpaq 1:55a6170b404f 12 distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 1:55a6170b404f 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 1:55a6170b404f 14 See the License for the specific language governing permissions and
nexpaq 1:55a6170b404f 15 limitations under the License.
nexpaq 1:55a6170b404f 16 """
nexpaq 1:55a6170b404f 17
nexpaq 1:55a6170b404f 18 import sys
nexpaq 1:55a6170b404f 19 import uuid
nexpaq 1:55a6170b404f 20 from sys import stdout
nexpaq 1:55a6170b404f 21
nexpaq 1:55a6170b404f 22 class EchoTest():
nexpaq 1:55a6170b404f 23
nexpaq 1:55a6170b404f 24 # Test parameters
nexpaq 1:55a6170b404f 25 TEST_SERIAL_BAUDRATE = 115200
nexpaq 1:55a6170b404f 26 TEST_LOOP_COUNT = 50
nexpaq 1:55a6170b404f 27
nexpaq 1:55a6170b404f 28 def test(self, selftest):
nexpaq 1:55a6170b404f 29 """ This host test will use mbed serial port with
nexpaq 1:55a6170b404f 30 baudrate 115200 to perform echo test on that port.
nexpaq 1:55a6170b404f 31 """
nexpaq 1:55a6170b404f 32 # Custom initialization for echo test
nexpaq 1:55a6170b404f 33 selftest.mbed.init_serial_params(serial_baud=self.TEST_SERIAL_BAUDRATE)
nexpaq 1:55a6170b404f 34 selftest.mbed.init_serial()
nexpaq 1:55a6170b404f 35
nexpaq 1:55a6170b404f 36 # Test function, return True or False to get standard test notification on stdout
nexpaq 1:55a6170b404f 37 selftest.mbed.flush()
nexpaq 1:55a6170b404f 38 selftest.notify("HOST: Starting the ECHO test")
nexpaq 1:55a6170b404f 39 result = True
nexpaq 1:55a6170b404f 40
nexpaq 1:55a6170b404f 41 """ This ensures that there are no parasites left in the serial buffer.
nexpaq 1:55a6170b404f 42 """
nexpaq 1:55a6170b404f 43 for i in range(0, 2):
nexpaq 1:55a6170b404f 44 selftest.mbed.serial_write("\n")
nexpaq 1:55a6170b404f 45 c = selftest.mbed.serial_readline()
nexpaq 1:55a6170b404f 46
nexpaq 1:55a6170b404f 47 for i in range(0, self.TEST_LOOP_COUNT):
nexpaq 1:55a6170b404f 48 TEST_STRING = str(uuid.uuid4()) + "\n"
nexpaq 1:55a6170b404f 49 selftest.mbed.serial_write(TEST_STRING)
nexpaq 1:55a6170b404f 50 c = selftest.mbed.serial_readline()
nexpaq 1:55a6170b404f 51 if c is None:
nexpaq 1:55a6170b404f 52 return selftest.RESULT_IO_SERIAL
nexpaq 1:55a6170b404f 53 if c.strip() != TEST_STRING.strip():
nexpaq 1:55a6170b404f 54 selftest.notify('HOST: "%s" != "%s"'% (c, TEST_STRING))
nexpaq 1:55a6170b404f 55 result = False
nexpaq 1:55a6170b404f 56 else:
nexpaq 1:55a6170b404f 57 sys.stdout.write('.')
nexpaq 1:55a6170b404f 58 stdout.flush()
nexpaq 1:55a6170b404f 59 return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE