Skip to content

Commit 4feb0af

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ARM
2 parents 576e882 + 767867b commit 4feb0af

35 files changed

+404
-215
lines changed

app/test/cc/arduino/i18n/ExternalProcessOutputParserTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,29 @@ public void testParser5() throws Exception {
9292
assertEquals("", args[0]);
9393
}
9494

95+
@Test
96+
public void testParser6() throws Exception {
97+
Map<String, Object> output = new ExternalProcessOutputParser().parse("===info ||| Progress {0} ||| [79.31]");
98+
99+
assertEquals("info", output.get("level"));
100+
assertEquals("Progress {0}", output.get("msg"));
101+
Object[] args = (Object[]) output.get("args");
102+
assertEquals(1, args.length);
103+
assertEquals("79.31", args[0]);
104+
}
105+
106+
@Test
107+
public void testParser7() throws Exception {
108+
Map<String, Object> output = new ExternalProcessOutputParser().parse("===info ||| Using library {0} at version {1} in folder: {2} {3} ||| [Bridge 1.6.0 %2Fhome%2Ffederico%2Fmateriale%2Fworks_Arduino%2FArduino%2Fbuild%2Flinux%2Fwork%2Flibraries%2FBridge ]");
109+
110+
assertEquals("info", output.get("level"));
111+
assertEquals("Using library {0} at version {1} in folder: {2} {3}", output.get("msg"));
112+
Object[] args = (Object[]) output.get("args");
113+
assertEquals(4, args.length);
114+
assertEquals("Bridge", args[0]);
115+
assertEquals("1.6.0", args[1]);
116+
assertEquals("/home/federico/materiale/works_Arduino/Arduino/build/linux/work/libraries/Bridge", args[2]);
117+
assertEquals("", args[3]);
118+
}
119+
95120
}

arduino-core/src/cc/arduino/Compiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public String build(CompilerProgressListener progListener, boolean exportHex) th
137137

138138
PreferencesMap prefs = loadPreferences(board, platform, aPackage, vidpid);
139139

140-
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out), progListener), "\n");
140+
MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out, System.err), progListener), "\n");
141141
MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.err, Compiler.this), "\n");
142142

143143
callArduinoBuilder(board, platform, aPackage, vidpid, BuilderAction.COMPILE, new PumpStreamHandler(out, err));

arduino-core/src/cc/arduino/ProgressAwareMessageConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ProgressAwareMessageConsumer(MessageConsumer parent, CompilerProgressList
4848

4949
@Override
5050
public void message(String s) {
51-
if (s.startsWith("===Progress")) {
51+
if (s.startsWith("===info ||| Progress") || s.startsWith("===Progress")) {
5252
Map<String, Object> parsedMessage = parser.parse(s);
5353
Object[] args = (Object[]) parsedMessage.get("args");
5454
progressListener.progress(Double.valueOf(args[0].toString()).intValue());

arduino-core/src/cc/arduino/i18n/ExternalProcessOutputParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ public Map<String, Object> parse(String s) {
5050

5151
String[] parts = SPLIT.split(s);
5252

53-
output.put("msg", parts[0]);
54-
output.put("args", parseArgs(parts[1]));
53+
int idx = 0;
54+
if (parts.length == 3) {
55+
output.put("level", parts[idx++]);
56+
}
57+
output.put("msg", parts[idx++]);
58+
output.put("args", parseArgs(parts[idx++]));
5559

5660
return output;
5761
}

arduino-core/src/cc/arduino/i18n/I18NAwareMessageConsumer.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,26 @@
3939

4040
public class I18NAwareMessageConsumer implements MessageConsumer {
4141

42-
private final PrintStream ps;
42+
private final PrintStream out;
43+
private final PrintStream err;
4344
private final MessageConsumer parent;
4445
private final ExternalProcessOutputParser parser;
4546

46-
public I18NAwareMessageConsumer(PrintStream ps) {
47-
this(ps, null);
47+
public I18NAwareMessageConsumer(PrintStream out) {
48+
this(out, out, null);
4849
}
4950

50-
public I18NAwareMessageConsumer(PrintStream ps, MessageConsumer parent) {
51-
this.ps = ps;
51+
public I18NAwareMessageConsumer(PrintStream out, MessageConsumer parent) {
52+
this(out, out, parent);
53+
}
54+
55+
public I18NAwareMessageConsumer(PrintStream out, PrintStream err) {
56+
this(out, err, null);
57+
}
58+
59+
public I18NAwareMessageConsumer(PrintStream out, PrintStream err, MessageConsumer parent) {
60+
this.out = out;
61+
this.err = err;
5262
this.parent = parent;
5363
this.parser = new ExternalProcessOutputParser();
5464
}
@@ -57,14 +67,19 @@ public I18NAwareMessageConsumer(PrintStream ps, MessageConsumer parent) {
5767
public void message(String s) {
5868
if (s.startsWith("===")) {
5969
Map<String, Object> parsedMessage = parser.parse(s);
60-
ps.println(I18n.format(tr((String) parsedMessage.get("msg")), (Object[]) parsedMessage.get("args")));
70+
String translatedMessage = I18n.format(tr((String) parsedMessage.get("msg")), (Object[]) parsedMessage.get("args"));
71+
if (!parsedMessage.containsKey("level") || "".equals(parsedMessage.get("level")) || "info".equals(parsedMessage.get("level"))) {
72+
out.println(translatedMessage);
73+
} else {
74+
err.println(translatedMessage);
75+
}
6176
return;
6277
}
6378

6479
if (parent != null) {
6580
parent.message(s);
6681
} else {
67-
ps.println(s);
82+
out.println(s);
6883
}
6984
}
7085
}

arduino-core/src/cc/arduino/packages/UploaderFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import cc.arduino.packages.uploaders.SSHUploader;
3333
import cc.arduino.packages.uploaders.SerialUploader;
34+
import cc.arduino.packages.uploaders.GenericNetworkUploader;
3435
import processing.app.debug.TargetBoard;
3536

3637
public class UploaderFactory {
@@ -41,6 +42,9 @@ public Uploader newUploader(TargetBoard board, BoardPort port, boolean noUploadP
4142
}
4243

4344
if (port != null && "network".equals(port.getProtocol())) {
45+
if(port.getPrefs().get("ssh_upload").contentEquals("no")){
46+
return new GenericNetworkUploader(port);
47+
}
4448
return new SSHUploader(port);
4549
}
4650

arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ public void serviceResolved(ServiceEvent serviceEvent) {
144144
port.getPrefs().put("board", board);
145145
port.getPrefs().put("distro_version", info.getPropertyString("distro_version"));
146146
port.getPrefs().put("port", "" + info.getPort());
147+
148+
//Add additional fields to permit generic ota updates
149+
//and make sure we do not intefere with Arduino boards
150+
// define "ssh_upload=no" TXT property to use generic uploader
151+
// define "tcp_check=no" TXT property if you are not using TCP
152+
// define "auth_upload=yes" TXT property if you want to use authenticated generic upload
153+
String useSSH = info.getPropertyString("ssh_upload");
154+
String checkTCP = info.getPropertyString("tcp_check");
155+
String useAuth = info.getPropertyString("auth_upload");
156+
if(useSSH == null || !useSSH.contentEquals("no")) useSSH = "yes";
157+
if(checkTCP == null || !checkTCP.contentEquals("no")) checkTCP = "yes";
158+
if(useAuth == null || !useAuth.contentEquals("yes")) useAuth = "no";
159+
port.getPrefs().put("ssh_upload", useSSH);
160+
port.getPrefs().put("tcp_check", checkTCP);
161+
port.getPrefs().put("auth_upload", useAuth);
147162
}
148163

149164
String label = name + " at " + address;

arduino-core/src/cc/arduino/packages/discoverers/network/BoardReachabilityFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void run() {
6969
ports.add(0, 22);
7070
}
7171

72-
boolean reachable = NetUtils.isReachable(inetAddress, ports);
72+
boolean reachable = board.getPrefs().get("tcp_check").contentEquals("no") || NetUtils.isReachable(inetAddress, ports);
7373
if (!reachable) {
7474
boardPortIterator.remove();
7575
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
GenericNetworkUploader - generic network uploader implementation
3+
makes possible to implement firmware updates over the air on any device
4+
Part of the Arduino project - http://www.arduino.cc/
5+
6+
Copyright (c) 2004-05
7+
Hernando Barragan
8+
Copyright (c) 2012
9+
Cristian Maglie <[email protected]>
10+
Copyright (c) 2015
11+
Hristo Gochkov <[email protected]>
12+
13+
This program is free software; you can redistribute it and/or modify
14+
it under the terms of the GNU General Public License as published by
15+
the Free Software Foundation; either version 2 of the License, or
16+
(at your option) any later version.
17+
18+
This program is distributed in the hope that it will be useful,
19+
but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
GNU General Public License for more details.
22+
23+
You should have received a copy of the GNU General Public License
24+
along with this program; if not, write to the Free Software Foundation,
25+
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26+
*/
27+
28+
package cc.arduino.packages.uploaders;
29+
30+
import cc.arduino.packages.BoardPort;
31+
import cc.arduino.packages.Uploader;
32+
import processing.app.*;
33+
import processing.app.debug.RunnerException;
34+
import processing.app.debug.TargetPlatform;
35+
import processing.app.helpers.PreferencesMap;
36+
import processing.app.helpers.StringReplacer;
37+
38+
import java.io.File;
39+
import java.util.List;
40+
41+
import static processing.app.I18n.tr;
42+
43+
public class GenericNetworkUploader extends Uploader {
44+
45+
private final BoardPort port;
46+
47+
public GenericNetworkUploader(BoardPort port) {
48+
this.port = port;
49+
}
50+
51+
public boolean requiresAuthorization() {
52+
return this.port.getPrefs().get("auth_upload").contentEquals("yes");
53+
}
54+
55+
@Override
56+
public String getAuthorizationKey() {
57+
return "runtime.pwd." + this.port.getAddress();
58+
}
59+
60+
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List<String> warningsAccumulator) throws Exception {
61+
TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
62+
PreferencesMap prefs = PreferencesData.getMap();
63+
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
64+
if (boardPreferences != null) {
65+
prefs.putAll(boardPreferences);
66+
}
67+
String tool = prefs.getOrExcept("upload.tool");
68+
if (tool.contains(":")) {
69+
String[] split = tool.split(":", 2);
70+
targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
71+
tool = split[1];
72+
}
73+
prefs.putAll(targetPlatform.getTool(tool));
74+
75+
String password = "";
76+
if(requiresAuthorization()){
77+
password = prefs.getOrExcept(getAuthorizationKey());
78+
}
79+
prefs.put("network.password", password);
80+
81+
prefs.put("network.port", this.port.getPrefs().get("port"));
82+
83+
prefs.put("build.path", buildPath);
84+
prefs.put("build.project_name", className);
85+
if (verbose) {
86+
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
87+
} else {
88+
prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
89+
}
90+
91+
boolean uploadResult;
92+
try {
93+
String pattern;
94+
//check if there is a separate pattern for network uploads
95+
pattern = prefs.get("upload.network_pattern");
96+
if(pattern == null)
97+
pattern = prefs.getOrExcept("upload.pattern");
98+
String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
99+
uploadResult = executeUploadCommand(cmd);
100+
} catch (RunnerException e) {
101+
throw e;
102+
} catch (Exception e) {
103+
throw new RunnerException(e);
104+
}
105+
return uploadResult;
106+
}
107+
108+
@Override
109+
public boolean burnBootloader() throws RunnerException {
110+
throw new RunnerException("Burning bootloader is not supported via network!");
111+
}
112+
}

arduino-core/src/processing/app/i18n/Resources_bg.po

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ msgstr ""
1818
"Project-Id-Version: Arduino IDE 1.5\n"
1919
"Report-Msgid-Bugs-To: \n"
2020
"POT-Creation-Date: 2012-03-29 10:24-0400\n"
21-
"PO-Revision-Date: 2015-11-26 11:18+0000\n"
22-
"Last-Translator: Ivaylo Malinov <mals@mail.bg>\n"
21+
"PO-Revision-Date: 2015-12-10 21:08+0000\n"
22+
"Last-Translator: Valentin Laskov <laskov@festa.bg>\n"
2323
"Language-Team: Bulgarian (http://www.transifex.com/mbanzi/arduino-ide-15/language/bg/)\n"
2424
"MIME-Version: 1.0\n"
2525
"Content-Type: text/plain; charset=UTF-8\n"
@@ -659,7 +659,7 @@ msgstr "Danish (Denmark)"
659659

660660
#: ../../../../../arduino-core/src/processing/app/I18n.java:36
661661
msgid "Data Processing"
662-
msgstr ""
662+
msgstr "Обработка на данни"
663663

664664
#: ../../../../../arduino-core/src/processing/app/I18n.java:35
665665
msgid "Data Storage"
@@ -1196,7 +1196,7 @@ msgstr "Намерена невалидна библиотека в {0}: {1}"
11961196
#: ../../../../../arduino-core/src/cc/arduino/Compiler.java:66
11971197
#, java-format
11981198
msgid "Invalid quoting: no closing [{0}] char found."
1199-
msgstr ""
1199+
msgstr "Невалиден текст: липсва затварящ [{0}] знак."
12001200

12011201
#: Preferences.java:102
12021202
msgid "Italian"
@@ -1220,11 +1220,11 @@ msgstr "Мениджър библиотеки"
12201220

12211221
#: ../../../../../app/src/processing/app/Base.java:2349
12221222
msgid "Library added to your libraries. Check \"Include library\" menu"
1223-
msgstr ""
1223+
msgstr "Библиотеката е добавена към Вашите библиотеки. Вижте менюто \"Включване на библиотека\""
12241224

12251225
#: ../../../../../arduino-core/src/cc/arduino/Compiler.java:73
12261226
msgid "Library can't use both 'src' and 'utility' folders. Double check {0}"
1227-
msgstr ""
1227+
msgstr "Библиотеката не може да ползва едновременно папките 'src' и 'utility'. Проверете отново {0}"
12281228

12291229
#: ../../../cc/arduino/contributions/libraries/LibraryInstaller.java:107
12301230
#, java-format
@@ -1246,7 +1246,7 @@ msgstr "Зареждане на конфигурацията..."
12461246
#: ../../../../../arduino-core/src/cc/arduino/Compiler.java:73
12471247
#, java-format
12481248
msgid "Looking for recipes like {0}*{1}"
1249-
msgstr ""
1249+
msgstr "Търсене на рецепти като {0}*{1}"
12501250

12511251
#: ../../../processing/app/Sketch.java:1684
12521252
msgid "Low memory available, stability problems may occur."
@@ -1271,7 +1271,7 @@ msgstr "Съобщение"
12711271
#: ../../../../../arduino-core/src/cc/arduino/Compiler.java:81
12721272
#, java-format
12731273
msgid "Missing '{0}' from library in {1}"
1274-
msgstr ""
1274+
msgstr "Липсващ '{0}' от библиотека в {1}"
12751275

12761276
#: ../../../processing/app/BaseNoGui.java:455
12771277
msgid "Mode not supported"
@@ -1296,7 +1296,7 @@ msgstr "Множество файлове не се поддържат"
12961296
#: ../../../processing/app/debug/Compiler.java:520
12971297
#, java-format
12981298
msgid "Multiple libraries were found for \"{0}\""
1299-
msgstr ""
1299+
msgstr "Намерени са няколко библиотеки за \"{0}\""
13001300

13011301
#: ../../../processing/app/Base.java:395
13021302
msgid "Must specify exactly one sketch file"
@@ -1344,7 +1344,7 @@ msgstr "Не"
13441344

13451345
#: ../../../processing/app/debug/Compiler.java:158
13461346
msgid "No authorization data found"
1347-
msgstr ""
1347+
msgstr "Не са намерени данни за удостоверяване"
13481348

13491349
#: tools/format/src/AutoFormat.java:54 tools/AutoFormat.java:916
13501350
msgid "No changes necessary for Auto Format."
@@ -1356,7 +1356,7 @@ msgstr "Не са намерени параметри в командния ре
13561356

13571357
#: ../../../processing/app/debug/Compiler.java:200
13581358
msgid "No compiled sketch found"
1359-
msgstr ""
1359+
msgstr "Не е намерена компилирана скица"
13601360

13611361
#: Editor.java:373
13621362
msgid "No files were added to the sketch."
@@ -1487,11 +1487,11 @@ msgstr "Платформа {0} (пакет {1}) е непознат"
14871487

14881488
#: ../../../../../app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java:195
14891489
msgid "Please confirm boards deletion"
1490-
msgstr ""
1490+
msgstr "Моля, потвърдете изтриването на платката"
14911491

14921492
#: ../../../../../app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java:257
14931493
msgid "Please confirm library deletion"
1494-
msgstr ""
1494+
msgstr "Моля, потвърдете изтриването на библиотеката"
14951495

14961496
#: debug/Compiler.java:408
14971497
msgid "Please import the SPI library from the Sketch > Import Library menu."
@@ -1536,7 +1536,7 @@ msgstr "Предпочитания"
15361536

15371537
#: ../../../../../app/src/processing/app/Base.java:297
15381538
msgid "Preparing boards..."
1539-
msgstr ""
1539+
msgstr "Подготовка на платки..."
15401540

15411541
#: FindReplace.java:123 FindReplace.java:128
15421542
msgid "Previous"
@@ -1603,7 +1603,7 @@ msgstr "Програматор"
16031603
#: ../../../../../arduino-core/src/cc/arduino/Compiler.java:80
16041604
#, java-format
16051605
msgid "Progress {0}"
1606-
msgstr ""
1606+
msgstr "Напредък {0}"
16071607

16081608
#: Base.java:783 Editor.java:593
16091609
msgid "Quit"

0 commit comments

Comments
 (0)