IDFDUT: seperate into different classes
The DUT should be created as the correct sub classes. This can be done in the config file (UT_xxx_x.yml) Filter
This commit is contained in:
parent
1f580e3f0e
commit
4558824150
1 changed files with 36 additions and 3 deletions
|
@ -122,7 +122,7 @@ def _uses_esptool(func):
|
||||||
settings = self.port_inst.get_settings()
|
settings = self.port_inst.get_settings()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rom = esptool.ESP32ROM(self.port_inst)
|
rom = self._get_rom()(self.port_inst)
|
||||||
rom.connect('hard_reset')
|
rom.connect('hard_reset')
|
||||||
esp = rom.run_stub()
|
esp = rom.run_stub()
|
||||||
|
|
||||||
|
@ -159,6 +159,10 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
self.exceptions = _queue.Queue()
|
self.exceptions = _queue.Queue()
|
||||||
self.performance_items = _queue.Queue()
|
self.performance_items = _queue.Queue()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_rom(cls):
|
||||||
|
raise NotImplementedError("This is an abstraction class, method not defined.")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mac(cls, app, port):
|
def get_mac(cls, app, port):
|
||||||
"""
|
"""
|
||||||
|
@ -169,7 +173,7 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
:return: MAC address or None
|
:return: MAC address or None
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
esp = esptool.ESP32ROM(port)
|
esp = cls._get_rom()(port)
|
||||||
esp.connect()
|
esp.connect()
|
||||||
return esp.read_mac()
|
return esp.read_mac()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
@ -181,7 +185,18 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def confirm_dut(cls, port, app, **kwargs):
|
def confirm_dut(cls, port, app, **kwargs):
|
||||||
return cls.get_mac(app, port) is not None
|
try:
|
||||||
|
# TODO: check whether 8266 works with this logic
|
||||||
|
# Otherwise overwrite it in ESP8266DUT
|
||||||
|
inst = esptool.ESPLoader.detect_chip(port)
|
||||||
|
if type(inst) != cls._get_rom():
|
||||||
|
raise RuntimeError("Target not expected")
|
||||||
|
return inst.read_mac() is not None
|
||||||
|
except(esptool.FatalError, RuntimeError):
|
||||||
|
return False
|
||||||
|
finally:
|
||||||
|
if inst:
|
||||||
|
inst._port.close()
|
||||||
|
|
||||||
@_uses_esptool
|
@_uses_esptool
|
||||||
def _try_flash(self, esp, erase_nvs, baud_rate):
|
def _try_flash(self, esp, erase_nvs, baud_rate):
|
||||||
|
@ -389,3 +404,21 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
if not self.allow_dut_exception and self.get_exceptions():
|
if not self.allow_dut_exception and self.get_exceptions():
|
||||||
Utility.console_log("DUT exception detected on {}".format(self), color="red")
|
Utility.console_log("DUT exception detected on {}".format(self), color="red")
|
||||||
raise IDFDUTException()
|
raise IDFDUTException()
|
||||||
|
|
||||||
|
|
||||||
|
class ESP32DUT(IDFDUT):
|
||||||
|
@classmethod
|
||||||
|
def _get_rom(cls):
|
||||||
|
return esptool.ESP32ROM
|
||||||
|
|
||||||
|
|
||||||
|
class ESP32S2DUT(IDFDUT):
|
||||||
|
@classmethod
|
||||||
|
def _get_rom(cls):
|
||||||
|
return esptool.ESP32S2ROM
|
||||||
|
|
||||||
|
|
||||||
|
class ESP8266DUT(IDFDUT):
|
||||||
|
@classmethod
|
||||||
|
def _get_rom(cls):
|
||||||
|
return esptool.ESP8266ROM
|
||||||
|
|
Loading…
Reference in a new issue