JetBrains / intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
https://plugins.jetbrains.com/plugin/9777-micropython
Apache License 2.0
495 stars 106 forks source link

Micropython plugin no longer works #251

Closed PierreDeQuebec closed 8 months ago

PierreDeQuebec commented 9 months ago

What steps will reproduce the issue? Under Linux and for one or other of the versions of Intellij IDEA 2020.2.5, 2023.2.2, 2021.2.4, the Micropython plugin no longer works for an ESP8266 microcontroller, in this case a Metro M4 Airlift Lite microcircuit .

  1. Install the plugin from the Marketplace.
  2. Choose a Python SDK (>3.5)
  3. Connect the microcircuit to the PC station via the USB connection. Mount the device and check the presence of the /dev/ttyACM0 port (under Linux).
  4. In 'Project Structure...', under Modules, choose ESP8266 as device type, uncheck "Auto-detect device Path" and enter '/dev/ttyACM0'.
  5. Perform the detection test.

What is the expected result? In the 'Tools/Micropython' menu, clicking on 'Micropython REPL' should open a REPL window and allow interaction with the microcontroller.

What happens instead? The following message appears "No ESP8266 Devices Detected - Possible solutions: - Check if your device is connected to your computer - Specify the device path manually in the IDE settings for MicroPython" and the '/dev/ttyACM0' entry is deleted.

PierreDeQuebec commented 9 months ago

It is worth adding this. I forked the plugins and tried to "debug" it.

In the end, the error message is generated because the serial port is not detected in 'fun detectDevicePathSynchronously' at line 152 (val detected = findSerialPorts(deviceProvider, progress.progressIndicator).firstOrNull()).

fun detectDevicePathSynchronously(deviceProvider: MicroPythonDeviceProvider): String? {
  ApplicationManager.getApplication().assertIsDispatchThread()

  var detectedDevicePath: String? = null
  val deviceProviderName = deviceProvider.presentableName
  val progress = ProgressManager.getInstance()

  progress.runProcessWithProgressSynchronously({
    progress.progressIndicator.text = "Detecting connected $deviceProviderName devices..."
    val detected = findSerialPorts(deviceProvider, progress.progressIndicator).firstOrNull()
    ApplicationManager.getApplication().invokeLater {
      if (detected == null) {
        Messages.showErrorDialog(module.project,
            """Possible solutions:
              |
              |- Check if your device is connected to your computer
              |- Specify the device path manually in the IDE settings for MicroPython""".trimMargin(),
            "No $deviceProviderName Devices Detected")
      }
      detectedDevicePath = detected
    }

The problem seems related to the list of identifiers 'vendordid: productId' in the Esp8266DeviceProvider class: MicroPythonDeviceProvider. By adding the Adafruit identifier (0x239A, 0x8038) to the usbIds list, the plugin correctly detects the microcontroller board.