scaffolding the i2cdetect command

This commit is contained in:
bunnie 2025-06-06 16:45:00 +08:00 committed by Sam Chin
parent 526d8353fd
commit 0d0267f0ea
3 changed files with 16 additions and 21 deletions

17
Cargo.lock generated
View file

@ -1308,25 +1308,26 @@ dependencies = [
[[package]]
name = "curve25519-dalek"
version = "4.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348"
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#bef542a781348054c32a9beaf6bd1195814cace2"
dependencies = [
"cfg-if",
"cpufeatures",
"curve25519-dalek-derive",
"digest 0.10.7",
"engine25519-as",
"fiat-crypto 0.2.7",
"platforms",
"log",
"rustc_version 0.4.0",
"subtle",
"utralib 0.1.25",
"xous 0.9.66 (registry+https://github.com/rust-lang/crates.io-index)",
"zeroize",
]
[[package]]
name = "curve25519-dalek-derive"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#bef542a781348054c32a9beaf6bd1195814cace2"
dependencies = [
"proc-macro2",
"quote",
@ -4074,12 +4075,6 @@ version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
[[package]]
name = "platforms"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d43467300237085a4f9e864b937cf0bc012cef7740be12be1a48b10d2c8a3701"
[[package]]
name = "plotters"
version = "0.3.5"

View file

@ -91,8 +91,8 @@ use usb::*;
mod pddb;
#[cfg(feature = "with-pddb")]
use pddb::*;
mod cute;
use cute::*;
mod i2cdetect;
use i2cdetect:*;
pub struct CmdEnv {
common_env: CommonEnv,
@ -140,14 +140,14 @@ impl CmdEnv {
let mut echo_cmd = Echo {}; // this command has no persistent storage, so we can "create" it every time we call dispatch (but it's a zero-cost absraction so this doesn't actually create any instructions)
let mut ver_cmd = Ver {};
let mut console_cmd = Test {};
let mut cute_cmd = Cute{};
let mut i2cdetect_cmd = I2cdetect{};
let commands: &mut [&mut dyn ShellCmdApi] = &mut [
///// 4. add your command to this array, so that it can be looked up and dispatched
&mut echo_cmd,
&mut ver_cmd,
&mut self.trng_cmd,
&mut cute_cmd,
&mut i2cdetect_cmd,
&mut console_cmd,
#[cfg(feature = "usb")]
&mut self.usb,

View file

@ -3,18 +3,18 @@ use String;
use crate::{CommonEnv, ShellCmdApi};
#[derive(Debug)]
pub struct Cute {}
pub struct I2cDetect {}
impl<'a> ShellCmdApi<'a> for Cute {
cmd_api!(cute);
impl<'a> ShellCmdApi<'a> for I2cDetect {
cmd_api!(cui;
fn process(&mut self, args: String, _env: &mut CommonEnv) -> Result<Option<String>, xous::Error> {
use core::fmt::Write;
let mut ret = String::new();
let helpstring = "Usage:
cute cat - prints cat ascii art
cute bread - prints bread ascii art
cute breadcat - prints breadcat ascii art";
i2cdetect cat - prints cat ascii art
i2cdetect bread - prints bread ascii art
i2cdetect breadcat - prints breadcat ascii art";
let mut tokens = args.split_whitespace();