eric6/MicroPython/EspDevices.py

changeset 7346
9108d26211f7
parent 7337
0e4a912548cc
child 7352
5f69f55b919f
--- a/eric6/MicroPython/EspDevices.py	Sun Dec 01 13:17:07 2019 +0100
+++ b/eric6/MicroPython/EspDevices.py	Sun Dec 01 18:55:38 2019 +0100
@@ -30,9 +30,6 @@
 # TODO: add restoreFlash: python esptool.py --port /dev/ttyUSB4 write_flash --flash_mode qio 0x00000 backup.img
 #       alternative modes for --flash_mode: qio,qout,dio,dout
 #       optional: --flash_size 1MB, 2MB, 4MB, 8MB, 16M (ESP8266 zusätzlich 256KB, 512KB)
-# TODO: add showChipID: python esptool.py  --port /dev/ttyUSB4  --baud 115200 chip_id
-# TODO: add showFlashID: python esptool.py  --port /dev/ttyUSB4  --baud 115200 flash_id
-# TODO: add readMAC: python esptool.py  --port /dev/ttyUSB4  --baud 115200 read_mac
 
 class EspDevice(MicroPythonDevice):
     """
@@ -146,6 +143,16 @@
                              self.__flashAddons)
         act.setEnabled(not connected)
         menu.addSeparator()
+        act = menu.addAction(self.tr("Show Chip ID"),
+                             self.__showChipID)
+        act.setEnabled(not connected)
+        act = menu.addAction(self.tr("Show Flash ID"),
+                             self.__showFlashID)
+        act.setEnabled(not connected)
+        act = menu.addAction(self.tr("Show MAC Address"),
+                             self.__showMACAddress)
+        act.setEnabled(not connected)
+        menu.addSeparator()
         act = menu.addAction(self.tr("Reset Device"), self.__resetDevice)
         menu.addSeparator()
         menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool)
@@ -231,6 +238,57 @@
                 dlg.exec_()
     
     @pyqtSlot()
+    def __showChipID(self):
+        """
+        Private slot to show the ID of the ESP chip.
+        """
+        args = [
+            "-u",
+            "-m", "esptool",
+            "--port", self.microPython.getCurrentPort(),
+            "chip_id"
+        ]
+        dlg = E5ProcessDialog(self.tr("'esptool chip_id' Output"),
+                              self.tr("Show Chip ID"))
+        res = dlg.startProcess(sys.executable, args)
+        if res:
+            dlg.exec_()
+    
+    @pyqtSlot()
+    def __showFlashID(self):
+        """
+        Private slot to show the ID of the ESP flash chip.
+        """
+        args = [
+            "-u",
+            "-m", "esptool",
+            "--port", self.microPython.getCurrentPort(),
+            "flash_id"
+        ]
+        dlg = E5ProcessDialog(self.tr("'esptool flash_id' Output"),
+                              self.tr("Show Flash ID"))
+        res = dlg.startProcess(sys.executable, args)
+        if res:
+            dlg.exec_()
+    
+    @pyqtSlot()
+    def __showMACAddress(self):
+        """
+        Private slot to show the MAC address of the ESP chip.
+        """
+        args = [
+            "-u",
+            "-m", "esptool",
+            "--port", self.microPython.getCurrentPort(),
+            "read_mac"
+        ]
+        dlg = E5ProcessDialog(self.tr("'esptool read_mac' Output"),
+                              self.tr("Show MAC Address"))
+        res = dlg.startProcess(sys.executable, args)
+        if res:
+            dlg.exec_()
+    
+    @pyqtSlot()
     def __resetDevice(self):
         """
         Private slot to reset the connected device.

eric ide

mercurial