Search in sources :

Example 1 with STATUS

use of xyz.elmot.clion.openocd.OpenOcdComponent.STATUS in project clion-embedded-arm by elmot.

the class OpenOcdLauncher method startDebugProcess.

@NotNull
@Override
public CidrDebugProcess startDebugProcess(@NotNull CommandLineState commandLineState, @NotNull XDebugSession xDebugSession) throws ExecutionException {
    Project project = commandLineState.getEnvironment().getProject();
    File runFile = findRunFile(commandLineState);
    try {
        xDebugSession.stop();
        OpenOcdComponent openOcdComponent = findOpenOcdAction(commandLineState.getEnvironment().getProject());
        openOcdComponent.stopOpenOcd();
        Future<STATUS> downloadResult = openOcdComponent.startOpenOcd(project, runFile, "reset init");
        ThrowableComputable<STATUS, ExecutionException> process = () -> {
            try {
                ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
                return downloadResult.get(10, TimeUnit.MINUTES);
            } catch (InterruptedException | TimeoutException | java.util.concurrent.ExecutionException e) {
                throw new ExecutionException(e);
            }
        };
        STATUS downloadStatus = ProgressManager.getInstance().runProcessWithProgressSynchronously(process, "Firmware Download", true, getProject());
        if (downloadStatus == STATUS.FLASH_ERROR) {
            downloadResult.cancel(true);
            throw new ExecutionException("OpenOCD cancelled");
        }
        return super.startDebugProcess(commandLineState, xDebugSession);
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(getProject(), e.getLocalizedMessage(), e.getTitle());
        throw new ExecutionException(e);
    }
}
Also used : Project(com.intellij.openapi.project.Project) STATUS(xyz.elmot.clion.openocd.OpenOcdComponent.STATUS) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1 STATUS (xyz.elmot.clion.openocd.OpenOcdComponent.STATUS)1