mirror of https://github.com/ARMmbed/mbed-os.git
Synchronize host and target for nc serial auto test
We're ensuring target and host start-up sync here in 2 ways: 1) adding a delay on host side to make sure the serial initialization can happen before sending a character is sent to target 2) in case of serial_nc_rx_auto.py test, we're sending a first character S which will trigger the move from rx+tx to NC+rx. This should avoid any crossing case due to HSOT being faster than target or vice-versapull/1781/head
parent
c35a6f65f2
commit
05baf365dc
|
@ -11,21 +11,27 @@ int main() {
|
||||||
|
|
||||||
char c = pc->getc();
|
char c = pc->getc();
|
||||||
|
|
||||||
|
|
||||||
|
// This should be true, sync the start of test
|
||||||
|
if (c == 'S') {
|
||||||
|
pc->printf("RX OK - Start NC test\r\n");
|
||||||
|
|
||||||
|
// disconnect TX and get char
|
||||||
delete pc;
|
delete pc;
|
||||||
|
pc = new Serial(NC, USBRX);
|
||||||
// This should be true
|
c = pc->getc();
|
||||||
if (c == 'E') {
|
if (c == 'E') {
|
||||||
Serial *pc = new Serial(USBTX, NC);
|
// ok disconnect Rx and answer to host
|
||||||
|
delete pc;
|
||||||
|
pc = new Serial(USBTX, NC);
|
||||||
pc->printf("RX OK - Expected\r\n");
|
pc->printf("RX OK - Expected\r\n");
|
||||||
|
|
||||||
c = pc->getc();
|
c = pc->getc();
|
||||||
|
|
||||||
// This should be false/not get here
|
// This should be false/not get here
|
||||||
if (c == 'U') {
|
if (c == 'U') {
|
||||||
pc->printf("RX OK - Unexpected\r\n");
|
pc->printf("RX OK - Unexpected\r\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
delete pc;
|
delete pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,29 @@ class SerialNCRXTest():
|
||||||
|
|
||||||
def test(self, selftest):
|
def test(self, selftest):
|
||||||
selftest.mbed.flush();
|
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");
|
selftest.mbed.serial_write("E");
|
||||||
|
|
||||||
strip_chars = string.whitespace + "\0"
|
strip_chars = string.whitespace + "\0"
|
||||||
|
|
|
@ -25,6 +25,9 @@ class SerialNCTXTest():
|
||||||
|
|
||||||
def test(self, selftest):
|
def test(self, selftest):
|
||||||
selftest.mbed.flush();
|
selftest.mbed.flush();
|
||||||
|
# Wait 0.5 seconds to ensure mbed is listening
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
selftest.mbed.serial_write("S");
|
selftest.mbed.serial_write("S");
|
||||||
|
|
||||||
strip_chars = string.whitespace + "\0"
|
strip_chars = string.whitespace + "\0"
|
||||||
|
|
Loading…
Reference in New Issue