eric6/MicroPython/EspDevices.py

changeset 7353
caa2ccd5677c
parent 7352
5f69f55b919f
child 7355
c7146f7e06aa
--- a/eric6/MicroPython/EspDevices.py	Sat Dec 07 17:47:24 2019 +0100
+++ b/eric6/MicroPython/EspDevices.py	Sun Dec 08 12:38:34 2019 +0100
@@ -11,7 +11,7 @@
 
 import sys
 
-from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtCore import pyqtSlot, QProcess
 from PyQt5.QtWidgets import QDialog
 
 from E5Gui import E5MessageBox
@@ -352,10 +352,25 @@
         """
         Private slot to reset the connected device.
         """
-        self.microPython.commandsInterface().execute([
-            "import machine",
-            "machine.reset()",
-        ])
+        if self.microPython.isConnected():
+            self.microPython.commandsInterface().execute([
+                "import machine",
+                "machine.reset()",
+            ])
+        else:
+            # perform a reset via esptool using flash_id command ignoring
+            # the output
+            args = [
+                "-u",
+                "-m", "esptool",
+                "--port", self.microPython.getCurrentPort(),
+                "flash_id"
+            ]
+            proc = QProcess()
+            proc.start(sys.executable, args)
+            procStarted = proc.waitForStarted(10000)
+            if procStarted:
+                proc.waitForFinished(10000)
     
     @pyqtSlot()
     def __installEspTool(self):

eric ide

mercurial