Add option to manually set serial port

the default is /dev/heliox, which is a symlink to /dev/ttyUSBx
This commit is contained in:
GHOSCHT 2024-02-06 14:01:26 +01:00
parent b3ec529d1c
commit 72c9fa0a58
Signed by: ghoscht
GPG key ID: 2C2C1C62A5388E82

View file

@ -4,13 +4,16 @@ use std::time::Duration;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
struct Args { struct Args {
#[arg(short, long)]
mode: String, mode: String,
#[arg(short, long)]
port: Option<String>,
} }
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
let mut port = serialport::new("/dev/heliox", 115_200) let default_address = "/dev/heliox".to_string();
let address = args.port.unwrap_or(default_address);
let mut port = serialport::new(address, 115_200)
.timeout(Duration::from_millis(10)) .timeout(Duration::from_millis(10))
.open() .open()
.expect("Failed to open port"); .expect("Failed to open port");