Merge pull request #1781 from LMESTM/fix_MBED_37_Init

Modify serial nc tests init part
pull/1868/head
Martin Kojtal 2016-06-07 12:15:57 +01:00
commit 4afc14d18b
4 changed files with 49 additions and 16 deletions

View File

@ -2,31 +2,37 @@
#include "test_env.h"
int main() {
Serial *pc = new Serial(USBTX, USBRX);
MBED_HOSTTEST_TIMEOUT(20);
MBED_HOSTTEST_SELECT(serial_nc_rx_auto);
MBED_HOSTTEST_DESCRIPTION(Serial NC RX);
MBED_HOSTTEST_START("MBED_37");
Serial *pc = new Serial(NC, USBRX);
char c = pc->getc();
delete pc;
// This should be true
if (c == 'E') {
Serial *pc = new Serial(USBTX, NC);
// This should be true, sync the start of test
if (c == 'S') {
pc->printf("RX OK - Start NC test\r\n");
pc->printf("RX OK - Expected\r\n");
// disconnect TX and get char
delete pc;
pc = new Serial(NC, USBRX);
c = pc->getc();
if (c == 'E') {
// ok disconnect Rx and answer to host
delete pc;
pc = new Serial(USBTX, NC);
pc->printf("RX OK - Expected\r\n");
c = pc->getc();
// This should be false/not get here
if (c == 'U') {
pc->printf("RX OK - Unexpected\r\n");
}
delete pc;
c = pc->getc();
// This should be false/not get here
if (c == 'U') {
pc->printf("RX OK - Unexpected\r\n");
}
}
delete pc;
}
while (1) {

View File

@ -2,13 +2,14 @@
#include "test_env.h"
int main() {
Serial *pc = new Serial(USBTX, USBRX);
MBED_HOSTTEST_TIMEOUT(20);
MBED_HOSTTEST_SELECT(serial_nc_tx_auto);
MBED_HOSTTEST_DESCRIPTION(Serial NC TX);
MBED_HOSTTEST_START("MBED_38");
// Wait until we receive start signal from host test
Serial *pc = new Serial(USBTX, USBRX);
char c = pc->getc();
delete pc;

View File

@ -25,6 +25,29 @@ class SerialNCRXTest():
def test(self, selftest):
selftest.mbed.flush();
# Wait 0.5 seconds to ensure mbed is listening
time.sleep(0.5)
#handshake with target to sync test start
selftest.mbed.serial_write("S");
strip_chars = string.whitespace + "\0"
out_str = selftest.mbed.serial_readline()
if not out_str:
selftest.notify("HOST: No output detected")
return selftest.RESULT_IO_SERIAL
out_str_stripped = out_str.strip(strip_chars)
if out_str_stripped != "RX OK - Start NC test":
selftest.notify("HOST: Unexpected output. Expected 'RX OK - Expected' but received '%s'" % out_str_stripped)
return selftest.RESULT_FAILURE
# Wait 0.5 seconds to ensure mbed is listening
time.sleep(0.5)
selftest.mbed.serial_write("E");
strip_chars = string.whitespace + "\0"

View File

@ -25,6 +25,9 @@ class SerialNCTXTest():
def test(self, selftest):
selftest.mbed.flush();
# Wait 0.5 seconds to ensure mbed is listening
time.sleep(0.5)
selftest.mbed.serial_write("S");
strip_chars = string.whitespace + "\0"