Add cmdline-flag handling.

For now, just interface settings for the stage control:

```
target/release/hostcontrol --help
Usage: hostcontrol [OPTIONS]

Options:
      --stage-device <STAGE_DEVICE>  Interface to talk to movement stage [default: /dev/ttyACM0]
      --tty-speed <TTY_SPEED>        Speed of the stage device (bps) [default: 115200]
  -h, --help                         Print help
  -V, --version                      Print version
```

Signed-off-by: Henner Zeller <h.zeller@acm.org>
This commit is contained in:
Henner Zeller 2026-03-08 08:35:36 +01:00
parent f65cc9236b
commit 7d8337bd5e
3 changed files with 63 additions and 1 deletions

47
hostcontrol/Cargo.lock generated
View file

@ -656,6 +656,46 @@ dependencies = [
"libc", "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]] [[package]]
name = "clipboard-win" name = "clipboard-win"
version = "5.4.0" version = "5.4.0"
@ -1443,6 +1483,7 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
name = "hostcontrol" name = "hostcontrol"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap",
"eframe", "eframe",
"egui", "egui",
"env_logger", "env_logger",
@ -2936,6 +2977,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "strum" name = "strum"
version = "0.26.3" version = "0.26.3"

View file

@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
clap = { version = "4.0", features = ["derive"] }
nalgebra = { version = "0.33" } nalgebra = { version = "0.33" }
serialport = { version = "4", default-features = false } serialport = { version = "4", default-features = false }
thiserror = "2" thiserror = "2"

View file

@ -1,10 +1,24 @@
use std::{thread::sleep, time::Duration}; use std::{thread::sleep, time::Duration};
use clap::Parser;
mod stage; 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() { fn main() {
let args = CliArgs::parse();
env_logger::init(); 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 mut s = stage::Stage::new(stage_io, 1.12).unwrap();
let origin = nalgebra::vector![3000.0, 0.0, -6000.0]; let origin = nalgebra::vector![3000.0, 0.0, -6000.0];
//println!("{}", s.version().unwrap()); //println!("{}", s.version().unwrap());