diff --git a/Cargo.lock b/Cargo.lock index c2183112d..1ac0b41c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1106,16 +1106,25 @@ dependencies = [ name = "dns" version = "0.1.0" dependencies = [ + "chrono", + "gam", + "llio", + "locales", "log", + "modals", "net", "num-derive", "num-traits", + "pddb", "rkyv", + "sntpc", "trng", + "userprefs", "utralib", "xous 0.9.37 (registry+https://github.com/rust-lang/crates.io-index)", "xous-api-log", "xous-api-names", + "xous-api-susres", "xous-api-ticktimer", "xous-ipc 0.9.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3817,6 +3826,7 @@ dependencies = [ "content-plugin-api", "crossbeam", "digest 0.9.0", + "dns", "gam", "graphics-server", "keyboard", @@ -3831,7 +3841,6 @@ dependencies = [ "rkyv", "root-keys", "sha2", - "sntpc", "trng", "usb-device-xous", "userprefs", diff --git a/services/dns/Cargo.toml b/services/dns/Cargo.toml index 724e40754..7fcbf2424 100644 --- a/services/dns/Cargo.toml +++ b/services/dns/Cargo.toml @@ -19,6 +19,19 @@ xous-ipc = "0.9.37" rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} trng = {path = "../trng"} +# for the time UX wart +# time UX is stuck here because the DNS crate has a lot of connections available +# and the more logically grouped status crate has run out of resources. +llio = {path = "../llio"} +pddb = {path = "../pddb"} +chrono = {version = "0.4.19", default-features = false, features = ["std"]} +sntpc = {version = "0.3.1"} #, features = ["log"] +locales = {path = "../../locales"} +gam = {path = "../gam"} +susres = {package = "xous-api-susres", version = "0.9.32"} +userprefs = {path = "../../libs/userprefs"} +modals = {path = "../modals"} + utralib = { version = "0.1.16", optional = true, default-features = false } [features] diff --git a/services/dns/src/api.rs b/services/dns/src/api.rs index 688d080b5..75f0500fd 100644 --- a/services/dns/src/api.rs +++ b/services/dns/src/api.rs @@ -80,3 +80,15 @@ pub struct DnsResponse { pub addr: Option, pub code: DnsResponseCode, } + +// Time API items. Time is in the DNS crate because it has the resources +// to accommodate the time server, while the more logically grouped status +// crate does not. +pub const TIME_UX_NAME: &'static str = "_time UX server_"; +/// Time API exports +#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)] +pub enum TimeUxOp { + SetTime = 0, + SetTimeZone = 1, + Quit = 2, +} diff --git a/services/dns/src/lib.rs b/services/dns/src/lib.rs index 0d03f6c38..eef26ee40 100644 --- a/services/dns/src/lib.rs +++ b/services/dns/src/lib.rs @@ -1,6 +1,6 @@ pub mod api; #[allow(unused_imports)] -use api::*; +pub use api::*; #[cfg(any(feature="precursor", feature="renode"))] mod hw; diff --git a/services/dns/src/main.rs b/services/dns/src/main.rs index c8625d460..b2a47c23a 100644 --- a/services/dns/src/main.rs +++ b/services/dns/src/main.rs @@ -2,6 +2,7 @@ #![cfg_attr(target_os = "none", no_main)] mod api; +mod time; // why is this here? because it's the only place it'll fit. :-/ use api::*; use net::NetIpAddr; @@ -484,6 +485,14 @@ fn main() -> ! { log::set_max_level(log::LevelFilter::Info); log::info!("my PID is {}", xous::process::id()); + // Time is stuck in the DNS crate because the status crate is out of resources, and the DNS + // crate is fairly under-utilized and ideal for sticking a service like time in it. + // + // this kicks off the thread that services the `libstd` calls for time-related things. + // we want this started really early, because it sanity checks the RTC and a bunch of other stuff. + time::start_time_server(); + time::start_time_ux(); + let xns = xous_names::XousNames::new().unwrap(); let dns_sid = xns .register_name(api::SERVER_NAME_DNS, None) diff --git a/services/status/src/time.rs b/services/dns/src/time.rs similarity index 98% rename from services/status/src/time.rs rename to services/dns/src/time.rs index 161cce301..a26d19e88 100644 --- a/services/status/src/time.rs +++ b/services/dns/src/time.rs @@ -91,12 +91,6 @@ pub(crate) enum PrivTimeOp { SusRes = 1, } -#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)] -pub(crate) enum TimeUxOp { - SetTime, - SetTimeZone, - Quit, -} #[derive(Copy, Clone, Default)] struct StdTimestampGen { duration: std::time::Duration, @@ -556,11 +550,12 @@ fn simple_kilofloat_parse(input: &str) -> core::result::Result xous::msg_scalar_unpack!(msg, _, _, _, _, { + Some(crate::TimeUxOp::SetTime) => xous::msg_scalar_unpack!(msg, _, _, _, _, { if !pddb_poller.is_mounted_nonblocking() { modals.show_notification(t!("stats.please_mount", xous::LANG), None).expect("couldn't show notification"); continue; @@ -706,7 +701,7 @@ pub fn start_time_ux(sid: xous::SID) { ) ).expect("couldn't set time"); }), - Some(TimeUxOp::SetTimeZone) => xous::msg_scalar_unpack!(msg, _, _, _, _, { + Some(crate::TimeUxOp::SetTimeZone) => xous::msg_scalar_unpack!(msg, _, _, _, _, { if !pddb_poller.is_mounted_nonblocking() { modals.show_notification(t!("stats.please_mount", xous::LANG), None).expect("couldn't show notification"); continue; @@ -730,7 +725,7 @@ pub fn start_time_ux(sid: xous::SID) { ) ).expect("couldn't set timezone"); }), - Some(TimeUxOp::Quit) => { + Some(crate::TimeUxOp::Quit) => { xous::return_scalar(msg.sender, 0).unwrap(); break; } diff --git a/services/status/Cargo.toml b/services/status/Cargo.toml index e717190db..199cf5093 100644 --- a/services/status/Cargo.toml +++ b/services/status/Cargo.toml @@ -29,13 +29,13 @@ keyboard = {path = "../keyboard"} usb-device-xous = {path="../usb-device-xous"} codec = {path="../codec"} userprefs = {path = "../../libs/userprefs"} +dns = {path="../dns"} num-derive = {version = "0.3.3", default-features = false} num-traits = {version = "0.2.14", default-features = false} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} chrono = {version = "0.4.19", default-features = false, features = ["std"]} -sntpc = {version = "0.3.1"} #, features = ["log"] crossbeam = "0.8.2" sha2 = {path="../engine-sha512"} diff --git a/services/status/src/ecup.rs b/services/status/src/ecup.rs index aca86d359..9b594b269 100644 --- a/services/status/src/ecup.rs +++ b/services/status/src/ecup.rs @@ -259,7 +259,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { do_fw = true; } log::info!("Auto-version check results: do_gw: {:?}, do_fw: {:?}", do_gw, do_fw); - if do_gw { + if do_gw || force { log::info!("updating GW"); netmgr.connection_manager_stop().ok(); llio.com_event_enable(false).ok(); @@ -272,7 +272,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { } susres.set_suspendable(true).unwrap(); // resume suspend/resume operations } - if do_fw { + if do_fw || force { log::info!("updating FW"); netmgr.connection_manager_stop().unwrap(); llio.com_event_enable(false).ok(); diff --git a/services/status/src/main.rs b/services/status/src/main.rs index dae7c4fec..ee6261317 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -7,7 +7,6 @@ use mainmenu::*; mod appmenu; use appmenu::*; mod app_autogen; -mod time; mod ecup; mod wifi; mod preferences; @@ -152,10 +151,6 @@ fn wrapped_main() -> ! { log::set_max_level(log::LevelFilter::Info); log::info!("my PID is {}", xous::process::id()); - // this kicks off the thread that services the `libstd` calls for time-related things. - // we want this started really early, because it sanity checks the RTC and a bunch of other stuff. - time::start_time_server(); - // ------------------ acquire the status canvas GID let xns = xous_names::XousNames::new().unwrap(); // 1 connection exactly -- from the GAM to set our canvas GID @@ -1385,7 +1380,6 @@ fn wrapped_main() -> ! { thread::spawn({ let ecup_conn = ecup_conn.clone(); move || { - let xns = xous_names::XousNames::new().unwrap(); // send with an argument of '1', which forces the update match send_message(ecup_conn, Message::new_blocking_scalar(ecup::UpdateOp::UpdateAuto.to_usize().unwrap(), 1, 0, 0, 0) @@ -1393,6 +1387,7 @@ fn wrapped_main() -> ! { xous::Result::Scalar1(r) => { match FromPrimitive::from_usize(r) { Some(ecup::UpdateResult::AutoDone) => { + let xns = xous_names::XousNames::new().unwrap(); let llio = llio::Llio::new(&xns); let netmgr = net::NetManager::new(); // restore interrupts and connection manager @@ -1404,6 +1399,7 @@ fn wrapped_main() -> ! { panic!("Force update responded with nothing to do. This is a bug, please report it in xous-core issues, and note the results of `ver ec`, `ver xous`, `ver soc`, `ver wf200`."); }, Some(ecup::UpdateResult::Abort) => { + let xns = xous_names::XousNames::new().unwrap(); let modals = modals::Modals::new(&xns).unwrap(); modals.show_notification(t!("ecup.abort", xous::LANG), None).unwrap(); } diff --git a/services/status/src/preferences.rs b/services/status/src/preferences.rs index 53f4ea826..5777ed052 100644 --- a/services/status/src/preferences.rs +++ b/services/status/src/preferences.rs @@ -389,7 +389,7 @@ impl DevicePrefs { xous::send_message( self.time_ux_cid, xous::Message::new_scalar( - crate::time::TimeUxOp::SetTime.to_usize().unwrap(), + dns::TimeUxOp::SetTime.to_usize().unwrap(), 0, 0, 0, @@ -407,7 +407,7 @@ impl DevicePrefs { xous::send_message( self.time_ux_cid, xous::Message::new_scalar( - crate::time::TimeUxOp::SetTimeZone.to_usize().unwrap(), + dns::TimeUxOp::SetTimeZone.to_usize().unwrap(), 0, 0, 0, @@ -600,9 +600,7 @@ fn run_menu_thread(sid: xous::SID, status_cid: xous::CID) { let menumatic_sid = xous::create_server().unwrap(); // --------------------------- spawn a time UX manager thread - let time_sid = xous::create_server().unwrap(); - let time_cid = xous::connect(time_sid).unwrap(); - crate::time::start_time_ux(time_sid); + let time_cid = xns.request_connection_blocking(dns::api::TIME_UX_NAME).unwrap(); #[cfg(not(feature="no-codec"))] let codec = codec::Codec::new(&xns).unwrap();