Corrected the device interface for STLiink devices. eric7

Fri, 21 Mar 2025 18:11:36 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 21 Mar 2025 18:11:36 +0100
branch
eric7
changeset 11184
33a600dd86f4
parent 11183
553b50b72f5b
child 11185
a6f70425f5be

Corrected the device interface for STLiink devices.

src/eric7/MicroPython/Devices/STLinkDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/MicroPythonWidget.py file | annotate | diff | comparison | revisions
--- a/src/eric7/MicroPython/Devices/STLinkDevices.py	Fri Mar 21 18:01:35 2025 +0100
+++ b/src/eric7/MicroPython/Devices/STLinkDevices.py	Fri Mar 21 18:11:36 2025 +0100
@@ -46,8 +46,6 @@
 
         self._submitMode = "paste"  # use 'paste' mode
 
-        self.__workspace = self.__findWorkspace()
-
         self.__createSTLinkMenu()
 
     def setButtons(self):
@@ -129,80 +127,6 @@
         """
         return True, ""
 
-    def supportsLocalFileAccess(self):
-        """
-        Public method to indicate file access via a local directory.
-
-        @return flag indicating file access via local directory
-        @rtype bool
-        """
-        return self.__deviceVolumeMounted()
-
-    def __deviceVolumeMounted(self):
-        """
-        Private method to check, if the device volume is mounted.
-
-        @return flag indicated a mounted device
-        @rtype bool
-        """
-        if self.__workspace and not os.path.exists(self.__workspace):
-            self.__workspace = ""  # reset
-
-        return self.DeviceVolumeName in self.getWorkspace(silent=True)
-
-    def getWorkspace(self, silent=False):
-        """
-        Public method to get the workspace directory.
-
-        @param silent flag indicating silent operations
-        @type bool
-        @return workspace directory used for saving files
-        @rtype str
-        """
-        if self.__workspace:
-            # return cached entry
-            return self.__workspace
-        else:
-            self.__workspace = self.__findWorkspace(silent=silent)
-            return self.__workspace
-
-    def __findWorkspace(self, silent=False):
-        """
-        Private method to find the workspace directory.
-
-        @param silent flag indicating silent operations
-        @type bool
-        @return workspace directory used for saving files
-        @rtype str
-        """
-        # Attempts to find the path on the filesystem that represents the
-        # plugged in PyBoard board.
-        deviceDirectories = FileSystemUtilities.findVolume(
-            self.DeviceVolumeName, findAll=True
-        )
-
-        if deviceDirectories:
-            if len(deviceDirectories) == 1:
-                return deviceDirectories[0]
-            else:
-                return self.selectDeviceDirectory(deviceDirectories)
-        else:
-            # return the default workspace and give the user a warning (unless
-            # silent mode is selected)
-            if not silent:
-                EricMessageBox.warning(
-                    self.microPython,
-                    self.tr("Workspace Directory"),
-                    self.tr(
-                        "Python files for STLink boards can be edited in"
-                        " place, if the device volume is locally"
-                        " available. Such a volume was not found. In"
-                        " place editing will not be available."
-                    ),
-                )
-
-            return super().getWorkspace()
-
     def getDocumentationUrl(self):
         """
         Public method to get the device documentation URL.
@@ -477,9 +401,11 @@
         Private slot to reset the connected device.
         """
         if self.microPython.isConnected():
-            self.executeCommands(
+            out, err = self.executeCommands(
                 "import machine\nmachine.reset()\n", mode=self._submitMode
             )
+        if not err:
+            self.microPython.insertData(out + b"\r\n")
 
 
 def createDevice(microPythonWidget, deviceType, _vid, _pid, _boardName, _serialNumber):
--- a/src/eric7/MicroPython/MicroPythonWidget.py	Fri Mar 21 18:01:35 2025 +0100
+++ b/src/eric7/MicroPython/MicroPythonWidget.py	Fri Mar 21 18:11:36 2025 +0100
@@ -979,6 +979,17 @@
             with EricOverrideCursor():
                 self.__disconnectFromDevice()
 
+    def insertData(self, data):
+        """
+        Public method to insert some data as if it was sent directly from the device.
+
+        @param data data to be inserted into the REPL pane
+        @type str or bytes
+        """
+        if isinstance(data, str):
+            data = data.encode("utf-8")
+        self.replWidget.replEdit().processData(data)
+
     ##################################################################
     ## Super Menu related methods below
     ##################################################################

eric ide

mercurial