test framework for xous-names

This commit is contained in:
bunnie 2021-01-04 23:34:18 +08:00
parent 2beddd745e
commit cce89395f6
8 changed files with 41 additions and 11 deletions

12
Cargo.lock generated
View file

@ -821,6 +821,7 @@ dependencies = [
"ticktimer-server", "ticktimer-server",
"utralib", "utralib",
"xous", "xous",
"xous-names",
] ]
[[package]] [[package]]
@ -1159,6 +1160,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "xous-names"
version = "0.1.0"
dependencies = [
"heapless",
"log",
"log-server",
"utralib",
"xous",
]
[[package]] [[package]]
name = "xtask" name = "xtask"
version = "0.1.0" version = "0.1.0"

View file

@ -10,7 +10,7 @@ members = [
"services/com", "services/com",
"services/trng-tester", "services/trng-tester",
"services/fcc-agent", "services/fcc-agent",
# "services/xous-names", "services/xous-names",
"svd2utra", "svd2utra",
"xtask", "xtask",
] ]
@ -21,7 +21,7 @@ default-members = [
"services/ticktimer-server", "services/ticktimer-server",
"services/trng-tester", "services/trng-tester",
"services/fcc-agent", "services/fcc-agent",
# "services/xous-names", "services/xous-names",
"services/com", "services/com",
] ]

View file

@ -23,5 +23,5 @@ utralib = { path = "../../utralib"}
[features] [features]
debugprint = [] debugprint = []
fccagent = [] fccagent = []
#default = [] # "debugprint" default = [] # "debugprint"
default = ["debugprint", "fccagent"] #default = ["debugprint"] # , "fccagent"

View file

@ -15,6 +15,6 @@ utralib = { path = "../../utralib"}
[features] [features]
debugprint = [] # adding this allocates the UART for debugging the logger debugprint = [] # adding this allocates the UART for debugging the logger
logging = [] # adding this allocates the UART for logging of Xous logging = [] # adding this allocates the UART for logging of Xous
default = [] #default = []
#default = ["logging"] default = ["logging"]
#default = ["debugprint"] #default = ["debugprint"]

View file

@ -10,6 +10,7 @@ bitflags = "1.2.1"
xous = { path = "../../xous-rs" } xous = { path = "../../xous-rs" }
graphics-server = { path = "../graphics-server" } graphics-server = { path = "../graphics-server" }
ticktimer-server = { path = "../ticktimer-server" } ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
log-server = { path = "../log-server" } log-server = { path = "../log-server" }
log = "0.4" log = "0.4"

View file

@ -7,6 +7,8 @@ use core::fmt::Write;
use graphics_server::{Circle, DrawStyle, Line, PixelColor, Point, Rectangle}; use graphics_server::{Circle, DrawStyle, Line, PixelColor, Point, Rectangle};
use log::{error, info}; use log::{error, info};
use xous::String; use xous::String;
use xous::ipc::*;
use xous_names::api::Registration;
use core::convert::TryFrom; use core::convert::TryFrom;
@ -136,11 +138,13 @@ fn shell_main() -> ! {
let ticktimer_server_id = xous::SID::from_bytes(b"ticktimer-server").unwrap(); 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 log_server_id = xous::SID::from_bytes(b"xous-log-server ").unwrap();
let com_id = xous::SID::from_bytes(b"com ").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 log_conn = xous::connect(log_server_id).unwrap();
let graphics_conn = xous::connect(graphics_server_id).unwrap(); let graphics_conn = xous::connect(graphics_server_id).unwrap();
let ticktimer_conn = xous::connect(ticktimer_server_id).unwrap(); let ticktimer_conn = xous::connect(ticktimer_server_id).unwrap();
let com_conn = xous::connect(com_id).unwrap(); let com_conn = xous::connect(com_id).unwrap();
let ns_conn = xous::connect(ns_id).unwrap();
info!( info!(
"SHELL: Connected to Log server: {} Graphics server: {} Ticktimer server: {} Com: {}", "SHELL: Connected to Log server: {} Graphics server: {} Ticktimer server: {} Com: {}",
@ -184,7 +188,7 @@ fn shell_main() -> ! {
) )
.expect("couldn't map GPIO CSR range"); .expect("couldn't map GPIO CSR range");
let mut gpio = CSR::new(gpio_base.as_mut_ptr() as *mut u32); 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); let style_dark = DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 1);
@ -215,6 +219,14 @@ fn shell_main() -> ! {
.expect("unable to clear region"); .expect("unable to clear region");
let mut firsttime = true; 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 { loop {
// status bar // status bar
graphics_server::set_glyph_style(graphics_conn, GlyphStyle::Small) graphics_server::set_glyph_style(graphics_conn, GlyphStyle::Small)
@ -275,7 +287,6 @@ fn shell_main() -> ! {
) )
.expect("can't draw line"); .expect("can't draw line");
/*
// work area // work area
string_buffer.clear(); string_buffer.clear();
write!( write!(
@ -303,7 +314,7 @@ fn shell_main() -> ! {
.expect("unable to draw string"); .expect("unable to draw string");
firsttime = false; firsttime = false;
} }
*/
// rate limit graphics // rate limit graphics
//ticktimer_server::sleep_ms(ticktimer_conn, 500).expect("couldn't sleep"); //ticktimer_server::sleep_ms(ticktimer_conn, 500).expect("couldn't sleep");
@ -344,10 +355,15 @@ fn shell_main() -> ! {
// Periodic tasks // Periodic tasks
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) { 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; last_time = elapsed_time;
info!("Requesting batt stats from COM"); info!("Requesting batt stats from COM");
get_batt_stats_nb(com_conn).expect("Can't get battery 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 { } else {
error!("error requesting ticktimer!") error!("error requesting ticktimer!")

View file

@ -151,7 +151,7 @@ impl<T: Send> Sendable<T> {
result result
} }
/// Perform a mutable lend of this Carton to the server. /// Perform a move of this Carton to the server.
pub fn send( pub fn send(
mut self, mut self,
connection: crate::CID, connection: crate::CID,

View file

@ -82,6 +82,7 @@ fn build_hw_image(debug: bool, svd: Option<String>) -> Result<(), DynError> {
"ticktimer-server", "ticktimer-server",
"log-server", "log-server",
"com", "com",
"xous-names",
] { ] {
// "xous-names" // "xous-names"
// "fcc-agent" // "fcc-agent"