mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
stop pump updates while we're doing the RTC setting
The RTC set dialog box is blocking, the pump will eventually lock up the system if we don't stop it. nb: ~200k saved in RAM with the refactor
This commit is contained in:
parent
4f638bb49a
commit
b161b021fe
2 changed files with 23 additions and 11 deletions
|
|
@ -698,10 +698,10 @@ fn xmain() -> ! {
|
|||
|
||||
// create the I2C handler thread
|
||||
// - codec
|
||||
// - rtc xx -> this is now handed off directly in the spawn of the sub command
|
||||
// - rtc
|
||||
// - shellchat
|
||||
// I2C can be used to set time, which can have security implications; we are more strict on counting who can have access to this resource.
|
||||
let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(2)).expect("can't register I2C thread");
|
||||
let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(3)).expect("can't register I2C thread");
|
||||
log::trace!("registered I2C thread with NS -- {:?}", i2c_sid);
|
||||
let _ = thread::spawn({
|
||||
let i2c_sid = i2c_sid.clone();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use llio::Weekday;
|
|||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
#[cfg_attr(
|
||||
not(any(target_os = "none", target_os = "xous")),
|
||||
allow(unused_imports)
|
||||
|
|
@ -71,16 +73,18 @@ pub fn dt_callback(dt: llio::DateTime) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pump_thread(conn: usize) {
|
||||
pub fn pump_thread(conn: usize, pump_run: Arc<AtomicBool>) {
|
||||
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
||||
loop {
|
||||
match send_message(
|
||||
conn as u32,
|
||||
Message::new_scalar(StatusOpcode::Pump.to_usize().unwrap(), 0, 0, 0, 0),
|
||||
) {
|
||||
Err(xous::Error::ServerNotFound) => break,
|
||||
Ok(xous::Result::Ok) => {}
|
||||
_ => panic!("unhandled error in status pump thread"),
|
||||
if pump_run.load(Ordering::Relaxed) {
|
||||
match send_message(
|
||||
conn as u32,
|
||||
Message::new_scalar(StatusOpcode::Pump.to_usize().unwrap(), 0, 0, 0, 0),
|
||||
) {
|
||||
Err(xous::Error::ServerNotFound) => break,
|
||||
Ok(xous::Result::Ok) => {}
|
||||
_ => panic!("unhandled error in status pump thread"),
|
||||
}
|
||||
}
|
||||
ticktimer.sleep_ms(1000).unwrap();
|
||||
}
|
||||
|
|
@ -125,8 +129,14 @@ fn xmain() -> ! {
|
|||
.expect("|status: can't register server");
|
||||
// create a connection for callback hooks
|
||||
unsafe { CB_TO_MAIN_CONN = Some(xous::connect(status_sid).unwrap()) };
|
||||
let pump_run = Arc::new(AtomicBool::new(true));
|
||||
let pump_conn = xous::connect(status_sid).unwrap();
|
||||
xous::create_thread_1(pump_thread, pump_conn as _).expect("couldn't create pump thread");
|
||||
let _ = thread::spawn({
|
||||
let pump_run = pump_run.clone();
|
||||
move || {
|
||||
pump_thread(pump_conn as _, pump_run);
|
||||
}
|
||||
});
|
||||
|
||||
let gam = gam::Gam::new(&xns).expect("|status: can't connect to GAM");
|
||||
let ticktimer = ticktimer_server::Ticktimer::new().expect("Couldn't connect to Ticktimer");
|
||||
|
|
@ -501,6 +511,7 @@ fn xmain() -> ! {
|
|||
datetime = Some(dt);
|
||||
}
|
||||
Some(StatusOpcode::UxSetTime) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||
pump_run.store(false, Ordering::Relaxed); // stop status updates while we do this
|
||||
let secs: u8;
|
||||
let mins: u8;
|
||||
let hours: u8;
|
||||
|
|
@ -584,6 +595,7 @@ fn xmain() -> ! {
|
|||
weekday
|
||||
};
|
||||
rtc.set_rtc(dt).expect("couldn't set the current time");
|
||||
pump_run.store(true, Ordering::Relaxed); // stop status updates while we do this
|
||||
}),
|
||||
Some(StatusOpcode::Quit) => {
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue