EspDevices: fixed an issue resetting the attached device when not connected.

Sun, 08 Dec 2019 12:38:34 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 08 Dec 2019 12:38:34 +0100
changeset 7353
caa2ccd5677c
parent 7352
5f69f55b919f
child 7354
d6aec4160f6b

EspDevices: fixed an issue resetting the attached device when not connected.

eric6/MicroPython/EspDevices.py file | annotate | diff | comparison | revisions
--- 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