Skip to content

Espressif-IDE is not clearing serial port before trying to upload (IEP-1398) #1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*******************************************************************************/
package com.espressif.idf.launch.serial.internal;

import java.io.IOException;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
Expand Down Expand Up @@ -55,14 +51,7 @@ public void start()
wasOpen = serialPort.isOpen();
if (wasOpen)
{
try
{
serialPort.pause();
}
catch (IOException e)
{
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SerialFlashLaunch_Pause, e));
}
serialPort.pause();
}
}
else
Expand All @@ -77,14 +66,7 @@ public void handleDebugEvents(DebugEvent[] events)
super.handleDebugEvents(events);
if (isTerminated() && wasOpen)
{
try
{
serialPort.resume();
}
catch (IOException e)
{
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SerialFlashLaunch_Resume, e));
}
serialPort.resume();
wasOpen = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*******************************************************************************/
package com.espressif.idf.terminal.connector.serial.connector;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -28,7 +27,8 @@
import com.espressif.idf.core.util.StringUtil;
import com.espressif.idf.terminal.connector.serial.activator.Activator;

public class SerialConnector extends TerminalConnectorImpl {
public class SerialConnector extends TerminalConnectorImpl
{

private SerialSettings settings = new SerialSettings();
protected Process process;
Expand All @@ -40,43 +40,51 @@ public class SerialConnector extends TerminalConnectorImpl {

private static Set<String> openPorts = new HashSet<>();

public static boolean isOpen(String portName) {
public static boolean isOpen(String portName)
{
return openPorts.contains(portName);
}

@Override
public OutputStream getTerminalToRemoteStream() {
public OutputStream getTerminalToRemoteStream()
{
return process.getOutputStream();
}

public SerialSettings getSettings() {
public SerialSettings getSettings()
{
return settings;
}

@Override
public String getSettingsSummary() {
public String getSettingsSummary()
{
return settings.getSummary();
}

@Override
public void load(ISettingsStore store) {
public void load(ISettingsStore store)
{
settings.load(store);
}

@Override
public void save(ISettingsStore store) {
public void save(ISettingsStore store)
{
settings.save(store);
}

@Override
public void connect(ITerminalControl control) {
public void connect(ITerminalControl control)
{
super.connect(control);
this.control = control;

//Get selected project - which is required for IDF Monitor
// Get selected project - which is required for IDF Monitor
project = settings.getProject();

if (project == null) {
if (project == null)
{
String message = "project can't be null. Make sure you select a project before launch a serial monitor"; //$NON-NLS-1$
Activator.log(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), message, null));
return;
Expand All @@ -94,15 +102,13 @@ public void connect(ITerminalControl control) {
}

@Override
protected void doDisconnect() {
protected void doDisconnect()
{

if (serialPort != null && serialPort.isOpen()) {
if (serialPort != null && serialPort.isOpen())
{
openPorts.remove(serialPort.getPortName());
try {
serialPort.close();
} catch (IOException e) {
Activator.log(e);
}
serialPort.close();
}
}

Expand Down
Loading
Loading