From 6e5506a23d1e0c24c1d22751640fd1798605c380 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 6 Jan 2022 14:50:44 +0800 Subject: [PATCH] add pddb shell debug commands --- services/shellchat/Cargo.toml | 1 + services/shellchat/src/cmds.rs | 4 +++ services/shellchat/src/cmds/pddb_cmd.rs | 43 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 services/shellchat/src/cmds/pddb_cmd.rs diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index d68d0c6ae..22eef46e0 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -34,6 +34,7 @@ root-keys = {path="../root-keys"} jtag = {path="../jtag"} net = {path="../net"} dns = {path="../dns"} +pddb = {path="../pddb"} trng = {path = "../trng"} diff --git a/services/shellchat/src/cmds.rs b/services/shellchat/src/cmds.rs index 260177cf5..4b19059b9 100644 --- a/services/shellchat/src/cmds.rs +++ b/services/shellchat/src/cmds.rs @@ -100,6 +100,7 @@ mod keys; use keys::*; mod wlan; use wlan::*; mod jtag_cmd; use jtag_cmd::*; mod net_cmd; use net_cmd::*; +mod pddb_cmd; use pddb_cmd::*; //mod fcc; use fcc::*; //mod pds; // dependency of the FCC file @@ -125,6 +126,7 @@ pub struct CmdEnv { keys_cmd: Keys, jtag_cmd: JtagCmd, net_cmd: NetCmd, + pddb_cmd: PddbCmd, //fcc_cmd: Fcc, } @@ -178,6 +180,7 @@ impl CmdEnv { keys_cmd: Keys::new(&xns), jtag_cmd: JtagCmd::new(&xns), net_cmd: NetCmd::new(&xns), + pddb_cmd: PddbCmd::new(&xns), //fcc_cmd: fcc, } @@ -217,6 +220,7 @@ impl CmdEnv { &mut wlan_cmd, &mut self.jtag_cmd, &mut self.net_cmd, + &mut self.pddb_cmd, //&mut self.fcc_cmd, ]; diff --git a/services/shellchat/src/cmds/pddb_cmd.rs b/services/shellchat/src/cmds/pddb_cmd.rs new file mode 100644 index 000000000..3559b326d --- /dev/null +++ b/services/shellchat/src/cmds/pddb_cmd.rs @@ -0,0 +1,43 @@ +use crate::{ShellCmdApi, CommonEnv}; +use xous_ipc::String; + +pub struct PddbCmd { + manager: pddb::PddbBasisManager, +} +impl PddbCmd { + pub fn new(xns: &xous_names::XousNames) -> PddbCmd { + PddbCmd { + manager: pddb::PddbBasisManager::new(), + } + } +} + +impl<'a> ShellCmdApi<'a> for PddbCmd { + cmd_api!(pddb); // inserts boilerplate for command API + + fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result>, xous::Error> { + use core::fmt::Write; + let mut ret = String::<1024>::new(); + let helpstring = "pddb [basislist]"; + + let mut tokens = args.as_str().unwrap().split(' '); + + if let Some(sub_cmd) = tokens.next() { + match sub_cmd { + "basislist" => { + let bases = self.manager.list_basis(); + for basis in bases { + write!(ret, "{}\n", basis).unwrap(); + } + } + _ => { + write!(ret, "{}", helpstring).unwrap(); + } + } + + } else { + write!(ret, "{}", helpstring).unwrap(); + } + Ok(Some(ret)) + } +}