Skip to content

Commit be6b6ec

Browse files
committed
Commander: fail immediately on error opening probe.
If opening the probe failed, for instance if the probe is already open, then the error was logged but execution continued until another error occurred. This change causes Commander to exit immediately in this case.
1 parent 730b162 commit be6b6ec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pyocd/commands/commander.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class PyOCDCommander(object):
3535
3636
Responsible for connecting the execution context, REPL, and commands, and handles connection.
3737
38+
Exit codes:
39+
- 0 = no errors
40+
- 1 = command error
41+
- 2 = transfer error
42+
- 3 = failed to create session (probe might not exist)
43+
- 4 = failed to open probe
44+
3845
@todo Replace use of args from argparse with something cleaner.
3946
"""
4047

@@ -169,7 +176,9 @@ def connect(self):
169176
self.exit_code = 3
170177
return False
171178

172-
self._post_connect()
179+
if not self._post_connect():
180+
self.exit_code = 4
181+
return False
173182

174183
result = self.context.attach_session(self.session)
175184
if not result:

0 commit comments

Comments
 (0)