Skip to content

Commit c437e9d

Browse files
mprsebulislaw
authored andcommitted
tests-mbed_hal-rtc_reset: Add ack from the device after each command is executed
RTC reset test was failing when board has been just powered and RTC reset test was executed for the first time (issue has been detected on CI). In such case RTC initialization takes more time than in futher rtc_init calls. This has impact on green-tea communication. Commands send by host immediately after init command (write, read) were not handled on the device side and no response to the host was provided. To fix this problem test communication flow has been modified. Device sends ack to the host after RTC init is done. Host sends further RTC commands when ack from the device has been received. Edit: There are still some communication issues on the CI. Add ack from the device after each executed command. Increase test timeout and wait after reset.
1 parent a1d92e5 commit c437e9d

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

TESTS/host_tests/rtc_reset.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RtcResetTest(BaseHostTest):
3232
START_TIME = 50000
3333
START_TIME_TOLERANCE = 10
3434
"""Time to delay after sending reset"""
35-
DELAY_TIME = 4.0
35+
DELAY_TIME = 5.0
3636
DELAY_TOLERANCE = 1.0
3737
VALUE_PLACEHOLDER = "0"
3838

@@ -47,12 +47,11 @@ def run_gen(key, value, time):
4747
if self._error:
4848
return
4949
try:
50-
print("Calling generator")
5150
generator.send((key, value, time))
5251
except StopIteration:
5352
self._error = True
5453

55-
for resp in ("start", "read"):
54+
for resp in ("start", "read", "ack"):
5655
self.register_callback(resp, run_gen)
5756

5857
def teardown(self):
@@ -75,7 +74,19 @@ def rtc_reset_test(self):
7574

7675
# Initialize, and set the time
7776
self.send_kv("init", self.VALUE_PLACEHOLDER)
77+
78+
# Wait for ack from the device
79+
key, value, time = yield
80+
if key != "ack":
81+
return
82+
7883
self.send_kv("write", str(self.START_TIME))
84+
85+
# Wait for ack from the device
86+
key, value, time = yield
87+
if key != "ack":
88+
return
89+
7990
self.send_kv("read", self.VALUE_PLACEHOLDER)
8091
key, value, time = yield
8192
if key != "read":
@@ -84,7 +95,15 @@ def rtc_reset_test(self):
8495

8596
# Unitialize, and reset
8697
self.send_kv("free", self.VALUE_PLACEHOLDER)
98+
99+
# Wait for ack from the device
100+
key, value, time = yield
101+
if key != "ack":
102+
return
103+
87104
self.send_kv("reset", self.VALUE_PLACEHOLDER)
105+
106+
# No ack after reset
88107
sleep(self.DELAY_TIME)
89108

90109
# Restart the test, and send the sync token
@@ -95,6 +114,12 @@ def rtc_reset_test(self):
95114

96115
# Initialize, and read the time
97116
self.send_kv("init", self.VALUE_PLACEHOLDER)
117+
118+
# Wait for ack from the device
119+
key, value, time = yield
120+
if key != "ack":
121+
return
122+
98123
self.send_kv("read", self.VALUE_PLACEHOLDER)
99124
key, value, time = yield
100125
if key != "read":

TESTS/mbed_hal/rtc_reset/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ static cmd_status_t handle_command(const char *key, const char *value)
3838
{
3939
if (strcmp(key, "init") == 0) {
4040
rtc_init();
41+
greentea_send_kv("ack", 0);
4142
return CMD_STATUS_CONTINUE;
4243

4344
} else if (strcmp(key, "free") == 0) {
4445
rtc_free();
46+
greentea_send_kv("ack", 0);
4547
return CMD_STATUS_CONTINUE;
4648

4749
} else if (strcmp(key, "read") == 0) {
@@ -55,6 +57,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
5557
uint32_t time;
5658
sscanf(value, "%lu", &time);
5759
rtc_write(time);
60+
greentea_send_kv("ack", 0);
5861
return CMD_STATUS_CONTINUE;
5962

6063
} else if (strcmp(key, "reset") == 0) {
@@ -74,7 +77,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
7477
/* Test that software reset doesn't stop RTC from counting. */
7578
void rtc_reset_test()
7679
{
77-
GREENTEA_SETUP(60, "rtc_reset");
80+
GREENTEA_SETUP(100, "rtc_reset");
7881

7982
static char _key[10 + 1] = {};
8083
static char _value[128 + 1] = {};

0 commit comments

Comments
 (0)