Skip to content

Commit 4afc14d

Browse files
committed
Merge pull request #1781 from LMESTM/fix_MBED_37_Init
Modify serial nc tests init part
2 parents 6455389 + 05baf36 commit 4afc14d

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed

libraries/tests/mbed/serial_nc_rx/main.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,37 @@
22
#include "test_env.h"
33

44
int main() {
5+
Serial *pc = new Serial(USBTX, USBRX);
6+
57
MBED_HOSTTEST_TIMEOUT(20);
68
MBED_HOSTTEST_SELECT(serial_nc_rx_auto);
79
MBED_HOSTTEST_DESCRIPTION(Serial NC RX);
810
MBED_HOSTTEST_START("MBED_37");
911

10-
Serial *pc = new Serial(NC, USBRX);
11-
1212
char c = pc->getc();
1313

14-
delete pc;
15-
16-
// This should be true
17-
if (c == 'E') {
18-
Serial *pc = new Serial(USBTX, NC);
19-
20-
pc->printf("RX OK - Expected\r\n");
21-
22-
c = pc->getc();
23-
24-
// This should be false/not get here
25-
if (c == 'U') {
26-
pc->printf("RX OK - Unexpected\r\n");
27-
}
2814

29-
delete pc;
15+
// This should be true, sync the start of test
16+
if (c == 'S') {
17+
pc->printf("RX OK - Start NC test\r\n");
18+
19+
// disconnect TX and get char
20+
delete pc;
21+
pc = new Serial(NC, USBRX);
22+
c = pc->getc();
23+
if (c == 'E') {
24+
// ok disconnect Rx and answer to host
25+
delete pc;
26+
pc = new Serial(USBTX, NC);
27+
pc->printf("RX OK - Expected\r\n");
28+
29+
c = pc->getc();
30+
// This should be false/not get here
31+
if (c == 'U') {
32+
pc->printf("RX OK - Unexpected\r\n");
33+
}
34+
}
35+
delete pc;
3036
}
3137

3238
while (1) {

libraries/tests/mbed/serial_nc_tx/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
#include "test_env.h"
33

44
int main() {
5+
Serial *pc = new Serial(USBTX, USBRX);
6+
57
MBED_HOSTTEST_TIMEOUT(20);
68
MBED_HOSTTEST_SELECT(serial_nc_tx_auto);
79
MBED_HOSTTEST_DESCRIPTION(Serial NC TX);
810
MBED_HOSTTEST_START("MBED_38");
911

1012
// Wait until we receive start signal from host test
11-
Serial *pc = new Serial(USBTX, USBRX);
1213
char c = pc->getc();
1314
delete pc;
1415

workspace_tools/host_tests/serial_nc_rx_auto.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ class SerialNCRXTest():
2525

2626
def test(self, selftest):
2727
selftest.mbed.flush();
28+
# Wait 0.5 seconds to ensure mbed is listening
29+
time.sleep(0.5)
30+
31+
#handshake with target to sync test start
32+
selftest.mbed.serial_write("S");
33+
34+
strip_chars = string.whitespace + "\0"
35+
36+
out_str = selftest.mbed.serial_readline()
37+
38+
if not out_str:
39+
selftest.notify("HOST: No output detected")
40+
return selftest.RESULT_IO_SERIAL
41+
42+
out_str_stripped = out_str.strip(strip_chars)
43+
44+
if out_str_stripped != "RX OK - Start NC test":
45+
selftest.notify("HOST: Unexpected output. Expected 'RX OK - Expected' but received '%s'" % out_str_stripped)
46+
return selftest.RESULT_FAILURE
47+
48+
# Wait 0.5 seconds to ensure mbed is listening
49+
time.sleep(0.5)
50+
2851
selftest.mbed.serial_write("E");
2952

3053
strip_chars = string.whitespace + "\0"

workspace_tools/host_tests/serial_nc_tx_auto.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class SerialNCTXTest():
2525

2626
def test(self, selftest):
2727
selftest.mbed.flush();
28+
# Wait 0.5 seconds to ensure mbed is listening
29+
time.sleep(0.5)
30+
2831
selftest.mbed.serial_write("S");
2932

3033
strip_chars = string.whitespace + "\0"

0 commit comments

Comments
 (0)