Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pyocd/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,18 +623,21 @@ def disconnect(self) -> None:
assert (self._probe is not None) and (self._board is not None)

LOG.debug("uninit session %s", self)
suppress_error = getattr(self.context_state, 'suppress_disconnect_error', False)
log = LOG.debug if suppress_error else LOG.error
if self._inited:
try:
self._board.uninit()
self._inited = False
except exceptions.Error:
LOG.error("Error during board uninit:", exc_info=self.log_tracebacks)
log("Error during board uninit:", exc_info=self.log_tracebacks)
finally:
self._inited = False

if self._probe.is_open and (self._probe.wire_protocol is not None):
try:
self._probe.disconnect()
except exceptions.Error:
LOG.error("Probe error during disconnect:", exc_info=self.log_tracebacks)
log("Probe error during disconnect:", exc_info=self.log_tracebacks)

def close(self) -> None:
"""@brief Close the session.
Expand All @@ -651,7 +654,9 @@ def close(self) -> None:
try:
self._probe.close()
except exceptions.Error:
LOG.error("Probe error during close:", exc_info=self.log_tracebacks)
suppress_error = getattr(self.context_state, 'suppress_disconnect_error', False)
log = LOG.debug if suppress_error else LOG.error
log("Probe error during close:", exc_info=self.log_tracebacks)

class UserScriptFunctionProxy:
"""@brief Proxy for user script functions.
Expand Down
3 changes: 3 additions & 0 deletions pyocd/subcommands/load_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,8 @@ def invoke(self) -> int:
# Skip DebugCoreStop and DebugPortStop unless it was explicitly requested by user.
if not session.options.is_set('resume_on_disconnect'):
session.options.set('resume_on_disconnect', False)
finally:
# Set a flag to suppress error logging for disconnect errors during session close.
session.context_state.suppress_disconnect_error = True

return 0
Loading