Skip to content

Commit

Permalink
espidf: add wait_for_user config for non-interactive runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp v. K committed Mar 11, 2022
1 parent 11ab49e commit d337854
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions mlonmcu/platform/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EspIdfPlatform(CompilePlatform, TargetPlatform):
"project_template": None,
"project_dir": None,
"port": None,
"baud": None,
"wait_for_user": True,
}

REQUIRED = ["espidf.install_dir", "espidf.src_dir"]
Expand All @@ -90,6 +90,15 @@ def espidf_src_dir(self):
def idf_exe(self):
return self.espidf_src_dir / "tools" / "idf.py"

@property
def wait_for_user(self):
# TODO: get rid of this
return (
bool(self.config["wait_for_user"])
if isinstance(self.config["wait_for_user"], (int, bool))
else bool(distutils.util.strtobool(self.config["wait_for_user"]))
)

def invoke_idf_exe(self, *args, **kwargs):
env = {} # Do not use current virtualenv (TODO: is there a better way?)
env["IDF_PATH"] = str(self.espidf_src_dir)
Expand Down Expand Up @@ -276,11 +285,12 @@ def get_idf_serial_args(self):
def flash(self, target, timeout=120):
# TODO: implement timeout
# TODO: make sure that already compiled? -> error or just call compile routine?
answer = input(
f"Make sure that the device '{target.name}' is connected before you press [Enter] (Type 'Abort' to cancel)"
)
if answer.lower() == "abort":
return ""
if self.wait_for_user: # INTERACTIVE
answer = input(
f"Make sure that the device '{target.name}' is connected before you press [Enter] (Type 'Abort' to cancel)"
)
if answer.lower() == "abort":
return ""
logger.debug("Flashing target software")

idfArgs = [
Expand All @@ -293,6 +303,7 @@ def flash(self, target, timeout=120):
self.invoke_idf_exe(*idfArgs, live=self.print_outputs)

def monitor(self, target, timeout=60):

def _kill_monitor():

for proc in psutil.process_iter():
Expand Down

0 comments on commit d337854

Please sign in to comment.