diff --git a/Cargo.toml b/Cargo.toml index 02e58d4..5cc9f43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "kulifuli-host" version = "0.1.0" edition = "2024" +[profile.release] +lto = true + [dependencies] eyre = "0.6.12" serialport = "4.7.2" diff --git a/src/main.rs b/src/main.rs index 221e8d8..98bb987 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,21 @@ use eyre::{Result, bail, ensure, eyre}; use serialport::TTYPort; +use std::env::args; use std::io::{Read, Write, stdin, stdout}; +use std::process::exit; use std::str::FromStr; use std::time::Duration; fn main() -> Result<()> { - let mut port = serialport::new("/dev/ttyACM0", 9600) + let args = args().collect::>(); + let serial_device = args.get(1); + if serial_device.is_none() { + println!("Please give a serial device path as program argument"); + exit(1); + } + let serial_device = serial_device.unwrap(); + + let mut port = serialport::new(serial_device, 9600) .timeout(Duration::from_secs(3600)) .open_native()?;