src/eric7/MicroPython/PyBoardDevices.py

branch
eric7
changeset 9751
606ac0e26533
parent 9749
5d409223cf3f
child 9752
2b9546c0cbd9
--- a/src/eric7/MicroPython/PyBoardDevices.py	Thu Feb 09 09:55:57 2023 +0100
+++ b/src/eric7/MicroPython/PyBoardDevices.py	Sat Feb 11 16:59:50 2023 +0100
@@ -414,36 +414,28 @@
         available firmware version.
         """
         if self.microPython.isConnected():
-            interface = self.microPython.commandsInterface()
-            if interface is not None:
-                impInfo = interface.getImplementation()
-                if impInfo["name"] != "micropython":
-                    EricMessageBox.critical(
-                        None,
-                        self.tr("Show MicroPython Versions"),
-                        self.tr(
-                            """The firmware of the connected device cannot be"""
-                            """ determined or the board does not run MicroPython."""
-                            """ Aborting..."""
-                        ),
-                    )
-                else:
-                    ui = ericApp().getObject("UserInterface")
-                    request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"]))
-                    reply = ui.networkAccessManager().head(request)
-                    reply.finished.connect(
-                        lambda: self.__firmwareVersionResponse(reply, impInfo)
-                    )
+            if self._deviceData["mpy_name"] != "micropython":
+                EricMessageBox.critical(
+                    None,
+                    self.tr("Show MicroPython Versions"),
+                    self.tr(
+                        """The firmware of the connected device cannot be"""
+                        """ determined or the board does not run MicroPython."""
+                        """ Aborting..."""
+                    ),
+                )
+            else:
+                ui = ericApp().getObject("UserInterface")
+                request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"]))
+                reply = ui.networkAccessManager().head(request)
+                reply.finished.connect(lambda: self.__firmwareVersionResponse(reply))
 
-    def __firmwareVersionResponse(self, reply, implementation):
+    def __firmwareVersionResponse(self, reply):
         """
         Private method handling the response of the latest version request.
 
         @param reply reference to the reply object
         @type QNetworkReply
-        @param implementation dictionary containing the implementation data of the
-            connected device
-        @type dict
         """
         latestUrl = reply.url().toString()
         tag = latestUrl.rsplit("/", 1)[-1]
@@ -452,11 +444,11 @@
             tag = tag[1:]
         latestVersion = Globals.versionToTuple(tag)
 
-        if implementation["version"] == "unknown":
+        if self._deviceData["mpy_version"] == "unknown":
             currentVersionStr = self.tr("unknown")
             currentVersion = (0, 0, 0)
         else:
-            currentVersionStr = implementation["version"]
+            currentVersionStr = self._deviceData["mpy_version"]
             currentVersion = Globals.versionToTuple(currentVersionStr)
 
         msg = self.tr(
@@ -491,7 +483,7 @@
             self.microPython.on_connectButton_clicked()
 
 
-def createDevice(microPythonWidget, deviceType, vid, pid, boardName):
+def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
     """
     Function to instantiate a MicroPython device object.
 
@@ -505,6 +497,8 @@
     @type int
     @param boardName name of the board
     @type str
+    @param serialNumber serial number of the board
+    @type str
     @return reference to the instantiated device object
     @rtype PyBoardDevice
     """

eric ide

mercurial