Skip to content

Commit 7e7f407

Browse files
committed
Oscilloscope will now connect to open monitor. Fixed plenty of warnings
1 parent 1a66fb9 commit 7e7f407

File tree

14 files changed

+177
-139
lines changed

14 files changed

+177
-139
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
bin.includes = META-INF/
1+
bin.includes = META-INF/,\
2+
OSGI-INF/

it.baeyens.arduino.core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public void serviceAdded(ServiceEvent serviceEvent) {
137137
String type = serviceEvent.getType();
138138
String name = serviceEvent.getName();
139139

140+
@SuppressWarnings("resource")
140141
JmDNS dns = serviceEvent.getDNS();
141142

142143
dns.requestServiceInfo(type, name);
@@ -201,6 +202,7 @@ public void inetAddressAdded(InetAddress address) {
201202
return;
202203
}
203204
try {
205+
@SuppressWarnings("resource")
204206
JmDNS jmDNS = JmDNS.create(address);
205207
jmDNS.addServiceListener("_arduino._tcp.local.", this);
206208
mappedJmDNSs.put(address, jmDNS);

it.baeyens.arduino.core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,40 @@
44

55
public class NoInteractionUserInfo implements UserInfo {
66

7-
private final String password;
8-
9-
public NoInteractionUserInfo(String password) {
10-
this.password = password;
11-
}
12-
13-
public String getPassword() {
14-
return password;
15-
}
16-
17-
public boolean promptYesNo(String str) {
18-
return true;
19-
}
20-
21-
public String getPassphrase() {
22-
return password;
23-
}
24-
25-
public boolean promptPassphrase(String message) {
26-
return true;
27-
}
28-
29-
public boolean promptPassword(String message) {
30-
return true;
31-
}
32-
33-
public void showMessage(String message) {
34-
}
7+
private final String password;
8+
9+
public NoInteractionUserInfo(String password) {
10+
this.password = password;
11+
}
12+
13+
@Override
14+
public String getPassword() {
15+
return password;
16+
}
17+
18+
@Override
19+
public boolean promptYesNo(String str) {
20+
return true;
21+
}
22+
23+
@Override
24+
public String getPassphrase() {
25+
return password;
26+
}
27+
28+
@Override
29+
public boolean promptPassphrase(String message) {
30+
return true;
31+
}
32+
33+
@Override
34+
public boolean promptPassword(String message) {
35+
return true;
36+
}
37+
38+
@Override
39+
public void showMessage(String message) {
40+
// no code needed here
41+
}
3542

3643
}

it.baeyens.arduino.core/src/cc/arduino/packages/ssh/SSH.java

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -29,86 +29,88 @@
2929

3030
package cc.arduino.packages.ssh;
3131

32+
import java.io.IOException;
33+
import java.io.InputStream;
34+
import java.io.PrintStream;
35+
3236
import com.jcraft.jsch.Channel;
3337
import com.jcraft.jsch.ChannelExec;
3438
import com.jcraft.jsch.JSchException;
3539
import com.jcraft.jsch.Session;
3640

37-
import java.io.IOException;
38-
import java.io.InputStream;
39-
import java.io.PrintStream;
40-
4141
public class SSH {
4242

43-
protected final Session session;
44-
45-
public SSH(Session session) {
46-
this.session = session;
47-
}
43+
protected final Session session;
4844

49-
public boolean execSyncCommand(String command) throws JSchException, IOException {
50-
return execSyncCommand(command, null, null);
51-
}
52-
53-
public boolean execSyncCommand(String command, PrintStream stdoutConsumer, PrintStream stderrConsumer) throws JSchException, IOException {
54-
InputStream stdout = null;
55-
InputStream stderr = null;
56-
Channel channel = null;
57-
try {
58-
channel = session.openChannel("exec");
59-
((ChannelExec) channel).setCommand(command);
60-
61-
channel.setInputStream(null);
62-
63-
stdout = channel.getInputStream();
64-
stderr = ((ChannelExec) channel).getErrStream();
65-
66-
channel.connect();
67-
68-
int exitCode = consumeOutputSyncAndReturnExitCode(channel, stdout, stdoutConsumer, stderr, stderrConsumer);
45+
public SSH(Session session) {
46+
this.session = session;
47+
}
6948

70-
return exitCode == 0;
49+
public boolean execSyncCommand(String command) throws JSchException, IOException {
50+
return execSyncCommand(command, null, null);
51+
}
7152

72-
} finally {
73-
if (stdout != null) {
74-
stdout.close();
75-
}
76-
if (stderr != null) {
77-
stderr.close();
78-
}
79-
if (channel != null) {
80-
channel.disconnect();
81-
}
53+
@SuppressWarnings("resource")
54+
public boolean execSyncCommand(String command, PrintStream stdoutConsumer, PrintStream stderrConsumer) throws JSchException, IOException {
55+
InputStream stdout = null;
56+
InputStream stderr = null;
57+
Channel channel = null;
58+
try {
59+
channel = session.openChannel("exec");
60+
((ChannelExec) channel).setCommand(command);
61+
62+
channel.setInputStream(null);
63+
64+
stdout = channel.getInputStream();
65+
stderr = ((ChannelExec) channel).getErrStream();
66+
67+
channel.connect();
68+
69+
int exitCode = consumeOutputSyncAndReturnExitCode(channel, stdout, stdoutConsumer, stderr, stderrConsumer);
70+
71+
return exitCode == 0;
72+
73+
} finally {
74+
if (stdout != null) {
75+
stdout.close();
76+
}
77+
if (stderr != null) {
78+
stderr.close();
79+
}
80+
if (channel != null) {
81+
channel.disconnect();
82+
}
83+
}
8284
}
83-
}
84-
85-
protected int consumeOutputSyncAndReturnExitCode(Channel channel, InputStream stdout, PrintStream stdoutConsumer, InputStream stderr, PrintStream stderrConsumer) throws IOException {
86-
byte[] tmp = new byte[102400];
87-
while (true) {
88-
consumeStream(tmp, stdout, stdoutConsumer);
89-
consumeStream(tmp, stderr, stderrConsumer);
90-
91-
if (channel.isClosed()) {
92-
return channel.getExitStatus();
93-
}
94-
try {
95-
Thread.sleep(100);
96-
} catch (Exception ee) {
97-
// noop
98-
}
85+
86+
protected static int consumeOutputSyncAndReturnExitCode(Channel channel, InputStream stdout, PrintStream stdoutConsumer, InputStream stderr,
87+
PrintStream stderrConsumer) throws IOException {
88+
byte[] tmp = new byte[102400];
89+
while (true) {
90+
consumeStream(tmp, stdout, stdoutConsumer);
91+
consumeStream(tmp, stderr, stderrConsumer);
92+
93+
if (channel.isClosed()) {
94+
return channel.getExitStatus();
95+
}
96+
try {
97+
Thread.sleep(100);
98+
} catch (Exception ee) {
99+
// noop
100+
}
101+
}
99102
}
100-
}
101-
102-
protected void consumeStream(byte[] buffer, InputStream in, PrintStream out) throws IOException {
103-
while (in.available() > 0) {
104-
int length = in.read(buffer, 0, buffer.length);
105-
if (length < 0) {
106-
break;
107-
}
108-
if (out != null) {
109-
out.print(new String(buffer, 0, length));
110-
}
103+
104+
protected static void consumeStream(byte[] buffer, InputStream in, PrintStream out) throws IOException {
105+
while (in.available() > 0) {
106+
int length = in.read(buffer, 0, buffer.length);
107+
if (length < 0) {
108+
break;
109+
}
110+
if (out != null) {
111+
out.print(new String(buffer, 0, length));
112+
}
113+
}
111114
}
112-
}
113115

114116
}

it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoGnuMakefileGenerator.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,10 +1256,10 @@ private StringBuffer addMacros() {
12561256
buffer.append(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(SRC_LISTS) + NEWLINE);
12571257
buffer.append("-include sources.mk" + NEWLINE); //$NON-NLS-1$
12581258

1259-
//Change the include of the "root" (our sketch) folder to be before libraries and other files
1260-
//When it is after it is different to the Arduino IDE and can cause linking/combining issues
1259+
// Change the include of the "root" (our sketch) folder to be before libraries and other files
1260+
// When it is after it is different to the Arduino IDE and can cause linking/combining issues
12611261
buffer.append("-include subdir.mk" + NEWLINE); //$NON-NLS-1$
1262-
1262+
12631263
// Add includes for each subdir in child-subdir-first order (required
12641264
// for makefile rule matching to work).
12651265
List<String> subDirList = new ArrayList<String>();
@@ -1273,7 +1273,7 @@ private StringBuffer addMacros() {
12731273
buffer.append("-include " + escapeWhitespaces(dir) + SEPARATOR + "subdir.mk" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
12741274
}
12751275

1276-
//Change the include of the "root" (our sketch) folder to be before libraries and other files
1276+
// Change the include of the "root" (our sketch) folder to be before libraries and other files
12771277
//buffer.append("-include subdir.mk" + NEWLINE); //$NON-NLS-1$
12781278

12791279
buffer.append("-include objects.mk" + NEWLINE + NEWLINE); //$NON-NLS-1$
@@ -2272,8 +2272,9 @@ protected IPath getPathForResource(IResource resource) {
22722272
* @param generatedSource
22732273
* if <code>true</code>, this file was generated by another tool in the tool-chain
22742274
*/
2275-
protected void addToBuildVar(LinkedHashMap<String, String> buildVarToRuleStringMap, String ext, String varName, String relativePath,
2275+
protected void addToBuildVar(LinkedHashMap<String, String> buildVarToRuleStringMap, String ext, String _varName, String relativePath,
22762276
IPath sourceLocation, boolean generatedSource) {
2277+
String varName = _varName;
22772278
List<IPath> varList = null;
22782279
if (varName == null) {
22792280
// Get the proper source build variable based upon the extension
@@ -2978,7 +2979,7 @@ private String[] addDependencyOptions(IManagedDependencyCommands depCommands, St
29782979
for (int i = 0; i < depOptions.length; i++) {
29792980
flagsCopy[i + flagsLen] = depOptions[i];
29802981
}
2981-
flags = flagsCopy;
2982+
return flagsCopy;
29822983
}
29832984
return flags;
29842985
}
@@ -3849,7 +3850,8 @@ protected void addMacroAdditionPrefix(LinkedHashMap<String, String> map, String
38493850
* Adds a file to an entry in a map of macro names to entries. File additions look like: example.c, \
38503851
*/
38513852
@SuppressWarnings("static-method")
3852-
protected void addMacroAdditionFile(HashMap<String, String> map, String macroName, String filename) {
3853+
protected void addMacroAdditionFile(HashMap<String, String> map, String macroName, String _filename) {
3854+
String filename = _filename;
38533855
StringBuffer buffer = new StringBuffer();
38543856
buffer.append(map.get(macroName));
38553857

@@ -4638,8 +4640,9 @@ public static String ensureUnquoted(String path) {
46384640
}
46394641

46404642
@SuppressWarnings("hiding")
4641-
@Override
4642-
public void initialize(int buildKind, IConfiguration cfg, IBuilder builder, IProgressMonitor monitor) {
4643+
@Override
4644+
public void initialize(int buildKind, IConfiguration cfg, IBuilder _builder, IProgressMonitor monitor) {
4645+
IBuilder builder = _builder;
46434646
// Save the project so we can get path and member information
46444647
this.project = cfg.getOwner().getProject();
46454648
if (builder == null) {
@@ -4727,7 +4730,8 @@ private ToolInfoHolder getToolInfo(IPath path) {
47274730
return getToolInfo(path, false);
47284731
}
47294732

4730-
private ToolInfoHolder getFolderToolInfo(IPath path) {
4733+
private ToolInfoHolder getFolderToolInfo(IPath _path) {
4734+
IPath path = _path;
47314735
IResourceInfo rcInfo = config.getResourceInfo(path, false);
47324736
while (rcInfo instanceof IFileInfo) {
47334737
path = path.removeLastSegments(1);

it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoManagedBuildGnuToolInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*
4747
* @noextend This class is not intended to be subclassed by clients.
4848
*/
49-
@SuppressWarnings({ "restriction" })
49+
@SuppressWarnings({ "restriction", "deprecation" })
5050
public class ArduinoManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
5151

5252
/*
@@ -840,8 +840,8 @@ public boolean calculateOutputs(ArduinoGnuMakefileGenerator makeGen, IConfigurat
840840

841841
private boolean callDependencyCalculator(ArduinoGnuMakefileGenerator makeGen, IConfiguration config, HashSet<String> handledInputExtensions,
842842
IManagedDependencyGeneratorType depGen, String[] extensionsList, Vector<String> myCommandDependencies,
843-
HashMap<String, List<IPath>> myOutputMacros, Vector<String> myAdditionalTargets, ToolInfoHolder h, boolean done) {
844-
843+
HashMap<String, List<IPath>> myOutputMacros, Vector<String> myAdditionalTargets, ToolInfoHolder h, boolean _done) {
844+
boolean done = _done;
845845
int calcType = depGen.getCalculatorType();
846846
switch (calcType) {
847847
case IManagedDependencyGeneratorType.TYPE_COMMAND:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ private static String collapseBraces(String in) {
321321
return buffer.toString();
322322
}
323323

324-
private static ArrayList<String> prototypes(String in) {
325-
in = collapseBraces(strip(in));
324+
private static ArrayList<String> prototypes(String _in) {
325+
String in = collapseBraces(strip(_in));
326326

327327
// XXX: doesn't handle ... varargs
328328
// XXX: doesn't handle function pointers

it.baeyens.arduino.core/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public void startCanceler() {
6464
public void startReaper() {
6565
new RecordReaper(jmDNSImpl) {
6666
@Override
67-
public void start(Timer timer) {
67+
public void start(Timer _timer) {
6868
if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) {
69-
timer.schedule(this, 0, 500);
69+
_timer.schedule(this, 0, 500);
7070
}
7171
}
7272
}.start(timer);

it.baeyens.arduino.feature/feature.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,5 @@ If you do not agree with this policy, then please do not install this software.
174174
version="0.0.0"
175175
fragment="true"/>
176176

177-
<plugin
178-
id="it.baeyens.arduino.application"
179-
download-size="0"
180-
install-size="0"
181-
version="0.0.0"/>
182177

183178
</feature>

0 commit comments

Comments
 (0)