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.
pull/7009/head
Przemyslaw Stekiel 2018-03-07 10:10:20 +01:00 committed by Bartek Szatkowski
parent a1d92e5168
commit c437e9d2c6
2 changed files with 32 additions and 4 deletions

View File

@ -32,7 +32,7 @@ class RtcResetTest(BaseHostTest):
START_TIME = 50000
START_TIME_TOLERANCE = 10
"""Time to delay after sending reset"""
DELAY_TIME = 4.0
DELAY_TIME = 5.0
DELAY_TOLERANCE = 1.0
VALUE_PLACEHOLDER = "0"
@ -47,12 +47,11 @@ class RtcResetTest(BaseHostTest):
if self._error:
return
try:
print("Calling generator")
generator.send((key, value, time))
except StopIteration:
self._error = True
for resp in ("start", "read"):
for resp in ("start", "read", "ack"):
self.register_callback(resp, run_gen)
def teardown(self):
@ -75,7 +74,19 @@ class RtcResetTest(BaseHostTest):
# Initialize, and set the time
self.send_kv("init", self.VALUE_PLACEHOLDER)
# Wait for ack from the device
key, value, time = yield
if key != "ack":
return
self.send_kv("write", str(self.START_TIME))
# Wait for ack from the device
key, value, time = yield
if key != "ack":
return
self.send_kv("read", self.VALUE_PLACEHOLDER)
key, value, time = yield
if key != "read":
@ -84,7 +95,15 @@ class RtcResetTest(BaseHostTest):
# Unitialize, and reset
self.send_kv("free", self.VALUE_PLACEHOLDER)
# Wait for ack from the device
key, value, time = yield
if key != "ack":
return
self.send_kv("reset", self.VALUE_PLACEHOLDER)
# No ack after reset
sleep(self.DELAY_TIME)
# Restart the test, and send the sync token
@ -95,6 +114,12 @@ class RtcResetTest(BaseHostTest):
# Initialize, and read the time
self.send_kv("init", self.VALUE_PLACEHOLDER)
# Wait for ack from the device
key, value, time = yield
if key != "ack":
return
self.send_kv("read", self.VALUE_PLACEHOLDER)
key, value, time = yield
if key != "read":

View File

@ -38,10 +38,12 @@ static cmd_status_t handle_command(const char *key, const char *value)
{
if (strcmp(key, "init") == 0) {
rtc_init();
greentea_send_kv("ack", 0);
return CMD_STATUS_CONTINUE;
} else if (strcmp(key, "free") == 0) {
rtc_free();
greentea_send_kv("ack", 0);
return CMD_STATUS_CONTINUE;
} else if (strcmp(key, "read") == 0) {
@ -55,6 +57,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
uint32_t time;
sscanf(value, "%lu", &time);
rtc_write(time);
greentea_send_kv("ack", 0);
return CMD_STATUS_CONTINUE;
} else if (strcmp(key, "reset") == 0) {
@ -74,7 +77,7 @@ static cmd_status_t handle_command(const char *key, const char *value)
/* Test that software reset doesn't stop RTC from counting. */
void rtc_reset_test()
{
GREENTEA_SETUP(60, "rtc_reset");
GREENTEA_SETUP(100, "rtc_reset");
static char _key[10 + 1] = {};
static char _value[128 + 1] = {};