examples/isp.rs: handle more USB UART adapter paths

Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
This commit is contained in:
Michał Kopeć
2024-06-20 12:32:55 +02:00
parent 763269951a
commit 6d142f4923
2 changed files with 16 additions and 2 deletions

View File

@@ -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"

View File

@@ -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];