Skip to content

Commit

Permalink
Don't disconnect for ESP flasher commands which don't touch the device
Browse files Browse the repository at this point in the history
  • Loading branch information
aivarannamaa committed Jun 2, 2023
1 parent 1e99bd7 commit f5ed255
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version history
* Fix MicroPython config page regression introduced in 4.1.0b1 (#2724, #2763)
* Fix code completion shortcut displayed in macOS menu
* Add command "Show esptool version" for ESP flasher
* Don't disconnect for ESP flasher commands which don't touch the device
* Close tab on middle click (#2767) by @mrexodia
* Make package manager support new micropython-lib index (#2777)
* Report macOS version instead of Darwin version in the About box
Expand Down
3 changes: 0 additions & 3 deletions thonny/plugins/micropython/base_flashing_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ def start_work(self):
target_info: TargetInfo = self._target_combo.get_selected_value()

self.report_progress(0, 100)
proxy = get_runner().get_backend_proxy()
if isinstance(proxy, BareMetalMicroPythonProxy):
proxy.disconnect()

work_options = self.prepare_work_get_options()
self.clear_log()
Expand Down
11 changes: 6 additions & 5 deletions thonny/plugins/micropython/esptool_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,17 @@ def get_variants_url(self) -> str:
def get_action_text_max_length(self):
return 35

def _work_needs_disconnect(self):
return self._work_mode not in ["image_info", "esptool_version"]

def prepare_work_get_options(self) -> Dict[str, Any]:
target = self._target_combo.get_selected_value()
proxy = get_runner().get_backend_proxy()
port_was_used_in_thonny = (
isinstance(proxy, BareMetalMicroPythonProxy) and proxy._port == target.port.device
)
if port_was_used_in_thonny:
if port_was_used_in_thonny and self._work_needs_disconnect():
logger.info("Disconnecting")
proxy.disconnect()

if self._work_mode in ["device_info", "image_info", "esptool_version"]:
Expand Down Expand Up @@ -329,10 +333,7 @@ def perform_core_operation(
else:
raise RuntimeError(f"Unknown work mode {self._work_mode!r}")

if (
self._work_mode in ["install", "device_info"]
and work_options["port_was_used_in_thonny"]
):
if self._work_needs_disconnect() and work_options["port_was_used_in_thonny"]:
self.append_text("Disconnecting from REPL...")
self.set_action_text("Disconnecting from REPL...")
time.sleep(1.5)
Expand Down

0 comments on commit f5ed255

Please sign in to comment.