From 5847cb04cfd0ea3cc4050beea2a5b74731385ae2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 13 Jul 2022 15:16:15 +0800 Subject: [PATCH] improve resume error handling in the time block --- services/status/src/time.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/services/status/src/time.rs b/services/status/src/time.rs index 2c232c318..ca252bf6a 100644 --- a/services/status/src/time.rs +++ b/services/status/src/time.rs @@ -204,8 +204,25 @@ pub fn start_time_server() { Some(TimeOp::SusRes) => xous::msg_scalar_unpack!(msg, token, _, _, _, { susres.suspend_until_resume(token).expect("couldn't execute suspend/resume"); // resync time on resume - start_rtc_secs = llio.get_rtc_secs().expect("couldn't read RTC offset value"); - start_tt_ms = tt.elapsed_ms(); + let mut count = 0; + loop { + match llio.get_rtc_secs() { + Ok(secs) => { + start_rtc_secs = secs; + start_tt_ms = tt.elapsed_ms(); + break; + } + Err(e) => { + log::warn!("RTC read yielded error; retrying: {:?}", e); + tt.sleep_ms(850).unwrap(); + count += 1; + if count > 5 { + // this should be a panic, I think, not an abort. + panic!("Couldn't sync time on resume. Something went wrong with the RTC hardware."); + } + } + } + } }), Some(TimeOp::HwSync) => { start_rtc_secs = llio.get_rtc_secs().expect("couldn't read RTC offset value");