mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Block discovery threads until packages is not null, otherwise boards discovered during startup will miss model name
This commit is contained in:
parent
350adb99cb
commit
eacddd6120
@ -45,6 +45,8 @@ import java.util.*;
|
||||
|
||||
public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.packages.discoverers.network.NetworkTopologyListener {
|
||||
|
||||
private static final int MAX_TIME_AWAITING_FOR_PACKAGES = 5000;
|
||||
|
||||
private final List<BoardPort> boardPortsDiscoveredWithJmDNS;
|
||||
private final Map<InetAddress, JmDNS> mappedJmDNSs;
|
||||
private Timer networkCheckerTimer;
|
||||
@ -121,6 +123,16 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
|
||||
|
||||
@Override
|
||||
public void serviceResolved(ServiceEvent serviceEvent) {
|
||||
int sleptFor = 0;
|
||||
while (BaseNoGui.packages == null && sleptFor <= MAX_TIME_AWAITING_FOR_PACKAGES) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
sleptFor += 1000;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ServiceInfo info = serviceEvent.getInfo();
|
||||
for (InetAddress inetAddress : info.getInet4Addresses()) {
|
||||
String address = inetAddress.getHostAddress();
|
||||
|
@ -43,6 +43,8 @@ import static processing.app.I18n._;
|
||||
|
||||
public class SerialBoardsLister extends TimerTask {
|
||||
|
||||
private static final int MAX_TIME_AWAITING_FOR_PACKAGES = 5000;
|
||||
|
||||
private final SerialDiscovery serialDiscovery;
|
||||
|
||||
public SerialBoardsLister(SerialDiscovery serialDiscovery) {
|
||||
@ -55,8 +57,14 @@ public class SerialBoardsLister extends TimerTask {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (BaseNoGui.packages == null) {
|
||||
return;
|
||||
int sleptFor = 0;
|
||||
while (BaseNoGui.packages == null && sleptFor <= MAX_TIME_AWAITING_FOR_PACKAGES) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
sleptFor += 1000;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Platform platform = BaseNoGui.getPlatform();
|
||||
|
Loading…
x
Reference in New Issue
Block a user