Skip to content

Commit

Permalink
fix: close port when connect fails
Browse files Browse the repository at this point in the history
This fixes a bug where the serial port is not closed when the connect
fails. This can cause the port to be left open and unusable.
This occurs when esptool is used as a module and detect_chip is called.

Closes espressif#1044
  • Loading branch information
Dzarda7 authored and radimkarnis committed Jan 8, 2025
1 parent 12095b2 commit d99c972
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion esptool/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def connect(
" if ESP32-C2 doesn't connect"
" (at least 115200 Bd is recommended)."
)

self._port.close()
raise FatalError(
"Failed to connect to {}: {}"
f"{additional_msg}"
Expand Down

0 comments on commit d99c972

Please sign in to comment.