1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-01 23:29:28 +01:00

PluggableDiscovery check for START_SYNC not supported

This commit is contained in:
PaulStoffregen 2018-09-29 00:07:37 -07:00 committed by Cristian Maglie
parent 5ba56abc80
commit b6066573b9

View File

@ -56,7 +56,7 @@ public class PluggableDiscovery implements Discovery {
this.cmd = cmd; this.cmd = cmd;
this.discoveryName = discoveryName; this.discoveryName = discoveryName;
portList = new LinkedList<>(); portList = new LinkedList<>();
System.out.println("Starting: " + PApplet.join(cmd, " ")); System.out.println(discoveryName + ": Starting: " + PApplet.join(cmd, " "));
} }
@Override @Override
@ -74,19 +74,25 @@ public class PluggableDiscovery implements Discovery {
while (program != null && program.isAlive()) { while (program != null && program.isAlive()) {
BoardPort port = mapper.readValue(parser, BoardPort.class); BoardPort port = mapper.readValue(parser, BoardPort.class);
if (port != null) { if (port != null) {
System.out.println(discoveryName + " received json"); System.out.println(discoveryName + ": received json");
// String address = port.getAddress();
// TODO: check for START_SYNC not supported, call startPolling() if (address != null) {
// if (address.equals("Error: START_SYNC not supported")) {
if (pollingThread == null) {
startPolling();
}
} else {
update(port); update(port);
} }
} }
System.out.println("thread exit normally"); }
}
System.out.println(discoveryName + ": thread exit normally");
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println("thread exit by interrupt"); System.out.println(discoveryName + ": thread exit by interrupt");
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
System.out.println("thread exit other exception"); System.out.println(discoveryName + ": thread exit other exception");
e.printStackTrace(); e.printStackTrace();
} }
try { try {
@ -160,9 +166,6 @@ public class PluggableDiscovery implements Discovery {
// avoid changing the list while it's being accessed by // avoid changing the list while it's being accessed by
// another thread. // another thread.
String address = port.getAddress(); String address = port.getAddress();
if (address == null) {
return; // address is required
}
for (BoardPort bp : portList) { for (BoardPort bp : portList) {
if (address.equals(bp.getAddress())) { if (address.equals(bp.getAddress())) {
// if address already on the list, discard old info // if address already on the list, discard old info
@ -191,8 +194,7 @@ public class PluggableDiscovery implements Discovery {
// a clean copy. // a clean copy.
final List<BoardPort> portListCopy = new ArrayList<>(); final List<BoardPort> portListCopy = new ArrayList<>();
for (BoardPort bp : portList) { for (BoardPort bp : portList) {
//portListCopy.add(new BoardPort(bp)); portListCopy.add(new BoardPort(bp));
portListCopy.add(bp);
} }
return portListCopy; return portListCopy;
} }