[SC64][SW] Added command to reset SC64 state in deployer

This commit is contained in:
Mateusz Faderewski 2023-12-14 20:33:21 +01:00
parent 3f3f1e3b86
commit bf13434f40

View File

@ -60,6 +60,9 @@ enum Commands {
/// Print information about connected SC64 device /// Print information about connected SC64 device
Info, Info,
/// Reset SC64 state (same as after power-up)
Reset,
/// Update persistent settings on SC64 device /// Update persistent settings on SC64 device
Set { Set {
#[command(subcommand)] #[command(subcommand)]
@ -317,6 +320,7 @@ fn handle_command(command: &Commands, port: Option<String>, remote: Option<Strin
Commands::Debug(args) => handle_debug_command(connection, args), Commands::Debug(args) => handle_debug_command(connection, args),
Commands::Dump(args) => handle_dump_command(connection, args), Commands::Dump(args) => handle_dump_command(connection, args),
Commands::Info => handle_info_command(connection), Commands::Info => handle_info_command(connection),
Commands::Reset => handle_reset_command(connection),
Commands::Set { command } => handle_set_command(connection, command), Commands::Set { command } => handle_set_command(connection, command),
Commands::Firmware { command } => handle_firmware_command(connection, command), Commands::Firmware { command } => handle_firmware_command(connection, command),
Commands::Server(args) => handle_server_command(connection, args), Commands::Server(args) => handle_server_command(connection, args),
@ -739,6 +743,16 @@ fn handle_info_command(connection: Connection) -> Result<(), sc64::Error> {
Ok(()) Ok(())
} }
fn handle_reset_command(connection: Connection) -> Result<(), sc64::Error> {
let mut sc64 = init_sc64(connection, true)?;
sc64.reset_state()?;
println!("SC64 state has been reset");
Ok(())
}
fn handle_set_command(connection: Connection, command: &SetCommands) -> Result<(), sc64::Error> { fn handle_set_command(connection: Connection, command: &SetCommands) -> Result<(), sc64::Error> {
let mut sc64 = init_sc64(connection, true)?; let mut sc64 = init_sc64(connection, true)?;