diff --git a/Cargo.toml b/Cargo.toml index b2d98ed..e2f4776 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,9 @@ repository = "https://github.com/system76/ecflash" [lib] name = "ecflash" +[dependencies] +glob = "0.3.1" + [dev-dependencies] libc = "0.2.121" redox_hwio = "0.1.5" diff --git a/examples/isp.rs b/examples/isp.rs index fb60d89..f638416 100644 --- a/examples/isp.rs +++ b/examples/isp.rs @@ -2,6 +2,8 @@ #![allow(clippy::missing_safety_doc)] #![allow(clippy::needless_range_loop)] +//extern crate glob; + use hwio::{Io, Pio}; use serialport::{Error, ErrorKind, Result, TTYPort}; use std::any::Any; @@ -11,6 +13,7 @@ use std::io::{self, Read, Write}; use std::process; use std::time::Duration; use std::thread; +use glob::glob; use ecflash::EcFlash; @@ -816,8 +819,16 @@ fn isp(internal: bool, file: &str) -> Result<()> { } } } else { - // Open arduino console - let mut port = ParallelArduino::new("/dev/ttyACM0")?; + // Open first serial device we find + let serial_device = glob("/dev/serial/by-id/usb-*") + .unwrap() + .next() + .expect("No serial device found.") + .unwrap(); + + println!("Using serial device: {:?}", serial_device.display()); + + let mut port = ParallelArduino::new(serial_device.to_str().unwrap())?; // Read ID let mut id = [0; 3];