mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-22 05:59:15 +01:00
[SC64][SW] Added ability to send debug commands at startup in deployer
This commit is contained in:
parent
5c6f25500a
commit
6eb89688ab
@ -18,6 +18,7 @@ pub enum Encoding {
|
|||||||
pub struct Handler {
|
pub struct Handler {
|
||||||
header: Option<Vec<u8>>,
|
header: Option<Vec<u8>>,
|
||||||
line_rx: Receiver<String>,
|
line_rx: Receiver<String>,
|
||||||
|
external_line_tx: Sender<String>,
|
||||||
encoding: Encoding,
|
encoding: Encoding,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +170,10 @@ impl Handler {
|
|||||||
self.encoding = encoding;
|
self.encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn send_external_input(&self, input: &str) {
|
||||||
|
self.external_line_tx.send(input.to_string()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn process_user_input(&self) -> Option<UserInput> {
|
pub fn process_user_input(&self) -> Option<UserInput> {
|
||||||
let raw_line = match self.line_rx.try_recv() {
|
let raw_line = match self.line_rx.try_recv() {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
@ -388,10 +393,14 @@ impl Handler {
|
|||||||
|
|
||||||
pub fn new() -> Handler {
|
pub fn new() -> Handler {
|
||||||
let (line_tx, line_rx) = channel::<String>();
|
let (line_tx, line_rx) = channel::<String>();
|
||||||
|
let external_line_tx = line_tx.clone();
|
||||||
|
|
||||||
spawn(move || stdin_thread(line_tx));
|
spawn(move || stdin_thread(line_tx));
|
||||||
|
|
||||||
Handler {
|
Handler {
|
||||||
header: None,
|
header: None,
|
||||||
line_rx,
|
line_rx,
|
||||||
|
external_line_tx,
|
||||||
encoding: Encoding::UTF8,
|
encoding: Encoding::UTF8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,11 @@ struct DebugArgs {
|
|||||||
|
|
||||||
/// Do not enable save writeback via USB
|
/// Do not enable save writeback via USB
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
no_writeback: bool
|
no_writeback: bool,
|
||||||
|
|
||||||
|
/// List of commands to send after connecting to the SC64, semicolon separated (;)
|
||||||
|
#[arg(long)]
|
||||||
|
init: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
@ -408,7 +412,8 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
"========== [WARNING] ==========".bold().bright_yellow(),
|
"========== [WARNING] ==========".bold().bright_yellow(),
|
||||||
"Do not use this mode when real 64DD accessory is connected to the N64".bright_yellow(),
|
"Do not use this mode when real 64DD accessory is connected to the N64".bright_yellow(),
|
||||||
"Doing so might permanently damage either N64, 64DD or SC64".bright_yellow(),
|
"Doing so might permanently damage either N64, 64DD or SC64".bright_yellow(),
|
||||||
"\"Only 64DD IPL\" mode should be safe on development units without IPL builtin".bright_green()
|
"\"Only 64DD IPL\" mode should be safe on development units without IPL builtin"
|
||||||
|
.bright_green()
|
||||||
);
|
);
|
||||||
|
|
||||||
sc64.reset_state()?;
|
sc64.reset_state()?;
|
||||||
@ -478,7 +483,7 @@ fn handle_64dd_command(connection: Connection, args: &_64DDArgs) -> Result<(), s
|
|||||||
let dd_mode = sc64::DdMode::DdIpl;
|
let dd_mode = sc64::DdMode::DdIpl;
|
||||||
println!("64DD mode set to [{dd_mode}]");
|
println!("64DD mode set to [{dd_mode}]");
|
||||||
sc64.configure_64dd(dd_mode, None)?;
|
sc64.configure_64dd(dd_mode, None)?;
|
||||||
return Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let disk_paths: Vec<String> = args
|
let disk_paths: Vec<String> = args
|
||||||
@ -632,6 +637,13 @@ fn handle_debug_command(connection: Connection, args: &DebugArgs) -> Result<(),
|
|||||||
|
|
||||||
println!("{}: Started", "[Debug]".bold());
|
println!("{}: Started", "[Debug]".bold());
|
||||||
|
|
||||||
|
if let Some(init) = args.init.clone() {
|
||||||
|
for command in init.split(";") {
|
||||||
|
println!("{}: {}", "[Init]".bold(), command);
|
||||||
|
debug_handler.send_external_input(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let exit = setup_exit_flag();
|
let exit = setup_exit_flag();
|
||||||
while !exit.load(Ordering::Relaxed) {
|
while !exit.load(Ordering::Relaxed) {
|
||||||
if let Some(data_packet) = sc64.receive_data_packet()? {
|
if let Some(data_packet) = sc64.receive_data_packet()? {
|
||||||
@ -653,7 +665,7 @@ fn handle_debug_command(connection: Connection, args: &DebugArgs) -> Result<(),
|
|||||||
} else if let Some(user_input) = debug_handler.process_user_input() {
|
} else if let Some(user_input) = debug_handler.process_user_input() {
|
||||||
match user_input {
|
match user_input {
|
||||||
debug::UserInput::Packet(debug_packet) => sc64.send_debug_packet(debug_packet)?,
|
debug::UserInput::Packet(debug_packet) => sc64.send_debug_packet(debug_packet)?,
|
||||||
debug::UserInput::EOF => break
|
debug::UserInput::EOF => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user