src/eric7/MicroPython/Devices/MicrobitDevices.py

branch
mpy_network
changeset 9989
286c2a21f36f
parent 9979
dbafba79461d
child 10032
102b79b2a8cd
--- a/src/eric7/MicroPython/Devices/MicrobitDevices.py	Mon Apr 24 17:51:11 2023 +0200
+++ b/src/eric7/MicroPython/Devices/MicrobitDevices.py	Thu Apr 27 17:59:09 2023 +0200
@@ -526,16 +526,18 @@
         """
         Private slot to reset the connected device.
         """
-        if self.getDeviceType() == "bbc_microbit":
-            # BBC micro:bit
-            self.microPython.deviceInterface().execute(
-                "import microbit\nmicrobit.reset()\n", mode=self._submitMode
-            )
-        else:
-            # Calliope mini
-            self.microPython.deviceInterface().execute(
-                "import calliope_mini\ncalliope_mini.reset()\n", mode=self._submitMode
-            )
+        if self.microPython.isConnected():
+            if self.getDeviceType() == "bbc_microbit":
+                # BBC micro:bit
+                self.executeCommands(
+                    "import microbit\nmicrobit.reset()\n", mode=self._submitMode
+                )
+            else:
+                # Calliope mini
+                self.executeCommands(
+                    "import calliope_mini\ncalliope_mini.reset()\n",
+                    mode=self._submitMode,
+                )
 
     def getDocumentationUrl(self):
         """
@@ -626,7 +628,7 @@
 print(__os_.listdir())
 del __os_
 """
-            out, err = self._interface.execute(command, mode=self._submitMode)
+            out, err = self.executeCommands(command, mode=self._submitMode)
             if err:
                 raise OSError(self._shortError(err))
             return ast.literal_eval(out.decode("utf-8"))
@@ -674,7 +676,7 @@
 """.format(
                 showHidden
             )
-            out, err = self._interface.execute(command, mode=self._submitMode)
+            out, err = self.executeCommands(command, mode=self._submitMode)
             if err:
                 raise OSError(self._shortError(err))
             fileslist = ast.literal_eval(out.decode("utf-8"))
@@ -765,9 +767,7 @@
 print(has_bt())
 del has_bt
 """
-        out, err = self._interface.execute(
-            command, mode=self._submitMode, timeout=10000
-        )
+        out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000)
         if err:
             raise OSError(self._shortError(err))
         return out.strip() == b"True"
@@ -811,7 +811,7 @@
 ble_status()
 del ble_status
 """
-        out, err = self._interface.execute(command, mode=self._submitMode)
+        out, err = self.executeCommands(command, mode=self._submitMode)
         if err:
             raise OSError(self._shortError(err))
 
@@ -848,7 +848,7 @@
 activate_ble()
 del activate_ble
 """
-        out, err = self._interface.execute(command, mode=self._submitMode)
+        out, err = self.executeCommands(command, mode=self._submitMode)
         if err:
             raise OSError(self._shortError(err))
 
@@ -874,7 +874,7 @@
 deactivate_ble()
 del deactivate_ble
 """
-        out, err = self._interface.execute(command, mode=self._submitMode)
+        out, err = self.executeCommands(command, mode=self._submitMode)
         if err:
             raise OSError(self._shortError(err))
 
@@ -935,7 +935,7 @@
 """.format(
             timeout
         )
-        out, err = self._interface.execute(
+        out, err = self.executeCommands(
             command, mode=self._submitMode, timeout=(timeout + 5) * 1000
         )
         if err:

eric ide

mercurial