src/eric7/MicroPython/Devices/CircuitPythonDevices.py

branch
eric7
changeset 11055
e68bcb2b5ec1
parent 11006
a671918232f3
child 11090
f5f5f5803935
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Nov 26 17:07:48 2024 +0100
+++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Nov 26 19:46:36 2024 +0100
@@ -756,7 +756,7 @@
         import wifi
         if hasattr(wifi, 'radio'):
             return True, 'circuitpython'
-    except ImportError:
+    except (ImportError, MemoryError):
         pass
 
     return False, ''
@@ -764,10 +764,13 @@
 print(has_wifi())
 del has_wifi
 """
-        out, err = self.executeCommands(command, mode=self._submitMode)
-        if err:
-            raise OSError(self._shortError(err))
-        return ast.literal_eval(out.decode("utf-8"))
+        try:
+            return self._deviceData["wifi"], self._deviceData["wifi_type"]
+        except KeyError:
+            out, err = self.executeCommands(command, mode=self._submitMode)
+            if err:
+                raise OSError(self._shortError(err))
+            return ast.literal_eval(out.decode("utf-8"))
 
     def getWifiData(self):
         """
@@ -1352,12 +1355,16 @@
 print(has_eth())
 del has_eth
 """
+        try:
+            return self._deviceData["ethernet"], self._deviceData["ethernet_type"]
+        except KeyError:
+            out, err = self.executeCommands(
+                command, mode=self._submitMode, timeout=10000
+            )
+            if err:
+                raise OSError(self._shortError(err))
 
-        out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000)
-        if err:
-            raise OSError(self._shortError(err))
-
-        return ast.literal_eval(out.decode("utf-8"))
+            return ast.literal_eval(out.decode("utf-8"))
 
     def getEthernetStatus(self):
         """
@@ -1707,10 +1714,15 @@
 print(has_bt())
 del has_bt
 """
-        out, err = self.executeCommands(command, mode=self._submitMode, timeout=10000)
-        if err:
-            raise OSError(self._shortError(err))
-        return out.strip() == b"True"
+        try:
+            return self._deviceData["bluetooth"]
+        except KeyError:
+            out, err = self.executeCommands(
+                command, mode=self._submitMode, timeout=10000
+            )
+            if err:
+                raise OSError(self._shortError(err))
+            return out.strip() == b"True"
 
     def getBluetoothStatus(self):
         """

eric ide

mercurial