Skip to content

Commit 4fe1a54

Browse files
author
jantje
committed
Refactorted and simplified the upload code
Basically I the time I wrote this code I knew even less what I was doing as I do today. As there was also some old code that was no longer used I could simplify the code. I still think there is a job in a job so it probably still is overly complicated, but at least it is simpler now
1 parent 11bbc95 commit 4fe1a54

File tree

6 files changed

+237
-396
lines changed

6 files changed

+237
-396
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ private SloeberProject(IProject project) {
9595
}
9696
}
9797

98+
public IProject getProject() {
99+
return myProject;
100+
}
101+
98102
/**
99103
* convenient method to create project
100104
*
@@ -1118,7 +1122,7 @@ private IStatus BuildTarget(String targetName) {
11181122
*/
11191123
public IStatus upload() {
11201124

1121-
Job upLoadJob = UploadSketchWrapper.upload(myProject,
1125+
Job upLoadJob = UploadSketchWrapper.upload(this,
11221126
CoreModel.getDefault().getProjectDescription(myProject).getActiveConfiguration());
11231127

11241128
if (upLoadJob == null)

io.sloeber.core/src/io/sloeber/core/communication/ArduinoSerial.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import java.util.List;
99

1010
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
11-
import org.eclipse.core.resources.IProject;
11+
import io.sloeber.core.api.SloeberProject;
1212
import org.eclipse.core.runtime.IStatus;
1313
import org.eclipse.core.runtime.Status;
1414
import org.eclipse.ui.console.MessageConsoleStream;
1515

1616
import io.sloeber.core.api.BoardDescription;
1717
import io.sloeber.core.api.Serial;
1818

19+
1920
public class ArduinoSerial {
2021

2122
private ArduinoSerial() {
@@ -103,8 +104,7 @@ private static String wait_for_com_Port_to_appear(MessageConsoleStream console,
103104
int newPortsCopySize = newPorts.size();
104105
if ((newPortsCopy.isEmpty()) && (newPortsCopySize == prefNewPortsCopySize + 1)) {
105106
console.println(ArduinoSerial_Comport_Appeared_and_disappeared);
106-
console.println(
107-
ArduinoSerial_Comport_reset_took.replace(MS_TAG, Integer.toString(numTries * delayMs)));
107+
console.println(ArduinoSerial_Comport_reset_took.replace(MS_TAG, Integer.toString(numTries * delayMs)));
108108
return defaultComPort;
109109
}
110110
prefNewPortsCopySize = newPortsCopySize;
@@ -144,8 +144,10 @@ private static String wait_for_com_Port_to_appear(MessageConsoleStream console,
144144
* The name of the com port to reset
145145
* @return The com port to upload to
146146
*/
147-
public static String makeArduinoUploadready(MessageConsoleStream console, IProject project,
148-
ICConfigurationDescription confDesc, BoardDescription boardDescriptor) {
147+
public static String makeArduinoUploadready(MessageConsoleStream console, SloeberProject project,
148+
ICConfigurationDescription confDesc) {
149+
150+
BoardDescription boardDescriptor = project.getBoardDescription(confDesc.getName(), true);
149151
boolean use_1200bps_touch = getBuildEnvironmentVariable(confDesc, ENV_KEY_UPLOAD_USE_1200BPS_TOUCH, FALSE)
150152
.equalsIgnoreCase(TRUE);
151153
boolean bWaitForUploadPort = getBuildEnvironmentVariable(confDesc, ENV_KEY_WAIT_FOR_UPLOAD_PORT, FALSE)

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

-56
This file was deleted.

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

-15
This file was deleted.

0 commit comments

Comments
 (0)