fun detectDevicePathSynchronously()

in src/main/kotlin/com/jetbrains/micropython/settings/MicroPythonFacet.kt [146:169]


  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
      }
    }, "Detecting MicroPython devices", true, module.project, null)
    return detectedDevicePath
  }