mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add debug level api calls to USB stack
This commit is contained in:
parent
87bdd6c197
commit
33e43aeb0a
2 changed files with 36 additions and 0 deletions
|
|
@ -29,6 +29,8 @@ pub(crate) enum Opcode {
|
|||
SetAutotypeRate = 10,
|
||||
/// Register a USB event observer
|
||||
RegisterUsbObserver = 11,
|
||||
/// Modify log level
|
||||
SetLogLevel = 12,
|
||||
|
||||
/// Send a U2F message
|
||||
U2fTx = 128,
|
||||
|
|
@ -186,3 +188,28 @@ pub(crate) struct UsbListenerRegistration {
|
|||
pub server_name: xous_ipc::String<64>,
|
||||
pub listener_op_id: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
#[repr(usize)]
|
||||
pub enum LogLevel {
|
||||
Trace = 0,
|
||||
Debug = 1,
|
||||
Info = 2,
|
||||
Warn = 3,
|
||||
Err = 4,
|
||||
}
|
||||
|
||||
impl TryFrom<usize> for LogLevel {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(value: usize) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
0 => Ok(LogLevel::Trace),
|
||||
1 => Ok(LogLevel::Debug),
|
||||
2 => Ok(LogLevel::Info),
|
||||
3 => Ok(LogLevel::Warn),
|
||||
4 => Ok(LogLevel::Err),
|
||||
_ => Err("Invalid LogLevel"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -448,6 +448,15 @@ impl UsbHid {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Attempts to set the logging level of the USB server
|
||||
pub fn set_log_level(&self, level: LogLevel) {
|
||||
send_message(
|
||||
self.conn,
|
||||
Message::new_scalar(Opcode::SetLogLevel.to_usize().unwrap(), level as usize, 0, 0, 0),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
|
|
|||
Loading…
Reference in a new issue