unit tests: Fix retrying with a new baud rate in IDFDUT.start_app()
This commit is contained in:
parent
f6e857c2b9
commit
b3249d56f3
|
@ -104,13 +104,14 @@ class IDFDUT(DUT.SerialDUT):
|
|||
return cls.get_mac(app, port) is not None
|
||||
|
||||
@_uses_esptool
|
||||
def start_app(self, esp, erase_nvs=ERASE_NVS):
|
||||
def _try_flash(self, esp, erase_nvs, baud_rate):
|
||||
"""
|
||||
download and start app.
|
||||
Called by start_app() to try flashing at a particular baud rate.
|
||||
|
||||
:param: erase_nvs: whether erase NVS partition during flash
|
||||
:return: None
|
||||
Structured this way so @_uses_esptool will reconnect each time
|
||||
"""
|
||||
try:
|
||||
# note: opening here prevents us from having to seek back to 0 each time
|
||||
flash_files = [ (offs, open(path, "rb")) for (offs, path) in self.app.flash_files ]
|
||||
|
||||
if erase_nvs:
|
||||
|
@ -144,19 +145,27 @@ class IDFDUT(DUT.SerialDUT):
|
|||
False
|
||||
)
|
||||
|
||||
try:
|
||||
for baud_rate in [ 921600, 115200 ]:
|
||||
try:
|
||||
esp.change_baud(baud_rate)
|
||||
esptool.write_flash(esp, flash_args)
|
||||
finally:
|
||||
for (_,f) in flash_files:
|
||||
f.close()
|
||||
|
||||
def start_app(self, erase_nvs=ERASE_NVS):
|
||||
"""
|
||||
download and start app.
|
||||
|
||||
:param: erase_nvs: whether erase NVS partition during flash
|
||||
:return: None
|
||||
"""
|
||||
for baud_rate in [ 921600, 115200 ]:
|
||||
try:
|
||||
self._try_flash(erase_nvs, baud_rate)
|
||||
break
|
||||
except RuntimeError:
|
||||
continue
|
||||
else:
|
||||
raise IDFToolError()
|
||||
finally:
|
||||
for (_,f) in flash_files:
|
||||
f.close()
|
||||
|
||||
@_uses_esptool
|
||||
def reset(self, esp):
|
||||
|
|
Loading…
Reference in a new issue