-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi,
I'm did a prototype for a STM32 chip using the ardiuno example as a basis. I have the same LedCommend
// Enum to represent commands and subcommands that can be issued to control LEDs.
// Tripple slash comments are used for generating the help for the CLI.
// Contains two subcommands and their functionality is defined inside on_led()
#[derive(Debug, Command)]
pub enum LedCommand {
/// Get current LED value
Get,
/// Set LED value
Set {
/// LED brightness
value: u8,
},
}
/// Function to process LED commands, This function is called once the Base CLI detects an LED command.
pub fn on_led<I: embedded_io::Write>(
cli: &mut CliHandle<'_, Writer<I>, CliError>,
state: &mut AppState,
id: u8,
command: LedCommand,
) -> Result<(), CliError> {
state.num_commands += 1; // Increment command count for state tracking
if id as usize >= state.led_brightness.len() {
uwrite!(cli.writer(), "{}{}{}\n", "LED", id, " not found")?;
// print command error
cli_print_error_code(cli, type_name::<LedCommand>(), CliError::CommandError)?;
return Ok(());
} else {
match command {
LedCommand::Get => {
uwrite!(
cli.writer(),
"{}{}{}{}\n",
"Current LED",
id,
" brightness: ",
state.led_brightness[id as usize]
)?;
}
LedCommand::Set { value } => {
state.led_brightness[id as usize] = value;
uwrite!(
cli.writer(),
"{}{}{}{}\n",
"Setting LED",
id,
" brightness to ",
state.led_brightness[id as usize]
)?;
}
}
}But this causes a hardfault, look at the call stack i can this
- token.rs:125 -
if let Some(pos) = self.tokens.as_bytes().iter().position(|&b| b == 0) { - arguments.rs:108 -
let raw = self.tokens.next()?; - cli.rs:365 -
let res = handler.process(&mut handle, command);
The CLI com
The interesting thing is, if we clone mainline locally and compile it this hardfault goes away. Want to see if you have any insight into this issue or its an issue fixed already and just need to make a new release.
Metadata
Metadata
Assignees
Labels
No labels