From cce89395f63b9df0287141f1de86673c23c8d665 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 4 Jan 2021 23:34:18 +0800 Subject: [PATCH] test framework for xous-names --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 4 ++-- services/com/Cargo.toml | 4 ++-- services/log-server/Cargo.toml | 4 ++-- services/shell/Cargo.toml | 1 + services/shell/src/main.rs | 24 ++++++++++++++++++++---- xous-rs/src/ipc.rs | 2 +- xtask/src/main.rs | 1 + 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfffa1c7f..c9ad92ba4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -821,6 +821,7 @@ dependencies = [ "ticktimer-server", "utralib", "xous", + "xous-names", ] [[package]] @@ -1159,6 +1160,17 @@ dependencies = [ "syn", ] +[[package]] +name = "xous-names" +version = "0.1.0" +dependencies = [ + "heapless", + "log", + "log-server", + "utralib", + "xous", +] + [[package]] name = "xtask" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 20d93fdc4..f11b5f56e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ members = [ "services/com", "services/trng-tester", "services/fcc-agent", -# "services/xous-names", + "services/xous-names", "svd2utra", "xtask", ] @@ -21,7 +21,7 @@ default-members = [ "services/ticktimer-server", "services/trng-tester", "services/fcc-agent", -# "services/xous-names", + "services/xous-names", "services/com", ] diff --git a/services/com/Cargo.toml b/services/com/Cargo.toml index d24ee4bfd..70a67f179 100644 --- a/services/com/Cargo.toml +++ b/services/com/Cargo.toml @@ -23,5 +23,5 @@ utralib = { path = "../../utralib"} [features] debugprint = [] fccagent = [] -#default = [] # "debugprint" -default = ["debugprint", "fccagent"] +default = [] # "debugprint" +#default = ["debugprint"] # , "fccagent" diff --git a/services/log-server/Cargo.toml b/services/log-server/Cargo.toml index 6eba1f577..ba434ac9c 100644 --- a/services/log-server/Cargo.toml +++ b/services/log-server/Cargo.toml @@ -15,6 +15,6 @@ utralib = { path = "../../utralib"} [features] debugprint = [] # adding this allocates the UART for debugging the logger logging = [] # adding this allocates the UART for logging of Xous -default = [] -#default = ["logging"] +#default = [] +default = ["logging"] #default = ["debugprint"] diff --git a/services/shell/Cargo.toml b/services/shell/Cargo.toml index febb074f2..0eb2db14b 100644 --- a/services/shell/Cargo.toml +++ b/services/shell/Cargo.toml @@ -10,6 +10,7 @@ bitflags = "1.2.1" xous = { path = "../../xous-rs" } graphics-server = { path = "../graphics-server" } ticktimer-server = { path = "../ticktimer-server" } +xous-names = { path = "../xous-names" } log-server = { path = "../log-server" } log = "0.4" diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index 7df578e81..6a4b2fe4c 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -7,6 +7,8 @@ use core::fmt::Write; use graphics_server::{Circle, DrawStyle, Line, PixelColor, Point, Rectangle}; use log::{error, info}; use xous::String; +use xous::ipc::*; +use xous_names::api::Registration; use core::convert::TryFrom; @@ -136,11 +138,13 @@ fn shell_main() -> ! { let ticktimer_server_id = xous::SID::from_bytes(b"ticktimer-server").unwrap(); let log_server_id = xous::SID::from_bytes(b"xous-log-server ").unwrap(); let com_id = xous::SID::from_bytes(b"com ").unwrap(); + let ns_id = xous::SID::from_bytes(b"xousnames-server").unwrap(); let log_conn = xous::connect(log_server_id).unwrap(); let graphics_conn = xous::connect(graphics_server_id).unwrap(); let ticktimer_conn = xous::connect(ticktimer_server_id).unwrap(); let com_conn = xous::connect(com_id).unwrap(); + let ns_conn = xous::connect(ns_id).unwrap(); info!( "SHELL: Connected to Log server: {} Graphics server: {} Ticktimer server: {} Com: {}", @@ -184,7 +188,7 @@ fn shell_main() -> ! { ) .expect("couldn't map GPIO CSR range"); let mut gpio = CSR::new(gpio_base.as_mut_ptr() as *mut u32); - gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 2); // 0 = kernel, 1 = log, 2 = app_uart + gpio.wfo(utra::gpio::UARTSEL_UARTSEL, 1); // 0 = kernel, 1 = log, 2 = app_uart } let style_dark = DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 1); @@ -215,6 +219,14 @@ fn shell_main() -> ! { .expect("unable to clear region"); let mut firsttime = true; + let mut registration = Registration { + sid: xous::SID::from_u32(0, 0, 0, 0,), + name: *b"test name ", + name_len: b"test name".len(), + success: false + }; + let mut sendable_registration = Sendable::new(registration) + .expect("can't create sendable registration structure"); loop { // status bar graphics_server::set_glyph_style(graphics_conn, GlyphStyle::Small) @@ -275,7 +287,6 @@ fn shell_main() -> ! { ) .expect("can't draw line"); - /* // work area string_buffer.clear(); write!( @@ -303,7 +314,7 @@ fn shell_main() -> ! { .expect("unable to draw string"); firsttime = false; } - */ + // rate limit graphics //ticktimer_server::sleep_ms(ticktimer_conn, 500).expect("couldn't sleep"); @@ -344,10 +355,15 @@ fn shell_main() -> ! { // Periodic tasks if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) { - if elapsed_time - last_time > 1000 { + if elapsed_time - last_time > 500 { last_time = elapsed_time; info!("Requesting batt stats from COM"); get_batt_stats_nb(com_conn).expect("Can't get battery stats from COM"); + info!("Test NS lookup"); + sendable_registration.success = false; + info!("NS lookup input: {:?}", sendable_registration.success); + sendable_registration.lend_mut(ns_conn, xous_names::api::ID_REGISTER_NAME); + info!("NS lookup result: {:?}", sendable_registration.success); } } else { error!("error requesting ticktimer!") diff --git a/xous-rs/src/ipc.rs b/xous-rs/src/ipc.rs index b906681c1..fab693701 100644 --- a/xous-rs/src/ipc.rs +++ b/xous-rs/src/ipc.rs @@ -151,7 +151,7 @@ impl Sendable { result } - /// Perform a mutable lend of this Carton to the server. + /// Perform a move of this Carton to the server. pub fn send( mut self, connection: crate::CID, diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9a84b3be8..c5b5aa6fa 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -82,6 +82,7 @@ fn build_hw_image(debug: bool, svd: Option) -> Result<(), DynError> { "ticktimer-server", "log-server", "com", + "xous-names", ] { // "xous-names" // "fcc-agent"