Add option to manually set serial port
the default is /dev/heliox, which is a symlink to /dev/ttyUSBx
This commit is contained in:
parent
b3ec529d1c
commit
72c9fa0a58
1 changed files with 5 additions and 2 deletions
|
@ -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");
|
||||||
|
|
Loading…
Reference in a new issue