diff options
author | Astatin <[email protected]> | 2025-06-29 02:27:13 +0200 |
---|---|---|
committer | Astatin <[email protected]> | 2025-06-29 02:27:13 +0200 |
commit | 4e46a48e042ca0d4d6814624e91108afeb5e7636 (patch) | |
tree | 46afde2ab9315026b4c1588c6919e297f60c6f21 /src/main.rs | |
parent | 4cb95575feedda5e2006d706a9e85db6569043ca (diff) |
Add serial over tcp support
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index d4cdb34..4399548 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,19 @@ struct Cli { /// Window title #[arg(long, default_value = "Gameboy Emulator")] - title: String + title: String, + + /// Serial tcp listen port + #[arg(short='L', long)] + listen: Option<u16>, + + /// Serial tcp connect port + #[arg(short, long)] + connect: Option<String>, + + /// Don't send (or expect) a byte as a response to a serial transfer + #[arg(long, default_value_t = false)] + no_response: bool, } fn main() { @@ -75,8 +87,10 @@ fn main() { let window = desktop::window::DesktopWindow::new(cli.title).unwrap(); - let serial: Box<dyn Serial> = match (cli.fifo_input, cli.fifo_output) { - (Some(fifo_input), Some(fifo_output)) => Box::new(desktop::serial::FIFOSerial::new(fifo_input, fifo_output)), + let serial: Box<dyn Serial> = match (cli.fifo_input, cli.fifo_output, cli.listen, cli.connect) { + (_, _, Some(port), _) => Box::new(desktop::serial::TcpSerial::new_listener(port, cli.no_response)), + (_, _, _, Some(addr)) => Box::new(desktop::serial::TcpSerial::connect(addr, cli.no_response)), + (Some(fifo_input), Some(fifo_output), _, _) => Box::new(desktop::serial::FIFOSerial::new(fifo_input, fifo_output, cli.no_response)), _ => Box::new(desktop::serial::UnconnectedSerial {}) }; |