Skip to content

Commit

Permalink
fix reconnection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Oct 14, 2024
1 parent 670afc0 commit f41cf1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,11 @@ impl MyApp {
if !devices.contains(&self.device) {
self.device.clear();
}

if let Ok(dev) = self.device_lock.read() {
if !dev.name.is_empty() {
self.device = dev.name.clone();
}
}
ui.add_space(10.0);
ui.horizontal(|ui| {
ui.label("Device");
Expand Down
5 changes: 5 additions & 0 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ fn get_device(
*write_guard = devices.clone();
}

// do reconnect
if devices.contains(&last_connected_device.name) {
if let Ok(mut device) = device_lock.write() {
device.name = last_connected_device.name.clone();
device.baud_rate = last_connected_device.baud_rate;
}
return last_connected_device.clone();
}

Expand Down

0 comments on commit f41cf1d

Please sign in to comment.