Skip to content

Commit bd36290

Browse files
authored
Merge pull request #788 from JoshuaWatt/uboot-console-loop
ubootdriver: Use a loop to access the u-boot console
2 parents 2082d9a + 897f625 commit bd36290

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

labgrid/driver/ubootdriver.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,26 @@ def _await_prompt(self):
152152
enter the password.
153153
"""
154154
self.console.expect(self.boot_expression, timeout=self.login_timeout)
155-
index, _, _, _ = self.console.expect(
156-
[self.prompt, self.autoboot, self.password_prompt]
157-
)
158-
if index == 0:
159-
self._status = 1
160-
elif index == 2:
161-
if self.password:
162-
self.console.sendline(self.password)
163-
self._check_prompt()
164-
else:
165-
raise Exception("Password entry needed but no password set")
166-
else:
167-
self.console.write(self.interrupt.encode('ASCII'))
155+
while True:
156+
index, _, _, _ = self.console.expect(
157+
[self.prompt, self.autoboot, self.password_prompt]
158+
)
159+
if index == 0:
160+
self._status = 1
161+
break
162+
163+
elif index == 1:
164+
self.console.write(self.interrupt.encode('ASCII'))
165+
166+
elif index == 2:
167+
if self.password:
168+
self.console.sendline(self.password)
169+
else:
170+
raise Exception("Password entry needed but no password set")
171+
172+
if self.prompt:
168173
self._check_prompt()
174+
169175
for command in self.init_commands: #pylint: disable=not-an-iterable
170176
self._run_check(command)
171177

0 commit comments

Comments
 (0)