From 8c12dbe2af52223550e307392140b4d9bf22d399 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 6 Apr 2021 01:52:26 +0800 Subject: [PATCH] found a bug. --- services/gam/src/main.rs | 1 + services/log-server/src/main.rs | 1 + services/rkyv-test-client/src/main.rs | 6 +++--- services/rkyv-test-server/src/api.rs | 1 - services/rkyv-test-server/src/main.rs | 18 ++++++++++++++++++ services/shellchat/src/cmds/callback.rs | 2 +- services/ticktimer-server/Cargo.toml | 3 ++- services/ticktimer-server/src/main.rs | 2 ++ services/trng/src/main.rs | 6 ++++-- 9 files changed, 32 insertions(+), 8 deletions(-) diff --git a/services/gam/src/main.rs b/services/gam/src/main.rs index 19edeec98..672e326a9 100644 --- a/services/gam/src/main.rs +++ b/services/gam/src/main.rs @@ -224,6 +224,7 @@ fn xmain() -> ! { // make a thread to manage the status bar -- this needs to start after the IMEF is initialized // the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now let status_gid = chatlayout.status.gid(); + log::trace!("starting status thread with gid {:?}", status_gid); xous::create_thread_4(status_thread, status_gid[0] as _, status_gid[1] as _, status_gid[2] as _, status_gid[3] as _).expect("couldn't create status thread"); let mut powerdown_requested = false; diff --git a/services/log-server/src/main.rs b/services/log-server/src/main.rs index cb3003cb0..e125a0fbd 100644 --- a/services/log-server/src/main.rs +++ b/services/log-server/src/main.rs @@ -238,6 +238,7 @@ fn reader_thread(arg: usize) { // capturing the build time of the very most recent change! // writeln!(output, "LOG: *** Built: {:49} ***", env!("VERGEN_BUILD_TIMESTAMP")).unwrap(); writeln!(output, "LOG: ****************************************************************").unwrap(); + println!("LOG: my PID is {}", xous::process::id()); let server_addr = xous::create_server_with_address(b"xous-log-server ").unwrap(); writeln!(output, "LOG: Server listening on address {:?}", server_addr).unwrap(); diff --git a/services/rkyv-test-client/src/main.rs b/services/rkyv-test-client/src/main.rs index 8f02466f9..b1d400011 100644 --- a/services/rkyv-test-client/src/main.rs +++ b/services/rkyv-test-client/src/main.rs @@ -49,11 +49,11 @@ fn rkyv_test_client() -> ! { let xns = xous_names::XousNames::new().unwrap(); - let mut com = com::Com::new(&xns).unwrap(); + /*let mut com = com::Com::new(&xns).unwrap(); com.hook_batt_stats(handle_battstats).unwrap(); let mut kbd = keyboard::Keyboard::new(&xns).unwrap(); - kbd.hook_keyboard_events(handle_keyevents).unwrap(); + kbd.hook_keyboard_events(handle_keyevents).unwrap();*/ loop { log::info!("2 + {} = {}", idx, rkyv_test_server::add(2, idx).unwrap()); ticktimer.sleep_ms(3000).ok(); @@ -72,7 +72,7 @@ fn rkyv_test_client() -> ! { log::info!("Sending a string \"{}\"", sent_str); rkyv_test_server::log_message("prefix", sent_str); - com.req_batt_stats().unwrap(); + //com.req_batt_stats().unwrap(); idx += 1; } diff --git a/services/rkyv-test-server/src/api.rs b/services/rkyv-test-server/src/api.rs index ef9658615..0fa674411 100644 --- a/services/rkyv-test-server/src/api.rs +++ b/services/rkyv-test-server/src/api.rs @@ -1,6 +1,5 @@ use xous_ipc::String; pub(crate) const SERVER_NAME: &str = "Rkyv Test Server 1"; - /// A `usize` value that gets set as the `id` for every message handled /// by our server. #[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)] diff --git a/services/rkyv-test-server/src/main.rs b/services/rkyv-test-server/src/main.rs index 9a6a5d912..41846f711 100644 --- a/services/rkyv-test-server/src/main.rs +++ b/services/rkyv-test-server/src/main.rs @@ -92,6 +92,22 @@ fn double_string(mem: &mut xous::MemoryMessage) { buffer.replace(response).unwrap(); } +fn local_lender(){ + use core::fmt::Write; + + let ticktimer = ticktimer_server::Ticktimer::new().unwrap(); + let mut message_string = xous::String::<64>::new(); + + let mut idx: usize = 0; + loop { + message_string.clear(); + write!(message_string, "LOCAL loop # {:^4}", idx).unwrap(); + idx += 1; + rkyv_test_server::log_message("LOCAL LENDER", message_string); + ticktimer.sleep_ms(500).unwrap(); + } +} + #[xous::xous_main] fn test_main() -> ! { log_server::init_wait().unwrap(); @@ -105,6 +121,8 @@ fn test_main() -> ! { let mut logstring_callback_connections = [None; 32]; + xous::create_thread_0(local_lender); + loop { let mut msg = xous::receive_message(sid).unwrap(); match FromPrimitive::from_usize(msg.body.id()) { diff --git a/services/shellchat/src/cmds/callback.rs b/services/shellchat/src/cmds/callback.rs index f3ee3191f..eaa0ffb13 100644 --- a/services/shellchat/src/cmds/callback.rs +++ b/services/shellchat/src/cmds/callback.rs @@ -20,7 +20,7 @@ pub fn callback_thread() { id: 0xdeadbeef, arg1: 0, arg2: 0, arg3: 0, arg4: 0, })).unwrap(); } else { - xous::yield_slice(); + ticktimer.sleep_ms(250).unwrap(); // a little more polite than simply busy-waiting } } } diff --git a/services/ticktimer-server/Cargo.toml b/services/ticktimer-server/Cargo.toml index fdb796a75..cc09d147e 100644 --- a/services/ticktimer-server/Cargo.toml +++ b/services/ticktimer-server/Cargo.toml @@ -22,5 +22,6 @@ utralib = {path = "../../utralib"} debug-print = [] watchdog = [] # generally you want to disable watchdog if you're doing development. -default = ["watchdog"] +#default = ["watchdog"] +default = [] # default = ["debug-print"] diff --git a/services/ticktimer-server/src/main.rs b/services/ticktimer-server/src/main.rs index 9b092670c..428efc57d 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -76,6 +76,7 @@ mod implementation { // - the ring oscillator has a tolerance band of 65MHz +/- 50% // - the CPU runs at 100MHz with a tight tolerance // - thus we have to confirm the write of the watchdog data before moving to the next state + #[cfg(feature = "watchdog")] if xtt.wdt.rf(utra::wdt::STATE_ENABLED) == 1 { if xtt.wdt.rf(utra::wdt::STATE_DISARMED) != 1 { while xtt.wdt.rf(utra::wdt::STATE_ARMED1) == 1 { @@ -88,6 +89,7 @@ mod implementation { } } // Clear the interrupt + #[cfg(feature = "watchdog")] xtt.wdt.wfo(utra::wdt::EV_PENDING_SOFT_INT, 1); } diff --git a/services/trng/src/main.rs b/services/trng/src/main.rs index 6ee5dc37c..5154076cf 100644 --- a/services/trng/src/main.rs +++ b/services/trng/src/main.rs @@ -154,7 +154,7 @@ fn xmain() -> ! { let xns = xous_names::XousNames::new().unwrap(); let trng_sid = xns.register_name(api::SERVER_NAME_TRNG).expect("can't register server"); - info!("registered with NS -- {:?}", trng_sid); + log::trace!("registered with NS -- {:?}", trng_sid); #[cfg(target_os = "none")] let trng = Trng::new(); @@ -162,7 +162,9 @@ fn xmain() -> ! { #[cfg(not(target_os = "none"))] let mut trng = Trng::new(); - info!("ready to accept requests"); + // pump the TRNG hardware to clear the first number out, sometimes it is 0 due to clock-sync issues on the fifo + trng.get_trng(2); + log::trace!("ready to accept requests"); loop { let msg = xous::receive_message(trng_sid).unwrap();