fix(mesh): stop probing one physical radio as two devices
/dev/mesh-radio is a udev symlink to a ttyUSB*/ttyACM* node that is also in SERIAL_CANDIDATES, so one board was detected, probed and DTR/RTS-reset twice per reconnect cycle (and shown twice in the UI): - detect_serial_devices() dedupes candidates by canonical path, keeping the stable /dev/mesh-radio name - auto-detect fallback skips the preferred path it just probed this cycle instead of immediately resetting the same board again - probe_device's active-session guard compares canonical paths, so a probe via the alias can no longer open the tty the live session holds Together with the 2s boot-settle and stable-session backoff gate, this takes a plugged-in CP2102/ESP32 board from up to 9 reset events per cycle at a permanent 5s retry floor down to one probe sequence per backoff window — enough for the radio to actually finish booting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
449ed7c1f7
commit
a32e40da31
@@ -1063,8 +1063,18 @@ impl MeshService {
|
||||
/// with the reconnect loop (whichever loses just retries).
|
||||
pub async fn probe_device(&self, path: &str) -> Result<listener::DeviceProbe> {
|
||||
let status = self.state.status.read().await;
|
||||
if status.device_connected && status.device_path.as_deref() == Some(path) {
|
||||
anyhow::bail!("{path} is the active mesh radio — already connected");
|
||||
if status.device_connected {
|
||||
if let Some(active) = status.device_path.as_deref() {
|
||||
// Compare canonical paths: /dev/mesh-radio is a symlink to the
|
||||
// ttyUSB*/ttyACM* node, and a probe through the alias would
|
||||
// still open the very tty the live session is holding.
|
||||
let canon = |p: &str| {
|
||||
std::fs::canonicalize(p).unwrap_or_else(|_| std::path::PathBuf::from(p))
|
||||
};
|
||||
if canon(active) == canon(path) {
|
||||
anyhow::bail!("{path} is the active mesh radio — already connected");
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(status);
|
||||
listener::probe_device(path).await
|
||||
|
||||
Reference in New Issue
Block a user