sleep() loops over all messages awaiting a response
@@ -16,9 +16,14 @@ unsigned sleep(unsigned int seconds) {
amc_message_construct_and_send(TIMED_SERVICE_NAME, &msg, sizeof(time_msg_t));
// Wait for the response
+ while (true) {
amc_message_t* resp;
amc_message_await(TIMED_SERVICE_NAME, &resp);
time_msg_sleep_t* awake = (time_msg_sleep_t*)&resp->body;
- assert(awake->common.event == TIMED_RESP_AWAKE, "Expected awake message from timed");
+ if (awake->common.event == TIMED_RESP_AWAKE) {
+ break;
+ }
+ printf("Discarding message from timed because it was not an awake signal: %d\n", awake->common.event);
+ }
return 0;
}
