improve error messages

This commit is contained in:
bunnie 2025-10-26 19:30:34 +08:00
parent 2f957d3f35
commit e770249f0a
2 changed files with 5 additions and 5 deletions

View file

@ -11,4 +11,4 @@ pub mod irq;
#[cfg(feature = "bao1x-usb")]
pub mod usb;
pub const UART_BAUD: u32 = 1_000_000;
pub const UART_BAUD: u32 = bao1x_api::UART_BAUD;

View file

@ -123,7 +123,7 @@ impl Repl {
"peek" => {
if args.len() == 1 || args.len() == 2 {
let addr = usize::from_str_radix(&args[0], 16)
.map_err(|_| Error::help("Peek address is in hex"))?;
.map_err(|_| Error::help("Peek address is in hex, no leading 0x"))?;
let count = if args.len() == 2 {
if let Ok(count) = u32::from_str_radix(&args[1], 10) { count } else { 1 }
@ -146,10 +146,10 @@ impl Repl {
"poke" => {
if args.len() == 2 || args.len() == 3 {
let addr = u32::from_str_radix(&args[0], 16)
.map_err(|_| Error::help("Poke address is in hex"))?;
.map_err(|_| Error::help("Poke address is in hex, no leading 0x"))?;
let value =
u32::from_str_radix(&args[1], 16).map_err(|_| Error::help("Poke value is in hex"))?;
let value = u32::from_str_radix(&args[1], 16)
.map_err(|_| Error::help("Poke value is in hex, no leading 0x"))?;
let count = if args.len() == 3 {
if let Ok(count) = u32::from_str_radix(&args[2], 10) { count } else { 1 }
} else {