diff --git a/hostcontrol/Cargo.lock b/hostcontrol/Cargo.lock index 54a9403..0bf3de0 100644 --- a/hostcontrol/Cargo.lock +++ b/hostcontrol/Cargo.lock @@ -656,6 +656,46 @@ dependencies = [ "libc", ] +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + [[package]] name = "clipboard-win" version = "5.4.0" @@ -1443,6 +1483,7 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" name = "hostcontrol" version = "0.1.0" dependencies = [ + "clap", "eframe", "egui", "env_logger", @@ -2936,6 +2977,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.26.3" diff --git a/hostcontrol/Cargo.toml b/hostcontrol/Cargo.toml index 16fa0d7..e4099bf 100644 --- a/hostcontrol/Cargo.toml +++ b/hostcontrol/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +clap = { version = "4.0", features = ["derive"] } nalgebra = { version = "0.33" } serialport = { version = "4", default-features = false } thiserror = "2" diff --git a/hostcontrol/src/main.rs b/hostcontrol/src/main.rs index fd7a634..ce9d0c1 100644 --- a/hostcontrol/src/main.rs +++ b/hostcontrol/src/main.rs @@ -1,10 +1,24 @@ use std::{thread::sleep, time::Duration}; +use clap::Parser; mod stage; +#[derive(clap::Parser, Debug)] +#[command(version, about, long_about = None)] +struct CliArgs { + /// Interface to talk to movement stage + #[arg(long, default_value="/dev/ttyACM0")] + stage_device: String, + + /// Speed of the stage device (bps) + #[arg(long, default_value="115200")] + tty_speed: u32, +} + fn main() { + let args = CliArgs::parse(); env_logger::init(); - let stage_io = stage::StageIO::new("/dev/ttyACM0", 115200).unwrap(); + let stage_io = stage::StageIO::new(&args.stage_device, args.tty_speed).unwrap(); let mut s = stage::Stage::new(stage_io, 1.12).unwrap(); let origin = nalgebra::vector![3000.0, 0.0, -6000.0]; //println!("{}", s.version().unwrap());