mirror of
https://github.com/Dasharo/ecflash.git
synced 2026-03-06 15:02:38 -08:00
examples/isp.rs: handle more USB UART adapter paths
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user