mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
shell: use log-server for message logging
This paves the way for no longer needing our own UART for this process. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1ffc440565
commit
4f2be0c0e1
3 changed files with 12 additions and 48 deletions
|
|
@ -10,6 +10,8 @@ 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" }
|
||||||
|
log-server = { path = "../log-server" }
|
||||||
|
log = "0.4"
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utralib = { path = "../../utralib"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,6 @@ impl<'a> LogStr<'a> {
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
self.len = 0;
|
self.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn set_len(&mut self, len: usize) {
|
|
||||||
self.len = len;
|
|
||||||
self.string = core::str::from_utf8_unchecked(slice::from_raw_parts(self.raw_slice.as_ptr(), self.len));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Write for LogStr<'a> {
|
impl<'a> Write for LogStr<'a> {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ mod debug;
|
||||||
mod logstr;
|
mod logstr;
|
||||||
mod timer;
|
mod timer;
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
use log::{error, info};
|
||||||
use xous::String;
|
use xous::String;
|
||||||
|
|
||||||
// fn print_and_yield(index: *mut usize) -> ! {
|
// fn print_and_yield(index: *mut usize) -> ! {
|
||||||
|
|
@ -37,11 +38,10 @@ fn ensure_connection(server: xous::SID) -> xous::CID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn shell_main() -> ! {
|
fn shell_main() -> ! {
|
||||||
timer::init();
|
timer::init();
|
||||||
|
log_server::init_wait().unwrap();
|
||||||
|
|
||||||
// let log_server_id = xous::SID::from_bytes(b"xous-logs-output").unwrap();
|
// let log_server_id = xous::SID::from_bytes(b"xous-logs-output").unwrap();
|
||||||
let graphics_server_id = xous::SID::from_bytes(b"graphics-server ").unwrap();
|
let graphics_server_id = xous::SID::from_bytes(b"graphics-server ").unwrap();
|
||||||
|
|
@ -92,14 +92,14 @@ fn shell_main() -> ! {
|
||||||
loop {
|
loop {
|
||||||
// a message passing demo -- checking time
|
// a message passing demo -- checking time
|
||||||
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
||||||
println!("SHELL: {}ms", elapsed_time);
|
info!("SHELL: {}ms", elapsed_time);
|
||||||
if elapsed_time - last_time > 40 {
|
if elapsed_time - last_time > 40 {
|
||||||
last_time = elapsed_time;
|
last_time = elapsed_time;
|
||||||
/*
|
/*
|
||||||
xous::try_send_message(log_conn,
|
xous::try_send_message(log_conn,
|
||||||
xous::Message::Scalar(xous::ScalarMessage{id:256, arg1: elapsed_time as usize, arg2: 257, arg3: 258, arg4: 259}));
|
xous::Message::Scalar(xous::ScalarMessage{id:256, arg1: elapsed_time as usize, arg2: 257, arg3: 258, arg4: 259}));
|
||||||
*/
|
*/
|
||||||
println!("Preparing a mutable borrow message");
|
info!("Preparing a mutable borrow message");
|
||||||
|
|
||||||
ls.clear();
|
ls.clear();
|
||||||
write!(
|
write!(
|
||||||
|
|
@ -113,16 +113,13 @@ fn shell_main() -> ! {
|
||||||
.as_memory_message(0)
|
.as_memory_message(0)
|
||||||
.expect("couldn't form memory message");
|
.expect("couldn't form memory message");
|
||||||
|
|
||||||
println!("Sending a mutable borrow message");
|
info!("Sending a mutable borrow message");
|
||||||
|
|
||||||
let response =
|
xous::syscall::send_message(log_conn, xous::Message::MutableBorrow(mm))
|
||||||
xous::syscall::try_send_message(log_conn, xous::Message::MutableBorrow(mm))
|
|
||||||
.expect("couldn't send memory message");
|
.expect("couldn't send memory message");
|
||||||
//unsafe { ls.set_len(response.0)};
|
|
||||||
//println!("Message came back with args ({}, {}) as: {}", response.0, response.1, ls);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("error requesting ticktimer!")
|
error!("error requesting ticktimer!")
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics_server::set_style(
|
graphics_server::set_style(
|
||||||
|
|
@ -148,40 +145,10 @@ fn shell_main() -> ! {
|
||||||
|
|
||||||
string_buffer.clear();
|
string_buffer.clear();
|
||||||
write!(&mut string_buffer, "Elapsed time: {}ms", last_time).expect("Can't write");
|
write!(&mut string_buffer, "Elapsed time: {}ms", last_time).expect("Can't write");
|
||||||
graphics_server::clear_region(graphics_conn, 0, 0, 300, 40).expect("unable to clear region");
|
graphics_server::clear_region(graphics_conn, 0, 0, 300, 40)
|
||||||
|
.expect("unable to clear region");
|
||||||
|
info!("drawing string: {}", string_buffer);
|
||||||
graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string");
|
graphics_server::draw_string(graphics_conn, &string_buffer).expect("unable to draw string");
|
||||||
graphics_server::flush(graphics_conn).expect("unable to draw to screen");
|
graphics_server::flush(graphics_conn).expect("unable to draw to screen");
|
||||||
|
|
||||||
// let lfsr = move_lfsr(lfsr);
|
|
||||||
// if lfsr.trailing_zeros() >= 3 {
|
|
||||||
// loop {
|
|
||||||
// match xous::syscall::try_send_message(
|
|
||||||
// log_conn,
|
|
||||||
// xous::Message::Scalar(xous::ScalarMessage {
|
|
||||||
// id: counter + 4096,
|
|
||||||
// arg1: counter,
|
|
||||||
// arg2: counter * 2,
|
|
||||||
// arg3: !counter,
|
|
||||||
// arg4: lfsr as _,
|
|
||||||
// }),
|
|
||||||
// ) {
|
|
||||||
// Err(xous::Error::ServerQueueFull) => {
|
|
||||||
// println!("SHELL: Log Server queue is full... retrying");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// Ok(_) => {
|
|
||||||
// println!("SHELL: Loop {}", counter);
|
|
||||||
// counter += 1;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// Err(e) => panic!("Unable to send message: {:?}", e),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // #[cfg(not(target_os = "none"))]
|
|
||||||
// std::thread::sleep(std::time::Duration::from_millis(500));
|
|
||||||
// if counter & 2 == 0 {
|
|
||||||
// xous::syscall::yield_slice();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue