Skip to content

Commit

Permalink
client: fix console --loop on micrcom error
Browse files Browse the repository at this point in the history
In certain situation, e.g. if the serial port vanishes (i.e. on-board
FTDI chips), microcom returns with 1 and:

  Got EOF from port
  connection lost

The loop should still continue, so do not raise an exception in this
case.

Fixes: cdebb1c ("remote/client: return exit code for ssh/scp/rsync/telnet/video/audio/console")
Signed-off-by: Bastian Krause <[email protected]>
  • Loading branch information
Bastian-Krause committed Oct 13, 2023
1 parent 6a11213 commit efc19b4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,10 @@ async def _console(self, place, target, timeout, *, logfile=None, loop=False, li
# use zero timeout to prevent blocking sleeps
target.await_resources([resource], timeout=0.0)

if not place.acquired:
print("place released")
return 255

host, port = proxymanager.get_host_and_port(resource)

# check for valid resources
Expand Down Expand Up @@ -856,11 +860,14 @@ async def console(self, place, target):
while True:
res = await self._console(place, target, 10.0, logfile=self.args.logfile,
loop=self.args.loop, listen_only=self.args.listenonly)
if res:
exc = InteractiveCommandError("microcom error")
exc.exitcode = res
raise exc
# place released
if res == 255:
break
if not self.args.loop:
if res:
exc = InteractiveCommandError("microcom error")
exc.exitcode = res
raise exc
break
await asyncio.sleep(1.0)
console.needs_target = True
Expand Down

0 comments on commit efc19b4

Please sign in to comment.