Skip to content

Commit 97aefec

Browse files
author
jantje
committed
#333 This should work but I'd like to do some testing before making it
master
1 parent 7130bef commit 97aefec

File tree

4 files changed

+68
-83
lines changed

4 files changed

+68
-83
lines changed

it.baeyens.arduino.common/src/it/baeyens/arduino/common/Const.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Const {
2222
// General stuff
2323
public static final String PLUGIN_START = "it.baeyens.";
2424
public static final String CORE_PLUGIN_ID = PLUGIN_START + "arduino.core";
25+
public static final String NETWORK = "NETWORK";
2526

2627
// prefix to be added to the arduino environment
2728
protected static final String UPLOAD_PORT_PREFIX_WIN = "-P\\\\.\\";
@@ -49,7 +50,8 @@ public class Const {
4950
public static final String ACTION_SIZE = "RECIPE.SIZE";
5051
public static final String ACTION_AR = "RECIPE.AR";
5152
public static final String ACTION_C_COMBINE = "RECIPE.C.COMBINE";
52-
53+
public static final String UPLOAD_CLASS = "UPLOAD_CLASS";
54+
public static final String UPLOAD_CLASS_DEFAULT = "arduinoUploader";
5355

5456
// Describers
5557
public static final String ENV_PROTOCOL = "PROTOCOL";
@@ -125,7 +127,6 @@ public class Const {
125127
public static final String ENV_KEY_WAIT_FOR_UPLOAD_PORT = ENV_KEY_BOARD_START + "UPLOAD.WAIT_FOR_UPLOAD_PORT";
126128
public static final String ENV_KEY_RESET_BEFORE_UPLOAD = ENV_KEY_BOARD_START + "UPLOAD.FORCE_RESET_BEFORE_UPLOAD";
127129

128-
129130
public static final String ENV_KEY_BUILD_CORE = ENV_KEY_BOARD_START + "BUILD.CORE";
130131
public static final String ENV_KEY_BUILD_CORE_PATH = ENV_KEY_BOARD_START + "BUILD.CORE.PATH";
131132
public static final String ENV_KEY_USE_ARCHIVER = ENV_KEY_BOARD_START + "BUILD.USE_ARCHIVER";

it.baeyens.arduino.core/config/pre_processing_platform_default.txt

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ BUILD.CORE.PATH={RUNTIME.PLATFORM.PATH}/cores/{BUILD.CORE}
77
archive_file_path={build.path}/{archive_file}
88
runtime.IDE.version=10606
99
build.system.path={RUNTIME.PLATFORM.PATH}/system
10+
11+
#for esp8266 network upload
12+
tools.esp8266ATO={tools.esptool.network_cmd}
13+
tools.esp8266ATO.upload.pattern={tools.esptool.upload.network_pattern}
14+
esp8266.network.upload.tool=esp8266ATO

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/Helpers.java

+21-61
Original file line numberDiff line numberDiff line change
@@ -372,60 +372,6 @@ public static void addFileToProject(IContainer container, Path path, InputStream
372372
}
373373
}
374374

375-
// /**
376-
// * This method sets the eclipse path variables to contain the 3 important
377-
// Arduino hardware folders (code wise that is)
378-
// *
379-
// * Core path (used when referencing Arduino Code) The Arduino Pin Path
380-
// (used from Arduino 1.0 to reference the arduino pin variants) The
381-
// libraries
382-
// * path (used to find libraries)
383-
// *
384-
// * Paths are given relative to the arduino folder to avoid conflict when a
385-
// version control system is being used (these values are in the
386-
// .project
387-
// * file) As the arduino folder location is in the workspace all values in
388-
// the .project file become relative avoiding conflict.
389-
// *
390-
// * If core or variant are of the type [vendor ID]:[core ID] then we
391-
// reroute
392-
// *
393-
// * @param project
394-
// */
395-
// public static void setProjectPathVariables(ICConfigurationDescription
396-
// configurationDescription) {
397-
// IPath variantPath = new
398-
// Path(Common.getBuildEnvironmentVariable(configurationDescription,
399-
// ArduinoConst.ENV_KEY_build_variant_path, ""));
400-
// IPath corePath = new
401-
// Path(Common.getBuildEnvironmentVariable(configurationDescription,
402-
// ArduinoConst.ENV_KEY_build_core_path, ""));
403-
// IPath platformPath = new
404-
// Path(Common.getBuildEnvironmentVariable(configurationDescription,
405-
// ArduinoConst.ENV_KEY_PLATFORM_PATH, ""));
406-
//
407-
// IPath arduinoHardwareLibraryPath =
408-
// platformPath.append(ArduinoConst.LIBRARY_PATH_SUFFIX);
409-
// IPathVariableManager pathMan =
410-
// configurationDescription.getProjectDescription().getProject().getPathVariableManager();
411-
// try {
412-
// pathMan.setURIValue(ArduinoConst.WORKSPACE_PATH_VARIABLE_NAME_HARDWARE_LIB,
413-
// URIUtil.toURI(arduinoHardwareLibraryPath));
414-
// pathMan.setURIValue(ArduinoConst.PATH_VARIABLE_NAME_ARDUINO_PLATFORM,
415-
// URIUtil.toURI(corePath.removeLastSegments(1)));
416-
// pathMan.setURIValue(ArduinoConst.PATH_VARIABLE_NAME_ARDUINO_PINS,
417-
// URIUtil.toURI(variantPath.removeLastSegments(1)));
418-
// // pathMan.setURIValue("ArduinoPivateLibPath", URIUtil.toURI("${" +
419-
// ArduinoConst.WORKSPACE_PATH_VARIABLE_NAME_PRIVATE_LIB + "}"));
420-
//
421-
// } catch (CoreException e) {
422-
// Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID,
423-
// "Failed to create the path variable variables. The setup will not work
424-
// properly", e));
425-
// e.printStackTrace();
426-
// }
427-
// }
428-
429375
private static void searchFiles(File folder, HashSet<String> Hardwarelists, String Filename, int depth) {
430376
if (depth > 0) {
431377
File[] a = folder.listFiles();
@@ -859,9 +805,9 @@ private static void setTheEnvironmentVariablesAddThePlatformInfo(IContributedEnv
859805
* from arduino IDE 1.6.5 an additional file generated by the arduino ide is
860806
* processed. This is the first file processed.
861807
*
862-
* To be able to quickly fix boards.txt and pmatform.txt problems I also
863-
* added a arduino_eclipse_plugin.txt that is processed as a boards.txt file
864-
* and is processed after the arduino delivered boards.txt file.
808+
* To be able to quickly fix boards.txt and platform.txt problems I also
809+
* added a pre and post platform and boards files that are processed before
810+
* and after the arduino delivered boards.txt file.
865811
*
866812
* @param project
867813
* the project for which the environment variables are set
@@ -882,8 +828,6 @@ public static void setTheEnvironmentVariables(IProject project, ICConfigurationD
882828
Common.getBuildEnvironmentVariable(confDesc, Const.ENV_KEY_JANTJE_PLATFORM_FILE, EMPTY_STRING))
883829
.toFile();
884830
Programmers localProgrammers = Programmers.fromBoards(boardFileName);
885-
// File pluginPlatformFilename =
886-
// ConfigurationPreferences.getPlugin_Platform_File();
887831

888832
String boardID = Common.getBuildEnvironmentVariable(confDesc, Const.ENV_KEY_JANTJE_BOARD_ID, EMPTY_STRING);
889833
String architecture = Common.getBuildEnvironmentVariable(confDesc, Const.ENV_KEY_JANTJE_ARCITECTURE_ID,
@@ -1131,8 +1075,24 @@ private static void setTheEnvironmentVariablesPostProcessing(IContributedEnviron
11311075
String programmer = contribEnv.getVariable(get_Jantje_KEY_PROTOCOL(ACTION_UPLOAD), confDesc).getValue();
11321076
if (programmer.equalsIgnoreCase(Const.DEFAULT)) {
11331077
String uploadTool = contribEnv.getVariable(get_ENV_KEY_TOOL(ACTION_UPLOAD), confDesc).getValue();
1134-
setBuildEnvironmentVariable(contribEnv, confDesc, get_Jantje_KEY_RECIPE(ACTION_UPLOAD),
1135-
makeEnvironmentVar(get_ENV_KEY_RECIPE(uploadTool, ACTION_UPLOAD)));
1078+
String MComPort = contribEnv.getVariable(Const.ENV_KEY_JANTJE_COM_PORT, confDesc).getValue();
1079+
if (getHostFromComPort(MComPort) != null) {
1080+
String platform = contribEnv.getVariable(Const.ENV_KEY_JANTJE_ARCITECTURE_ID, confDesc).getValue();
1081+
try {
1082+
String key = ENV_KEY_BOARD_START + platform.toUpperCase() + DOT + NETWORK + DOT
1083+
+ ACTION_UPLOAD.toUpperCase() + DOT + ENV_TOOL;
1084+
String networkUploadTool = contribEnv.getVariable(key, confDesc).getValue();
1085+
if (!networkUploadTool.isEmpty()) {
1086+
uploadTool = networkUploadTool;
1087+
setBuildEnvironmentVariable(contribEnv, confDesc, get_ENV_KEY_TOOL(UPLOAD_CLASS),
1088+
UPLOAD_CLASS_DEFAULT);
1089+
setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_RESET_BEFORE_UPLOAD, FALSE);
1090+
}
1091+
} catch (Exception e) {
1092+
// simply ignore
1093+
}
1094+
}
1095+
setBuildEnvironmentVariable(contribEnv, confDesc, get_Jantje_KEY_RECIPE(ACTION_UPLOAD), makeEnvironmentVar(get_ENV_KEY_RECIPE(uploadTool, ACTION_UPLOAD)));
11361096
setBuildEnvironmentVariable(contribEnv, confDesc, get_ENV_KEY_TOOL(ACTION_PROGRAM),
11371097
makeEnvironmentVar(get_ENV_KEY_TOOL(ACTION_UPLOAD)));
11381098
} else {

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/uploaders/UploadSketchWrapper.java

+39-20
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ public void internalUpload(IProject Project, String cConf) {
5858
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.Upload_Project_nature_unaccesible, e));
5959
}
6060

61-
String UpLoadTool = Common.getBuildEnvironmentVariable(Project, cConf, Const.get_ENV_KEY_TOOL(Const.ACTION_UPLOAD), Const.EMPTY_STRING);
62-
String MComPort = Common.getBuildEnvironmentVariable(Project, cConf, Const.ENV_KEY_JANTJE_COM_PORT, Const.EMPTY_STRING);
61+
String UpLoadTool = Common.getBuildEnvironmentVariable(Project, cConf,
62+
Const.get_ENV_KEY_TOOL(Const.ACTION_UPLOAD), Const.EMPTY_STRING);
63+
String MComPort = Common.getBuildEnvironmentVariable(Project, cConf, Const.ENV_KEY_JANTJE_COM_PORT,
64+
Const.EMPTY_STRING);
65+
String uploadClass = Common.getBuildEnvironmentVariable(Project, cConf,
66+
Const.get_ENV_KEY_TOOL(Const.UPLOAD_CLASS), Const.EMPTY_STRING);
6367
this.myConsole = Helpers.findConsole(Messages.Upload_console);
6468
this.myConsole.clearConsole();
6569
this.myConsole.activate();
@@ -76,20 +80,29 @@ public void internalUpload(IProject Project, String cConf) {
7680
String host = Helpers.getHostFromComPort(MComPort);
7781

7882
if (host != null) {
79-
this.myHighLevelConsoleStream.println(Messages.Upload_ssh);
80-
PasswordManager pwdManager = new PasswordManager();
81-
if (!pwdManager.setHost(host)) {
82-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.Upload_login_credentials_missing + host));
83-
}
83+
if (Const.UPLOAD_CLASS_DEFAULT.equals(uploadClass)) {
84+
this.myHighLevelConsoleStream.println(Messages.Upload_arduino);
85+
realUploader = new arduinoUploader(Project, cConf, UpLoadTool, this.myConsole);
86+
uploadJobName = UpLoadTool;
87+
} else {
88+
this.myHighLevelConsoleStream.println(Messages.Upload_ssh);
89+
PasswordManager pwdManager = new PasswordManager();
90+
if (!pwdManager.setHost(host)) {
91+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
92+
Messages.Upload_login_credentials_missing + host));
93+
}
8494

85-
String password = pwdManager.getPassword();
86-
String login = pwdManager.getLogin();
95+
String password = pwdManager.getPassword();
96+
String login = pwdManager.getLogin();
8797

88-
realUploader = new SSHUpload(this.myHighLevelConsoleStream, this.myOutconsoleStream, this.myErrconsoleStream, password, host, login);
89-
uploadJobName = Const.UPLOAD_SSH;
98+
realUploader = new SSHUpload(this.myHighLevelConsoleStream, this.myOutconsoleStream,
99+
this.myErrconsoleStream, password, host, login);
100+
uploadJobName = Const.UPLOAD_SSH;
101+
}
90102
} else if (UpLoadTool.equalsIgnoreCase(Const.UPLOAD_TOOL_TEENSY)) {
91103
this.myHighLevelConsoleStream.println(Messages.Upload_generic);
92-
realUploader = new GenericLocalUploader(UpLoadTool, Project, cConf, this.myConsole, this.myErrconsoleStream, this.myOutconsoleStream);
104+
realUploader = new GenericLocalUploader(UpLoadTool, Project, cConf, this.myConsole, this.myErrconsoleStream,
105+
this.myOutconsoleStream);
93106
uploadJobName = UpLoadTool;
94107
} else {
95108
this.myHighLevelConsoleStream.println(Messages.Upload_arduino);
@@ -108,9 +121,10 @@ public void internalUpload(IProject Project, String cConf) {
108121
protected IStatus run(IProgressMonitor monitor) {
109122
try {
110123
String uploadflag = "FuStatus"; //$NON-NLS-1$
111-
char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't', '/', 'e', 'c', 'l', 'i', 'p',
112-
's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'u', 'p', 'l', 'o', 'a', 'd', 'S', 't', 'a', 'r', 't', '.',
113-
'h', 't', 'm', 'l', '?', 'u', '=' };
124+
char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't',
125+
'/', 'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/',
126+
'u', 'p', 'l', 'o', 'a', 'd', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 'u',
127+
'=' };
114128
IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode(Const.NODE_ARDUINO);
115129
int curFsiStatus = myScope.getInt(uploadflag, 0) + 1;
116130
URL pluginStartInitiator = new URL(new String(uri) + Integer.toString(curFsiStatus));
@@ -128,7 +142,8 @@ protected IStatus run(IProgressMonitor monitor) {
128142
}
129143

130144
/**
131-
* UploadJobWrapper stops the serial port and restarts the serial port as needed. in between it calls the real uploader IUploader
145+
* UploadJobWrapper stops the serial port and restarts the serial port as
146+
* needed. in between it calls the real uploader IUploader
132147
*
133148
* @author jan
134149
*
@@ -152,15 +167,18 @@ protected IStatus run(IProgressMonitor monitor) {
152167
boolean WeStoppedTheComPort = false;
153168
String myComPort = Const.EMPTY_STRING;
154169
try {
155-
monitor.beginTask(Messages.Upload_uploading + " \"" + this.myProject.getName() + "\" " + this.myNAmeTag, 2); //$NON-NLS-1$//$NON-NLS-2$
156-
myComPort = Common.getBuildEnvironmentVariable(this.myProject, this.myCConf, Const.ENV_KEY_JANTJE_COM_PORT, ""); //$NON-NLS-1$
170+
monitor.beginTask(Messages.Upload_uploading + " \"" + this.myProject.getName() + "\" " + this.myNAmeTag, //$NON-NLS-1$//$NON-NLS-2$
171+
2);
172+
myComPort = Common.getBuildEnvironmentVariable(this.myProject, this.myCConf,
173+
Const.ENV_KEY_JANTJE_COM_PORT, ""); //$NON-NLS-1$
157174

158175
try {
159176
WeStoppedTheComPort = Common.StopSerialMonitor(myComPort);
160177
} catch (Exception e) {
161178
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, Messages.Upload_Error_com_port, e));
162179
}
163-
IFile hexFile = this.myProject.getFile(new Path(this.myCConf).append(this.myProject.getName() + ".hex")); //$NON-NLS-1$
180+
IFile hexFile = this.myProject
181+
.getFile(new Path(this.myCConf).append(this.myProject.getName() + ".hex")); //$NON-NLS-1$
164182
if (this.myUploader.uploadUsingPreferences(hexFile, this.myProject, false, monitor)) {
165183
UploadSketchWrapper.this.myHighLevelConsoleStream.println(Messages.Upload_Done);
166184
} else {
@@ -175,7 +193,8 @@ protected IStatus run(IProgressMonitor monitor) {
175193
Common.StartSerialMonitor(myComPort);
176194
}
177195
} catch (Exception e) {
178-
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, Messages.Upload_Error_serial_monitor_restart, e));
196+
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,
197+
Messages.Upload_Error_serial_monitor_restart, e));
179198
}
180199
monitor.done();
181200
}

0 commit comments

Comments
 (0)