Skip to content

Commit 6a00777

Browse files
author
jantje
committed
#1394 refactor rename to make things more readable
1 parent c3269fb commit 6a00777

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

io.sloeber.core/src/io/sloeber/core/api/SerialManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public static void UnRegisterSerialUser() {
3636
otherSerialUser = null;
3737
}
3838

39-
public static boolean StopSerialMonitor(String mComPort) {
39+
public static boolean pauzeSerialMonitor(String mComPort) {
4040
if (otherSerialUser != null) {
4141
return otherSerialUser.PauzePort(mComPort);
4242
}
4343
return false;
4444
}
4545

46-
public static void StartSerialMonitor(String mComPort) {
46+
public static void resumeSerialMonitor(String mComPort) {
4747
if (otherSerialUser != null) {
4848
otherSerialUser.ResumePort(mComPort);
4949
}

io.sloeber.core/src/io/sloeber/core/toolchain/SloeberBuildRunner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public boolean invokeBuild(int kind, IProject project, IConfiguration configurat
5454
}
5555
}
5656

57-
boolean WeStoppedTheComPort = false;
57+
boolean theComPortIsPauzed = false;
5858
if (!actualUploadPort.isBlank()) {
5959
try {
60-
WeStoppedTheComPort = SerialManager.StopSerialMonitor(actualUploadPort);
60+
theComPortIsPauzed = SerialManager.pauzeSerialMonitor(actualUploadPort);
6161
} catch (Exception e) {
6262
Status ret = new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, Messages.Upload_Error_com_port, e);
6363
Common.log(ret);
@@ -93,9 +93,9 @@ protected IStatus run(IProgressMonitor _monitor) {
9393
boolean ret = super.invokeBuild(kind, project, configuration, builder, console, markerGenerator, projectBuilder,
9494
monitor);
9595

96-
if (WeStoppedTheComPort) {
96+
if (theComPortIsPauzed) {
9797
try {
98-
SerialManager.StartSerialMonitor(actualUploadPort);
98+
SerialManager.resumeSerialMonitor(actualUploadPort);
9999
} catch (Exception e) {
100100
Status ret2 = new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,
101101
Messages.Upload_Error_serial_monitor_restart, e);

io.sloeber.core/src/io/sloeber/core/tools/uploaders/UploadSketchWrapper.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.File;
88
import java.io.IOException;
99
import java.net.URL;
10+
import java.util.List;
1011

1112
import org.eclipse.cdt.core.CCorePlugin;
1213
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
@@ -43,6 +44,7 @@
4344
import io.sloeber.core.Messages;
4445
import io.sloeber.core.api.BoardDescription;
4546
import io.sloeber.core.api.PasswordManager;
47+
import io.sloeber.core.api.Serial;
4648
import io.sloeber.core.api.SerialManager;
4749
import io.sloeber.core.api.SloeberProject;
4850
import io.sloeber.core.common.IndexHelper;
@@ -132,7 +134,7 @@ public UploadJobWrapper(String name, SloeberProject project, ICConfigurationDesc
132134
@Override
133135
protected IStatus run(IProgressMonitor monitor) {
134136
IStatus ret = Status.OK_STATUS;
135-
boolean WeStoppedTheComPort = false;
137+
boolean theComPortIsPauzed = false;
136138

137139
String projectName = myProject.getName();
138140
BoardDescription boardDescriptor = mySProject.getBoardDescription(myConfDes.getName(), true);
@@ -166,7 +168,7 @@ public void run() {
166168
highLevelStream.println(message);
167169
monitor.beginTask(message, 2);
168170
try {
169-
WeStoppedTheComPort = SerialManager.StopSerialMonitor(myProvidedUploadPort);
171+
theComPortIsPauzed = SerialManager.pauzeSerialMonitor(myProvidedUploadPort);
170172
} catch (Exception e) {
171173
ret = new Status(IStatus.WARNING, CORE_PLUGIN_ID, Upload_Error_com_port, e);
172174
log(ret);
@@ -183,8 +185,22 @@ public void run() {
183185
log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, error, e));
184186
} finally {
185187
try {
186-
if (WeStoppedTheComPort) {
187-
SerialManager.StartSerialMonitor(myProvidedUploadPort);
188+
if (theComPortIsPauzed) {
189+
// wait for the port to reappear
190+
boolean portFound = false;
191+
int counter = 0;
192+
while (!portFound & counter++ < 100) {
193+
List<String> currentPorts = Serial.list();
194+
portFound = currentPorts.contains(myProvidedUploadPort);
195+
if (!portFound) {
196+
Thread.sleep(100);
197+
}
198+
}
199+
if (portFound) {
200+
SerialManager.resumeSerialMonitor(myProvidedUploadPort);
201+
} else {
202+
SerialManager.pauzeSerialMonitor(myProvidedUploadPort);
203+
}
188204
}
189205
} catch (Exception e) {
190206
ret = new Status(IStatus.WARNING, CORE_PLUGIN_ID, Messages.Upload_Error_serial_monitor_restart, e);

0 commit comments

Comments
 (0)