فهرست منبع

idf_monitor: support to re-flash with the using port

This commit make idf_monitor overwrite the ESPPORT environment variable
with the port it's using, and re-run make with the modified environment
variable. In this way, the make invoked will inherit the idf_monitor's
port.

Closes https://github.com/espressif/esp-idf/issues/4591
michael 5 سال پیش
والد
کامیت
8aafb6b513
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      tools/idf_monitor.py

+ 8 - 1
tools/idf_monitor.py

@@ -649,7 +649,7 @@ class Monitor(object):
             else:
                 popen_args = [self.make, target]
             yellow_print("Running %s..." % " ".join(popen_args))
-            p = subprocess.Popen(popen_args)
+            p = subprocess.Popen(popen_args, env=os.environ)
             try:
                 p.wait()
             except KeyboardInterrupt:
@@ -967,6 +967,13 @@ def main():
     except KeyError:
         pass  # not running a make jobserver
 
+    # Pass the actual used port to callee of idf_monitor (e.g. make) through `ESPPORT` environment
+    # variable
+    # To make sure the key as well as the value are str type, by the requirements of subprocess
+    espport_key = str("ESPPORT")
+    espport_val = str(args.port)
+    os.environ.update({espport_key: espport_val})
+
     monitor = Monitor(serial_instance, args.elf_file.name, args.print_filter, args.make, args.encrypted,
                       args.toolchain_prefix, args.eol,
                       args.decode_coredumps)