173 """ |
173 """ |
174 Private slot to show the firmware version of the connected device and the |
174 Private slot to show the firmware version of the connected device and the |
175 available firmware version. |
175 available firmware version. |
176 """ |
176 """ |
177 if self.microPython.isConnected(): |
177 if self.microPython.isConnected(): |
178 interface = self.microPython.commandsInterface() |
178 if self._deviceData["mpy_name"] != "micropython": |
179 if interface is not None: |
179 EricMessageBox.critical( |
180 impInfo = interface.getImplementation() |
180 None, |
181 if impInfo["name"] != "micropython": |
181 self.tr("Show MicroPython Versions"), |
182 EricMessageBox.critical( |
182 self.tr( |
183 None, |
183 """The firmware of the connected device cannot be""" |
184 self.tr("Show MicroPython Versions"), |
184 """ determined or the board does not run MicroPython.""" |
185 self.tr( |
185 """ Aborting...""" |
186 """The firmware of the connected device cannot be""" |
186 ), |
187 """ determined or the board does not run MicroPython.""" |
187 ) |
188 """ Aborting...""" |
188 else: |
189 ), |
189 if self._deviceData["mpy_variant"] == "Pimoroni": |
190 ) |
190 # MicroPython with Pimoroni add-on libraries |
|
191 url = QUrl(FirmwareGithubUrls["pimoroni_pico"]) |
191 else: |
192 else: |
192 if impInfo["variant"] == "Pimoroni": |
193 url = QUrl(FirmwareGithubUrls["micropython"]) |
193 # MicroPython with Pimoroni add-on libraries |
194 ui = ericApp().getObject("UserInterface") |
194 url = QUrl(FirmwareGithubUrls["pimoroni_pico"]) |
195 request = QNetworkRequest(url) |
195 else: |
196 reply = ui.networkAccessManager().head(request) |
196 url = QUrl(FirmwareGithubUrls["micropython"]) |
197 reply.finished.connect(lambda: self.__firmwareVersionResponse(reply)) |
197 ui = ericApp().getObject("UserInterface") |
198 |
198 request = QNetworkRequest(url) |
199 def __firmwareVersionResponse(self, reply): |
199 reply = ui.networkAccessManager().head(request) |
|
200 reply.finished.connect( |
|
201 lambda: self.__firmwareVersionResponse(reply, impInfo) |
|
202 ) |
|
203 |
|
204 def __firmwareVersionResponse(self, reply, implementation): |
|
205 """ |
200 """ |
206 Private method handling the response of the latest version request. |
201 Private method handling the response of the latest version request. |
207 |
202 |
208 @param reply reference to the reply object |
203 @param reply reference to the reply object |
209 @type QNetworkReply |
204 @type QNetworkReply |
210 @param implementation dictionary containing the implementation data of the |
|
211 connected device |
|
212 @type dict |
|
213 """ |
205 """ |
214 latestUrl = reply.url().toString() |
206 latestUrl = reply.url().toString() |
215 tag = latestUrl.rsplit("/", 1)[-1] |
207 tag = latestUrl.rsplit("/", 1)[-1] |
216 while tag and not tag[0].isdecimal(): |
208 while tag and not tag[0].isdecimal(): |
217 # get rid of leading non-decimal characters |
209 # get rid of leading non-decimal characters |
218 tag = tag[1:] |
210 tag = tag[1:] |
219 latestVersion = Globals.versionToTuple(tag) |
211 latestVersion = Globals.versionToTuple(tag) |
220 |
212 |
221 if implementation["version"] == "unknown": |
213 if self._deviceData["mpy_version"] == "unknown": |
222 currentVersionStr = self.tr("unknown") |
214 currentVersionStr = self.tr("unknown") |
223 currentVersion = (0, 0, 0) |
215 currentVersion = (0, 0, 0) |
224 else: |
216 else: |
225 currentVersionStr = implementation["version"] |
217 currentVersionStr = self._deviceData["mpy_version"] |
226 currentVersion = Globals.versionToTuple(currentVersionStr) |
218 currentVersion = Globals.versionToTuple(currentVersionStr) |
227 |
219 |
228 msg = self.tr( |
220 msg = self.tr( |
229 "<h4>MicroPython Version Information</h4>" |
221 "<h4>MicroPython Version Information</h4>" |
230 "<table>" |
222 "<table>" |
285 Preferences.getMicroPython("CircuitPythonLibrariesUrl"), |
277 Preferences.getMicroPython("CircuitPythonLibrariesUrl"), |
286 ), |
278 ), |
287 ] |
279 ] |
288 |
280 |
289 |
281 |
290 def createDevice(microPythonWidget, deviceType, vid, pid, boardName): |
282 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber): |
291 """ |
283 """ |
292 Function to instantiate a MicroPython device object. |
284 Function to instantiate a MicroPython device object. |
293 |
285 |
294 @param microPythonWidget reference to the main MicroPython widget |
286 @param microPythonWidget reference to the main MicroPython widget |
295 @type MicroPythonWidget |
287 @type MicroPythonWidget |