Skip to content

Commit bcec355

Browse files
committed
Merge pull request #455 from jantje/working
ATO, programmer, build before upload
2 parents 9f9a775 + 1f16215 commit bcec355

File tree

22 files changed

+972
-814
lines changed

22 files changed

+972
-814
lines changed

it.baeyens.arduino.common/META-INF/MANIFEST.MF

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ Bundle-Version: 3.0.0.qualifier
66
Bundle-Activator: it.baeyens.arduino.common.Activator
77
Require-Bundle: org.eclipse.ui,
88
org.eclipse.core.runtime,
9-
org.junit
9+
org.junit,
10+
org.eclipse.wb.core.lib,
11+
org.eclipse.cdt.core
1012
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
1113
Bundle-ActivationPolicy: lazy
1214
Export-Package: it.baeyens.arduino.arduino,
1315
it.baeyens.arduino.common
1416
Import-Package: org.eclipse.cdt.core,
1517
org.eclipse.cdt.core.envvar,
18+
org.eclipse.cdt.core.index,
1619
org.eclipse.cdt.core.model,
1720
org.eclipse.cdt.core.settings.model,
1821
org.eclipse.core.resources

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static Vector<String> list() {
128128
String[] portNames;
129129
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
130130
if (os.indexOf("mac") >= 0) { //$NON-NLS-1$
131-
portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("^cu\\..*(serial|usb).*")); //$NON-NLS-1$ //$NON-NLS-2$
131+
portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("^cu\\..*(UART|serial|usb).*")); //$NON-NLS-1$ //$NON-NLS-2$
132132
} else {
133133
portNames = SerialPortList.getPortNames();
134134
}

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

Lines changed: 25 additions & 8 deletions
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";
@@ -124,7 +126,8 @@ public class Const {
124126
public static final String ENV_KEY_UPLOAD_DISABLE_FLUSHING = ENV_KEY_BOARD_START + "UPLOAD.DISABLE_FLUSHING";
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";
127-
129+
public static final String ENV_KEY_NETWORK_PORT = ENV_KEY_BOARD_START + "NETWORK.PORT";
130+
public static final String ENV_KEY_NETWORK_AUTH = ENV_KEY_BOARD_START + "NETWORK.AUTH";
128131

129132
public static final String ENV_KEY_BUILD_CORE = ENV_KEY_BOARD_START + "BUILD.CORE";
130133
public static final String ENV_KEY_BUILD_CORE_PATH = ENV_KEY_BOARD_START + "BUILD.CORE.PATH";
@@ -138,13 +141,15 @@ public class Const {
138141
public static final String ENV_KEY_JANTJE_SIZE_SWITCH = ENV_KEY_JANTJE_START + "SIZE.SWITCH";
139142
public static final String ENV_KEY_JANTJE_BOARDS_FILE = ENV_KEY_JANTJE_START + "BOARDS_FILE";
140143
public static final String ENV_KEY_JANTJE_PLATFORM_FILE = ENV_KEY_JANTJE_START + "PLATFORM_FILE";
141-
public static final String ENV_KEY_JANTJE_REFERENCED_PLATFORM_FILE = ENV_KEY_JANTJE_START + "REFERENCED_PLATFORM_FILE";
144+
public static final String ENV_KEY_JANTJE_REFERENCED_PLATFORM_FILE = ENV_KEY_JANTJE_START
145+
+ "REFERENCED_PLATFORM_FILE";
142146
public static final String ENV_KEY_JANTJE_COM_PORT = ENV_KEY_JANTJE_START + "COM_PORT";
143147
public static final String ENV_KEY_JANTJE_BOARD_NAME = ENV_KEY_JANTJE_START + "BOARD_NAME";
144148

145149
public static final String ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS = ENV_KEY_JANTJE_START + "EXTRA.COMPILE";
146150
public static final String ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS = ENV_KEY_JANTJE_START + "EXTRA.C.COMPILE";
147-
public static final String ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS = ENV_KEY_JANTJE_START + "EXTRA.CPP.COMPILE";
151+
public static final String ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS = ENV_KEY_JANTJE_START
152+
+ "EXTRA.CPP.COMPILE";
148153
public static final String ENV_KEY_JANTJE_PACKAGE_ID = ENV_KEY_JANTJE_START + "PACKAGE_ID";
149154
public static final String ENV_KEY_JANTJE_ARCITECTURE_ID = ENV_KEY_JANTJE_START + "ARCHITECTURE_ID";
150155
public static final String ENV_KEY_JANTJE_BOARD_ID = ENV_KEY_JANTJE_START + "BOARD_ID";
@@ -156,15 +161,25 @@ public class Const {
156161
// template Sketch information
157162

158163
public static final String ENV_KEY_JANTJE_SKETCH_TEMPLATE_FOLDER = ENV_KEY_JANTJE_START + "TEMPLATE_FOLDER";
159-
public static final String ENV_KEY_JANTJE_SKETCH_TEMPLATE_USE_DEFAULT = ENV_KEY_JANTJE_START + "TEMPLATE_USE_DEFAULT";
164+
public static final String ENV_KEY_JANTJE_SKETCH_TEMPLATE_USE_DEFAULT = ENV_KEY_JANTJE_START
165+
+ "TEMPLATE_USE_DEFAULT";
160166

161167
public static final String ENV_KEY_WARNING_LEVEL_OFF = " -w ";
162168
public static final String ENV_KEY_WARNING_LEVEL_ON = " -Wall ";
163169

164170
public static final String ENV_KEY_GNU_SERIAL_PORTS = "gnu.io.rxtx.SerialPorts";
165171
public static final String ENV_VALUE_GNU_SERIAL_PORTS_LINUX = "/dev/ttyACM0:/dev/ttyACM1:/dev/ttyACM2:/dev/ttyACM3:/dev/ttyUSB0::/dev/ttyUSB1::/dev/ttyUSB2::/dev/ttyUSB3::/dev/ttyUSB4";
166172
// scope stuff
167-
public static final short SCOPE_START_DATA = (short) 0xCDAB;// This is the 205 171 or -85 -51 flag that indicates scope data is following least significant first 0xCDAB;
173+
public static final short SCOPE_START_DATA = (short) 0xCDAB;// This is the
174+
// 205 171 or
175+
// -85 -51 flag
176+
// that
177+
// indicates
178+
// scope data is
179+
// following
180+
// least
181+
// significant
182+
// first 0xCDAB;
168183
public static final String EXAMPLE_FOLDER_NAME = "examples";
169184

170185
public static final String PRE_PROCESSING_BOARDS_TXT = "pre_processing_boards.txt";
@@ -204,13 +219,15 @@ public static String get_ENV_KEY_RECIPE(String action) {
204219
}
205220

206221
/**
207-
* given a action and a tool return the environment key that matches it's recipe
222+
* given a action and a tool return the environment key that matches it's
223+
* recipe
208224
*
209225
* @param action
210226
* @return he environment variable key to find the recipe
211227
*/
212228
public static String get_ENV_KEY_RECIPE(String tool, String action) {
213-
return ENV_KEY_BOARD_START + "TOOLS" + DOT + tool.toUpperCase() + DOT + action.toUpperCase() + DOT + ENV_PATTERN;
229+
return ENV_KEY_BOARD_START + "TOOLS" + DOT + tool.toUpperCase() + DOT + action.toUpperCase() + DOT
230+
+ ENV_PATTERN;
214231
}
215232

216233
public static String get_Jantje_KEY_PROTOCOL(String action) {
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package it.baeyens.arduino.common;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
6+
import org.apache.commons.io.FileUtils;
7+
import org.eclipse.cdt.core.CCorePlugin;
8+
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
9+
import org.eclipse.cdt.core.index.IIndex;
10+
import org.eclipse.cdt.core.index.IIndexBinding;
11+
import org.eclipse.cdt.core.index.IIndexName;
12+
import org.eclipse.cdt.core.index.IndexFilter;
13+
import org.eclipse.cdt.core.model.CoreModel;
14+
import org.eclipse.cdt.core.model.ICProject;
15+
import org.eclipse.core.resources.IProject;
16+
import org.eclipse.core.runtime.CoreException;
17+
import org.eclipse.core.runtime.NullProgressMonitor;
18+
19+
public class IndexHelper {
20+
/**
21+
* given a list of names from the indexer. Find a function call and return
22+
* the parameter I assume there is only one parameter and it is a string so
23+
* there are quotes
24+
*
25+
* @param names
26+
* the names provided by the indexer
27+
* @param function
28+
* the name of the function for which we are looking for a
29+
* parameter
30+
* @return the string or defaultValue if no string is found
31+
*/
32+
private static String findParameterInFunction(IIndexName[] names, String function, String defaultValue) {
33+
for (IIndexName name : names) {
34+
String SetupFileName = name.getFileLocation().getFileName();
35+
String SetupFileContent;
36+
try {
37+
SetupFileContent = FileUtils.readFileToString(new File(SetupFileName));
38+
} catch (IOException e) {
39+
return defaultValue;
40+
}
41+
SetupFileContent = SetupFileContent.replaceAll("//.*|/\\*((.|\\n)(?!=*/))+\\*/", ""); //$NON-NLS-1$ //$NON-NLS-2$
42+
int serialBeginStart = SetupFileContent.indexOf(function);
43+
if (serialBeginStart != -1) {
44+
int serialBeginStartbraket = SetupFileContent.indexOf("(", serialBeginStart); //$NON-NLS-1$
45+
if (serialBeginStartbraket != -1) {
46+
int serialBeginCloseBraket = SetupFileContent.indexOf(")", serialBeginStartbraket); //$NON-NLS-1$
47+
if (serialBeginCloseBraket != -1) {
48+
return SetupFileContent.substring(serialBeginStartbraket + 1, serialBeginCloseBraket).trim();
49+
50+
}
51+
}
52+
}
53+
}
54+
return defaultValue;
55+
56+
}
57+
58+
/**
59+
* given a project look in the source code for the line of code that sets
60+
* the password;
61+
*
62+
*
63+
*
64+
* return the password string of no_pwd_found_in_code
65+
*
66+
* @param iProject
67+
* @return
68+
*/
69+
public static String findParameterInFunction(IProject project, String parentFunctionName, String childFunctionName,
70+
String defaultValue) {
71+
72+
ICProject curProject = CoreModel.getDefault().getCModel().getCProject(project.getName());
73+
74+
IIndex index = null;
75+
try {
76+
index = CCorePlugin.getIndexManager().getIndex(curProject);
77+
index.acquireReadLock();
78+
IIndexBinding[] bindings = index.findBindings(parentFunctionName.toCharArray(), IndexFilter.ALL_DECLARED,
79+
new NullProgressMonitor());
80+
ICPPFunction parentFunction = null;
81+
for (IIndexBinding curbinding : bindings) {
82+
if (curbinding instanceof ICPPFunction) {
83+
parentFunction = (ICPPFunction) curbinding;
84+
}
85+
}
86+
87+
if (parentFunction == null) {
88+
return defaultValue;// that on found binding must be a function
89+
}
90+
91+
IIndexName[] names = index.findNames(parentFunction, org.eclipse.cdt.core.index.IIndex.FIND_DEFINITIONS);
92+
93+
return findParameterInFunction(names, childFunctionName, defaultValue);
94+
95+
} catch (CoreException | InterruptedException e) {
96+
e.printStackTrace();
97+
} finally {
98+
if (index != null) {
99+
index.releaseReadLock();
100+
}
101+
}
102+
103+
return defaultValue;
104+
}
105+
106+
}

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

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
import org.eclipse.core.runtime.Status;
1010
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
1111
import org.eclipse.core.runtime.preferences.InstanceScope;
12-
import org.eclipse.swt.SWT;
12+
import org.eclipse.jface.dialogs.MessageDialog;
1313
import org.eclipse.swt.widgets.Display;
14-
import org.eclipse.swt.widgets.MessageBox;
15-
import org.eclipse.swt.widgets.Shell;
16-
import org.eclipse.ui.PlatformUI;
1714
import org.osgi.service.prefs.BackingStoreException;
1815

1916
/**
20-
* ArduinoPreferences is a class containing only static methods that help managing the preferences.
17+
* ArduinoPreferences is a class containing only static methods that help
18+
* managing the preferences.
2119
*
2220
* @author jan Baeyens
2321
*
@@ -46,17 +44,19 @@ public static void setAutomaticallyIncludeLibraries(boolean value) {
4644
}
4745

4846
/***
49-
* get the stored option whether a build before the upload is wanted or not. If nothing is stored the option is ask and this method will pop up a
47+
* get the stored option whether a build before the upload is wanted or not.
48+
* If nothing is stored the option is ask and this method will pop up a
5049
* dialogbox
5150
*
52-
* @return true if a build is wanted before upload false if no build is wanted before upload
51+
* @return true if a build is wanted before upload false if no build is
52+
* wanted before upload
5353
*/
5454
public static boolean getBuildBeforeUploadOption() {
5555

5656
switch (getGlobalString(KEY_BUILD_BEFORE_UPLOAD_OPTION, "ASK")) { //$NON-NLS-1$
57-
case "YES": //$NON-NLS-1$
57+
case Const.TRUE:
5858
return true;
59-
case "NO": //$NON-NLS-1$
59+
case Const.FALSE:
6060
return false;
6161
default:
6262
break;
@@ -70,17 +70,26 @@ boolean getAnswer() {
7070

7171
@Override
7272
public void run() {
73-
Shell theShell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
74-
MessageBox dialog = new MessageBox(theShell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
75-
dialog.setText(Messages.Build_before_upload);
76-
dialog.setMessage(Messages.do_you_want_to_build_before_upload);
73+
74+
MessageDialog dialog = new MessageDialog(null, Messages.Build_before_upload, null,
75+
Messages.do_you_want_to_build_before_upload, MessageDialog.QUESTION,
76+
new String[] { "Yes", "No", "Always", "Never" }, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
77+
7778
switch (dialog.open()) {
78-
case SWT.NO:
79+
case 0:
80+
this.ret = true;
81+
break;
82+
case 1:
7983
this.ret = false;
8084
break;
81-
case SWT.YES:
85+
case 2:
86+
setGlobalValue(KEY_BUILD_BEFORE_UPLOAD_OPTION, Const.TRUE);
8287
this.ret = true;
8388
break;
89+
case 3:
90+
setGlobalValue(KEY_BUILD_BEFORE_UPLOAD_OPTION, Const.FALSE);
91+
this.ret = false;
92+
break;
8493
default:
8594
this.ret = false;
8695
break;
@@ -93,7 +102,8 @@ public void run() {
93102
}
94103

95104
/**
96-
* This method reads the name of the last used arduino board from the instance preferences
105+
* This method reads the name of the last used arduino board from the
106+
* instance preferences
97107
*
98108
* @return the Arduino Board name
99109
* @author Jan Baeyens
@@ -173,7 +183,8 @@ public static void setGlobalValue(String key, String Value) {
173183
try {
174184
myScope.flush();
175185
} catch (BackingStoreException e) {
176-
Common.log(new Status(IStatus.WARNING, CORE_PLUGIN_ID, "failed to set global variable of type string " + key)); //$NON-NLS-1$
186+
Common.log(
187+
new Status(IStatus.WARNING, CORE_PLUGIN_ID, "failed to set global variable of type string " + key)); //$NON-NLS-1$
177188
e.printStackTrace();
178189
}
179190
}
@@ -195,7 +206,8 @@ protected static void setGlobalValue(String key, boolean Value) {
195206
try {
196207
myScope.flush();
197208
} catch (BackingStoreException e) {
198-
Common.log(new Status(IStatus.WARNING, CORE_PLUGIN_ID, "failed to set global variable of type boolean " + key)); //$NON-NLS-1$
209+
Common.log(new Status(IStatus.WARNING, CORE_PLUGIN_ID,
210+
"failed to set global variable of type boolean " + key)); //$NON-NLS-1$
199211
e.printStackTrace();
200212
}
201213
}
@@ -206,13 +218,15 @@ protected static void setGlobalValue(String key, long Value) {
206218
try {
207219
myScope.flush();
208220
} catch (BackingStoreException e) {
209-
Common.log(new Status(IStatus.WARNING, CORE_PLUGIN_ID, "failed to set global variable of type long " + key)); //$NON-NLS-1$
221+
Common.log(
222+
new Status(IStatus.WARNING, CORE_PLUGIN_ID, "failed to set global variable of type long " + key)); //$NON-NLS-1$
210223
e.printStackTrace();
211224
}
212225
}
213226

214227
/**
215-
* This method returns the index of the last used line ending options are CR LF CR+LF none
228+
* This method returns the index of the last used line ending options are CR
229+
* LF CR+LF none
216230
*
217231
* @return the index of the last used setting
218232
*/
@@ -221,7 +235,8 @@ public static int getLastUsedSerialLineEnd() {
221235
}
222236

223237
/**
224-
* This method returns the index of the last used line ending options are CR LF CR+LF none
238+
* This method returns the index of the last used line ending options are CR
239+
* LF CR+LF none
225240
*
226241
* @return the index of the last used setting
227242
*/
@@ -278,7 +293,8 @@ public static void setConfigured() {
278293
}
279294

280295
/**
281-
* This method returns boolean whether the plugin is properly configured The plugin is configured properly if a board has been installed
296+
* This method returns boolean whether the plugin is properly configured The
297+
* plugin is configured properly if a board has been installed
282298
*
283299
* @return
284300
*/
@@ -356,8 +372,8 @@ public static void setPrivateHardwarePaths(String[] folderName) {
356372
* @return a list of all the folder locations that can contain hardware
357373
*/
358374
public static String[] getHardwarePaths() {
359-
return (getGlobalString(KEY_PRIVATE_HARDWARE_PATHS, EMPTY_STRING) + File.pathSeparator + ConfigurationPreferences.getInstallationPath())
360-
.split(File.pathSeparator);
375+
return (getGlobalString(KEY_PRIVATE_HARDWARE_PATHS, EMPTY_STRING) + File.pathSeparator
376+
+ ConfigurationPreferences.getInstallationPath()).split(File.pathSeparator);
361377
}
362378

363379
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ 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.esp8266OTA={tools.esptool.network_cmd}
13+
tools.esp8266OTA.upload.pattern={tools.esptool.upload.network_pattern}
14+
esp8266.network.upload.tool=esp8266OTA
15+
TOOLS.ESPTOOL.NETWORK.PASSWORD={NETWORK.AUTH}

it.baeyens.arduino.core/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java renamed to it.baeyens.arduino.core/src/cc/arduino/packages/discoverers/ArduinoDNSTaskStarter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.app.zeroconf.jmdns;
1+
package cc.arduino.packages.discoverers;
22

33
import java.util.Timer;
44

0 commit comments

Comments
 (0)