24 |
24 |
25 class EspDevice(MicroPythonDevice): |
25 class EspDevice(MicroPythonDevice): |
26 """ |
26 """ |
27 Class implementing the device for ESP32 and ESP8266 based boards. |
27 Class implementing the device for ESP32 and ESP8266 based boards. |
28 """ |
28 """ |
|
29 |
29 def __init__(self, microPythonWidget, deviceType, parent=None): |
30 def __init__(self, microPythonWidget, deviceType, parent=None): |
30 """ |
31 """ |
31 Constructor |
32 Constructor |
32 |
33 |
33 @param microPythonWidget reference to the main MicroPython widget |
34 @param microPythonWidget reference to the main MicroPython widget |
34 @type MicroPythonWidget |
35 @type MicroPythonWidget |
35 @param deviceType device type assigned to this device interface |
36 @param deviceType device type assigned to this device interface |
36 @type str |
37 @type str |
37 @param parent reference to the parent object |
38 @param parent reference to the parent object |
38 @type QObject |
39 @type QObject |
39 """ |
40 """ |
40 super().__init__(microPythonWidget, deviceType, parent) |
41 super().__init__(microPythonWidget, deviceType, parent) |
41 |
42 |
42 def setButtons(self): |
43 def setButtons(self): |
43 """ |
44 """ |
44 Public method to enable the supported action buttons. |
45 Public method to enable the supported action buttons. |
45 """ |
46 """ |
46 super().setButtons() |
47 super().setButtons() |
47 self.microPython.setActionButtons( |
48 self.microPython.setActionButtons( |
48 run=True, repl=True, files=True, chart=HAS_QTCHART) |
49 run=True, repl=True, files=True, chart=HAS_QTCHART |
49 |
50 ) |
|
51 |
50 def forceInterrupt(self): |
52 def forceInterrupt(self): |
51 """ |
53 """ |
52 Public method to determine the need for an interrupt when opening the |
54 Public method to determine the need for an interrupt when opening the |
53 serial connection. |
55 serial connection. |
54 |
56 |
55 @return flag indicating an interrupt is needed |
57 @return flag indicating an interrupt is needed |
56 @rtype bool |
58 @rtype bool |
57 """ |
59 """ |
58 return True |
60 return True |
59 |
61 |
60 def deviceName(self): |
62 def deviceName(self): |
61 """ |
63 """ |
62 Public method to get the name of the device. |
64 Public method to get the name of the device. |
63 |
65 |
64 @return name of the device |
66 @return name of the device |
65 @rtype str |
67 @rtype str |
66 """ |
68 """ |
67 return self.tr("ESP8266, ESP32") |
69 return self.tr("ESP8266, ESP32") |
68 |
70 |
69 def canStartRepl(self): |
71 def canStartRepl(self): |
70 """ |
72 """ |
71 Public method to determine, if a REPL can be started. |
73 Public method to determine, if a REPL can be started. |
72 |
74 |
73 @return tuple containing a flag indicating it is safe to start a REPL |
75 @return tuple containing a flag indicating it is safe to start a REPL |
74 and a reason why it cannot. |
76 and a reason why it cannot. |
75 @rtype tuple of (bool, str) |
77 @rtype tuple of (bool, str) |
76 """ |
78 """ |
77 return True, "" |
79 return True, "" |
78 |
80 |
79 def canStartPlotter(self): |
81 def canStartPlotter(self): |
80 """ |
82 """ |
81 Public method to determine, if a Plotter can be started. |
83 Public method to determine, if a Plotter can be started. |
82 |
84 |
83 @return tuple containing a flag indicating it is safe to start a |
85 @return tuple containing a flag indicating it is safe to start a |
84 Plotter and a reason why it cannot. |
86 Plotter and a reason why it cannot. |
85 @rtype tuple of (bool, str) |
87 @rtype tuple of (bool, str) |
86 """ |
88 """ |
87 return True, "" |
89 return True, "" |
88 |
90 |
89 def canRunScript(self): |
91 def canRunScript(self): |
90 """ |
92 """ |
91 Public method to determine, if a script can be executed. |
93 Public method to determine, if a script can be executed. |
92 |
94 |
93 @return tuple containing a flag indicating it is safe to start a |
95 @return tuple containing a flag indicating it is safe to start a |
94 Plotter and a reason why it cannot. |
96 Plotter and a reason why it cannot. |
95 @rtype tuple of (bool, str) |
97 @rtype tuple of (bool, str) |
96 """ |
98 """ |
97 return True, "" |
99 return True, "" |
98 |
100 |
99 def runScript(self, script): |
101 def runScript(self, script): |
100 """ |
102 """ |
101 Public method to run the given Python script. |
103 Public method to run the given Python script. |
102 |
104 |
103 @param script script to be executed |
105 @param script script to be executed |
104 @type str |
106 @type str |
105 """ |
107 """ |
106 pythonScript = script.split("\n") |
108 pythonScript = script.split("\n") |
107 self.sendCommands(pythonScript) |
109 self.sendCommands(pythonScript) |
108 |
110 |
109 def canStartFileManager(self): |
111 def canStartFileManager(self): |
110 """ |
112 """ |
111 Public method to determine, if a File Manager can be started. |
113 Public method to determine, if a File Manager can be started. |
112 |
114 |
113 @return tuple containing a flag indicating it is safe to start a |
115 @return tuple containing a flag indicating it is safe to start a |
114 File Manager and a reason why it cannot. |
116 File Manager and a reason why it cannot. |
115 @rtype tuple of (bool, str) |
117 @rtype tuple of (bool, str) |
116 """ |
118 """ |
117 return True, "" |
119 return True, "" |
118 |
120 |
119 def addDeviceMenuEntries(self, menu): |
121 def addDeviceMenuEntries(self, menu): |
120 """ |
122 """ |
121 Public method to add device specific entries to the given menu. |
123 Public method to add device specific entries to the given menu. |
122 |
124 |
123 @param menu reference to the context menu |
125 @param menu reference to the context menu |
124 @type QMenu |
126 @type QMenu |
125 """ |
127 """ |
126 connected = self.microPython.isConnected() |
128 connected = self.microPython.isConnected() |
127 |
129 |
128 act = menu.addAction(self.tr("Erase Flash"), |
130 act = menu.addAction(self.tr("Erase Flash"), self.__eraseFlash) |
129 self.__eraseFlash) |
131 act.setEnabled(not connected) |
130 act.setEnabled(not connected) |
132 act = menu.addAction( |
131 act = menu.addAction(self.tr("Flash MicroPython Firmware"), |
133 self.tr("Flash MicroPython Firmware"), self.__flashMicroPython |
132 self.__flashMicroPython) |
134 ) |
133 act.setEnabled(not connected) |
135 act.setEnabled(not connected) |
134 menu.addSeparator() |
136 menu.addSeparator() |
135 act = menu.addAction(self.tr("Flash Additional Firmware"), |
137 act = menu.addAction(self.tr("Flash Additional Firmware"), self.__flashAddons) |
136 self.__flashAddons) |
|
137 act.setEnabled(not connected) |
138 act.setEnabled(not connected) |
138 menu.addSeparator() |
139 menu.addSeparator() |
139 act = menu.addAction(self.tr("Backup Firmware"), |
140 act = menu.addAction(self.tr("Backup Firmware"), self.__backupFlash) |
140 self.__backupFlash) |
141 act.setEnabled(not connected) |
141 act.setEnabled(not connected) |
142 act = menu.addAction(self.tr("Restore Firmware"), self.__restoreFlash) |
142 act = menu.addAction(self.tr("Restore Firmware"), |
|
143 self.__restoreFlash) |
|
144 act.setEnabled(not connected) |
143 act.setEnabled(not connected) |
145 menu.addSeparator() |
144 menu.addSeparator() |
146 act = menu.addAction(self.tr("Show Chip ID"), |
145 act = menu.addAction(self.tr("Show Chip ID"), self.__showChipID) |
147 self.__showChipID) |
146 act.setEnabled(not connected) |
148 act.setEnabled(not connected) |
147 act = menu.addAction(self.tr("Show Flash ID"), self.__showFlashID) |
149 act = menu.addAction(self.tr("Show Flash ID"), |
148 act.setEnabled(not connected) |
150 self.__showFlashID) |
149 act = menu.addAction(self.tr("Show MAC Address"), self.__showMACAddress) |
151 act.setEnabled(not connected) |
|
152 act = menu.addAction(self.tr("Show MAC Address"), |
|
153 self.__showMACAddress) |
|
154 act.setEnabled(not connected) |
150 act.setEnabled(not connected) |
155 menu.addSeparator() |
151 menu.addSeparator() |
156 act = menu.addAction(self.tr("Reset Device"), self.__resetDevice) |
152 act = menu.addAction(self.tr("Reset Device"), self.__resetDevice) |
157 menu.addSeparator() |
153 menu.addSeparator() |
158 menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool) |
154 menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool) |
159 |
155 |
160 def hasFlashMenuEntry(self): |
156 def hasFlashMenuEntry(self): |
161 """ |
157 """ |
162 Public method to check, if the device has its own flash menu entry. |
158 Public method to check, if the device has its own flash menu entry. |
163 |
159 |
164 @return flag indicating a specific flash menu entry |
160 @return flag indicating a specific flash menu entry |
165 @rtype bool |
161 @rtype bool |
166 """ |
162 """ |
167 return True |
163 return True |
168 |
164 |
169 @pyqtSlot() |
165 @pyqtSlot() |
170 def __eraseFlash(self): |
166 def __eraseFlash(self): |
171 """ |
167 """ |
172 Private slot to erase the device flash memory. |
168 Private slot to erase the device flash memory. |
173 """ |
169 """ |
174 ok = EricMessageBox.yesNo( |
170 ok = EricMessageBox.yesNo( |
175 self.microPython, |
171 self.microPython, |
176 self.tr("Erase Flash"), |
172 self.tr("Erase Flash"), |
177 self.tr("""Shall the flash of the selected device really be""" |
173 self.tr( |
178 """ erased?""")) |
174 """Shall the flash of the selected device really be""" """ erased?""" |
|
175 ), |
|
176 ) |
179 if ok: |
177 if ok: |
180 flashArgs = [ |
178 flashArgs = [ |
181 "-u", |
179 "-u", |
182 "-m", "esptool", |
180 "-m", |
183 "--port", self.microPython.getCurrentPort(), |
181 "esptool", |
|
182 "--port", |
|
183 self.microPython.getCurrentPort(), |
184 "erase_flash", |
184 "erase_flash", |
185 ] |
185 ] |
186 dlg = EricProcessDialog(self.tr("'esptool erase_flash' Output"), |
186 dlg = EricProcessDialog( |
187 self.tr("Erase Flash"), |
187 self.tr("'esptool erase_flash' Output"), |
188 showProgress=True) |
188 self.tr("Erase Flash"), |
|
189 showProgress=True, |
|
190 ) |
189 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
191 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
190 if res: |
192 if res: |
191 dlg.exec() |
193 dlg.exec() |
192 |
194 |
193 @pyqtSlot() |
195 @pyqtSlot() |
194 def __flashMicroPython(self): |
196 def __flashMicroPython(self): |
195 """ |
197 """ |
196 Private slot to flash a MicroPython firmware to the device. |
198 Private slot to flash a MicroPython firmware to the device. |
197 """ |
199 """ |
198 from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
200 from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
|
201 |
199 dlg = EspFirmwareSelectionDialog() |
202 dlg = EspFirmwareSelectionDialog() |
200 if dlg.exec() == QDialog.DialogCode.Accepted: |
203 if dlg.exec() == QDialog.DialogCode.Accepted: |
201 chip, firmware, baudRate, flashMode, flashAddress = dlg.getData() |
204 chip, firmware, baudRate, flashMode, flashAddress = dlg.getData() |
202 flashArgs = [ |
205 flashArgs = [ |
203 "-u", |
206 "-u", |
204 "-m", "esptool", |
207 "-m", |
205 "--chip", chip, |
208 "esptool", |
206 "--port", self.microPython.getCurrentPort(), |
209 "--chip", |
|
210 chip, |
|
211 "--port", |
|
212 self.microPython.getCurrentPort(), |
207 ] |
213 ] |
208 if baudRate != "115200": |
214 if baudRate != "115200": |
209 flashArgs += [ |
215 flashArgs += ["--baud", baudRate] |
210 "--baud", baudRate |
|
211 ] |
|
212 flashArgs.append("write_flash") |
216 flashArgs.append("write_flash") |
213 if flashMode: |
217 if flashMode: |
214 flashArgs += [ |
218 flashArgs += ["--flash_mode", flashMode] |
215 "--flash_mode", flashMode |
|
216 ] |
|
217 flashArgs += [ |
219 flashArgs += [ |
218 flashAddress, |
220 flashAddress, |
219 firmware, |
221 firmware, |
220 ] |
222 ] |
221 dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"), |
223 dlg = EricProcessDialog( |
222 self.tr("Flash MicroPython Firmware"), |
224 self.tr("'esptool write_flash' Output"), |
223 showProgress=True) |
225 self.tr("Flash MicroPython Firmware"), |
|
226 showProgress=True, |
|
227 ) |
224 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
228 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
225 if res: |
229 if res: |
226 dlg.exec() |
230 dlg.exec() |
227 |
231 |
228 @pyqtSlot() |
232 @pyqtSlot() |
229 def __flashAddons(self): |
233 def __flashAddons(self): |
230 """ |
234 """ |
231 Private slot to flash some additional firmware images. |
235 Private slot to flash some additional firmware images. |
232 """ |
236 """ |
233 from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
237 from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
|
238 |
234 dlg = EspFirmwareSelectionDialog(addon=True) |
239 dlg = EspFirmwareSelectionDialog(addon=True) |
235 if dlg.exec() == QDialog.DialogCode.Accepted: |
240 if dlg.exec() == QDialog.DialogCode.Accepted: |
236 chip, firmware, baudRate, flashMode, flashAddress = dlg.getData() |
241 chip, firmware, baudRate, flashMode, flashAddress = dlg.getData() |
237 flashArgs = [ |
242 flashArgs = [ |
238 "-u", |
243 "-u", |
239 "-m", "esptool", |
244 "-m", |
240 "--chip", chip, |
245 "esptool", |
241 "--port", self.microPython.getCurrentPort(), |
246 "--chip", |
|
247 chip, |
|
248 "--port", |
|
249 self.microPython.getCurrentPort(), |
242 ] |
250 ] |
243 if baudRate != "115200": |
251 if baudRate != "115200": |
244 flashArgs += [ |
252 flashArgs += ["--baud", baudRate] |
245 "--baud", baudRate |
|
246 ] |
|
247 flashArgs.append("write_flash") |
253 flashArgs.append("write_flash") |
248 if flashMode: |
254 if flashMode: |
249 flashArgs += [ |
255 flashArgs += ["--flash_mode", flashMode] |
250 "--flash_mode", flashMode |
|
251 ] |
|
252 flashArgs += [ |
256 flashArgs += [ |
253 flashAddress.lower(), |
257 flashAddress.lower(), |
254 firmware, |
258 firmware, |
255 ] |
259 ] |
256 dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"), |
260 dlg = EricProcessDialog( |
257 self.tr("Flash Additional Firmware"), |
261 self.tr("'esptool write_flash' Output"), |
258 showProgress=True) |
262 self.tr("Flash Additional Firmware"), |
|
263 showProgress=True, |
|
264 ) |
259 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
265 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
260 if res: |
266 if res: |
261 dlg.exec() |
267 dlg.exec() |
262 |
268 |
263 @pyqtSlot() |
269 @pyqtSlot() |
264 def __backupFlash(self): |
270 def __backupFlash(self): |
265 """ |
271 """ |
266 Private slot to backup the currently flashed firmware. |
272 Private slot to backup the currently flashed firmware. |
267 """ |
273 """ |
268 from .EspBackupRestoreFirmwareDialog import ( |
274 from .EspBackupRestoreFirmwareDialog import EspBackupRestoreFirmwareDialog |
269 EspBackupRestoreFirmwareDialog |
275 |
270 ) |
|
271 dlg = EspBackupRestoreFirmwareDialog(backupMode=True) |
276 dlg = EspBackupRestoreFirmwareDialog(backupMode=True) |
272 if dlg.exec() == QDialog.DialogCode.Accepted: |
277 if dlg.exec() == QDialog.DialogCode.Accepted: |
273 chip, flashSize, baudRate, flashMode, firmware = dlg.getData() |
278 chip, flashSize, baudRate, flashMode, firmware = dlg.getData() |
274 flashArgs = [ |
279 flashArgs = [ |
275 "-u", |
280 "-u", |
276 "-m", "esptool", |
281 "-m", |
277 "--chip", chip, |
282 "esptool", |
278 "--port", self.microPython.getCurrentPort(), |
283 "--chip", |
279 "--baud", baudRate, |
284 chip, |
|
285 "--port", |
|
286 self.microPython.getCurrentPort(), |
|
287 "--baud", |
|
288 baudRate, |
280 "read_flash", |
289 "read_flash", |
281 "0x0", flashSize, |
290 "0x0", |
|
291 flashSize, |
282 firmware, |
292 firmware, |
283 ] |
293 ] |
284 dlg = EricProcessDialog(self.tr("'esptool read_flash' Output"), |
294 dlg = EricProcessDialog( |
285 self.tr("Backup Firmware"), |
295 self.tr("'esptool read_flash' Output"), |
286 showProgress=True) |
296 self.tr("Backup Firmware"), |
|
297 showProgress=True, |
|
298 ) |
287 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
299 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
288 if res: |
300 if res: |
289 dlg.exec() |
301 dlg.exec() |
290 |
302 |
291 @pyqtSlot() |
303 @pyqtSlot() |
292 def __restoreFlash(self): |
304 def __restoreFlash(self): |
293 """ |
305 """ |
294 Private slot to restore a previously saved firmware. |
306 Private slot to restore a previously saved firmware. |
295 """ |
307 """ |
296 from .EspBackupRestoreFirmwareDialog import ( |
308 from .EspBackupRestoreFirmwareDialog import EspBackupRestoreFirmwareDialog |
297 EspBackupRestoreFirmwareDialog |
309 |
298 ) |
|
299 dlg = EspBackupRestoreFirmwareDialog(backupMode=False) |
310 dlg = EspBackupRestoreFirmwareDialog(backupMode=False) |
300 if dlg.exec() == QDialog.DialogCode.Accepted: |
311 if dlg.exec() == QDialog.DialogCode.Accepted: |
301 chip, flashSize, baudRate, flashMode, firmware = dlg.getData() |
312 chip, flashSize, baudRate, flashMode, firmware = dlg.getData() |
302 flashArgs = [ |
313 flashArgs = [ |
303 "-u", |
314 "-u", |
304 "-m", "esptool", |
315 "-m", |
305 "--chip", chip, |
316 "esptool", |
306 "--port", self.microPython.getCurrentPort(), |
317 "--chip", |
307 "--baud", baudRate, |
318 chip, |
|
319 "--port", |
|
320 self.microPython.getCurrentPort(), |
|
321 "--baud", |
|
322 baudRate, |
308 "write_flash", |
323 "write_flash", |
309 ] |
324 ] |
310 if flashMode: |
325 if flashMode: |
311 flashArgs.extend([ |
326 flashArgs.extend( |
312 "--flash_mode", flashMode, |
327 [ |
313 ]) |
328 "--flash_mode", |
|
329 flashMode, |
|
330 ] |
|
331 ) |
314 if bool(flashSize): |
332 if bool(flashSize): |
315 flashArgs.extend([ |
333 flashArgs.extend( |
316 "--flash_size", flashSize, |
334 [ |
317 ]) |
335 "--flash_size", |
318 flashArgs.extend([ |
336 flashSize, |
319 "0x0", |
337 ] |
320 firmware, |
338 ) |
321 ]) |
339 flashArgs.extend( |
322 dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"), |
340 [ |
323 self.tr("Restore Firmware"), |
341 "0x0", |
324 showProgress=True) |
342 firmware, |
|
343 ] |
|
344 ) |
|
345 dlg = EricProcessDialog( |
|
346 self.tr("'esptool write_flash' Output"), |
|
347 self.tr("Restore Firmware"), |
|
348 showProgress=True, |
|
349 ) |
325 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
350 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
326 if res: |
351 if res: |
327 dlg.exec() |
352 dlg.exec() |
328 |
353 |
329 @pyqtSlot() |
354 @pyqtSlot() |
330 def __showChipID(self): |
355 def __showChipID(self): |
331 """ |
356 """ |
332 Private slot to show the ID of the ESP chip. |
357 Private slot to show the ID of the ESP chip. |
333 """ |
358 """ |
334 args = [ |
359 args = [ |
335 "-u", |
360 "-u", |
336 "-m", "esptool", |
361 "-m", |
337 "--port", self.microPython.getCurrentPort(), |
362 "esptool", |
338 "chip_id" |
363 "--port", |
|
364 self.microPython.getCurrentPort(), |
|
365 "chip_id", |
339 ] |
366 ] |
340 dlg = EricProcessDialog(self.tr("'esptool chip_id' Output"), |
367 dlg = EricProcessDialog( |
341 self.tr("Show Chip ID")) |
368 self.tr("'esptool chip_id' Output"), self.tr("Show Chip ID") |
|
369 ) |
342 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
370 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
343 if res: |
371 if res: |
344 dlg.exec() |
372 dlg.exec() |
345 |
373 |
346 @pyqtSlot() |
374 @pyqtSlot() |
347 def __showFlashID(self): |
375 def __showFlashID(self): |
348 """ |
376 """ |
349 Private slot to show the ID of the ESP flash chip. |
377 Private slot to show the ID of the ESP flash chip. |
350 """ |
378 """ |
351 args = [ |
379 args = [ |
352 "-u", |
380 "-u", |
353 "-m", "esptool", |
381 "-m", |
354 "--port", self.microPython.getCurrentPort(), |
382 "esptool", |
355 "flash_id" |
383 "--port", |
|
384 self.microPython.getCurrentPort(), |
|
385 "flash_id", |
356 ] |
386 ] |
357 dlg = EricProcessDialog(self.tr("'esptool flash_id' Output"), |
387 dlg = EricProcessDialog( |
358 self.tr("Show Flash ID")) |
388 self.tr("'esptool flash_id' Output"), self.tr("Show Flash ID") |
|
389 ) |
359 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
390 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
360 if res: |
391 if res: |
361 dlg.exec() |
392 dlg.exec() |
362 |
393 |
363 @pyqtSlot() |
394 @pyqtSlot() |
364 def __showMACAddress(self): |
395 def __showMACAddress(self): |
365 """ |
396 """ |
366 Private slot to show the MAC address of the ESP chip. |
397 Private slot to show the MAC address of the ESP chip. |
367 """ |
398 """ |
368 args = [ |
399 args = [ |
369 "-u", |
400 "-u", |
370 "-m", "esptool", |
401 "-m", |
371 "--port", self.microPython.getCurrentPort(), |
402 "esptool", |
372 "read_mac" |
403 "--port", |
|
404 self.microPython.getCurrentPort(), |
|
405 "read_mac", |
373 ] |
406 ] |
374 dlg = EricProcessDialog(self.tr("'esptool read_mac' Output"), |
407 dlg = EricProcessDialog( |
375 self.tr("Show MAC Address")) |
408 self.tr("'esptool read_mac' Output"), self.tr("Show MAC Address") |
|
409 ) |
376 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
410 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
377 if res: |
411 if res: |
378 dlg.exec() |
412 dlg.exec() |
379 |
413 |
380 @pyqtSlot() |
414 @pyqtSlot() |
381 def __resetDevice(self): |
415 def __resetDevice(self): |
382 """ |
416 """ |
383 Private slot to reset the connected device. |
417 Private slot to reset the connected device. |
384 """ |
418 """ |
385 if self.microPython.isConnected(): |
419 if self.microPython.isConnected(): |
386 self.microPython.commandsInterface().execute([ |
420 self.microPython.commandsInterface().execute( |
387 "import machine", |
421 [ |
388 "machine.reset()", |
422 "import machine", |
389 ]) |
423 "machine.reset()", |
|
424 ] |
|
425 ) |
390 else: |
426 else: |
391 # perform a reset via esptool using flash_id command ignoring |
427 # perform a reset via esptool using flash_id command ignoring |
392 # the output |
428 # the output |
393 args = [ |
429 args = [ |
394 "-u", |
430 "-u", |
395 "-m", "esptool", |
431 "-m", |
396 "--port", self.microPython.getCurrentPort(), |
432 "esptool", |
397 "flash_id" |
433 "--port", |
|
434 self.microPython.getCurrentPort(), |
|
435 "flash_id", |
398 ] |
436 ] |
399 proc = QProcess() |
437 proc = QProcess() |
400 proc.start(Globals.getPythonExecutable(), args) |
438 proc.start(Globals.getPythonExecutable(), args) |
401 procStarted = proc.waitForStarted(10000) |
439 procStarted = proc.waitForStarted(10000) |
402 if procStarted: |
440 if procStarted: |
403 proc.waitForFinished(10000) |
441 proc.waitForFinished(10000) |
404 |
442 |
405 @pyqtSlot() |
443 @pyqtSlot() |
406 def __installEspTool(self): |
444 def __installEspTool(self): |
407 """ |
445 """ |
408 Private slot to install the esptool package via pip. |
446 Private slot to install the esptool package via pip. |
409 """ |
447 """ |
410 pip = ericApp().getObject("Pip") |
448 pip = ericApp().getObject("Pip") |
411 pip.installPackages(["esptool"], |
449 pip.installPackages(["esptool"], interpreter=Globals.getPythonExecutable()) |
412 interpreter=Globals.getPythonExecutable()) |
450 |
413 |
|
414 def getDocumentationUrl(self): |
451 def getDocumentationUrl(self): |
415 """ |
452 """ |
416 Public method to get the device documentation URL. |
453 Public method to get the device documentation URL. |
417 |
454 |
418 @return documentation URL of the device |
455 @return documentation URL of the device |
419 @rtype str |
456 @rtype str |
420 """ |
457 """ |
421 return Preferences.getMicroPython("MicroPythonDocuUrl") |
458 return Preferences.getMicroPython("MicroPythonDocuUrl") |
422 |
459 |
423 def getFirmwareUrl(self): |
460 def getFirmwareUrl(self): |
424 """ |
461 """ |
425 Public method to get the device firmware download URL. |
462 Public method to get the device firmware download URL. |
426 |
463 |
427 @return firmware download URL of the device |
464 @return firmware download URL of the device |
428 @rtype str |
465 @rtype str |
429 """ |
466 """ |
430 return Preferences.getMicroPython("MicroPythonFirmwareUrl") |
467 return Preferences.getMicroPython("MicroPythonFirmwareUrl") |