mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Fixed NPE in case of missing boardData
This commit is contained in:
parent
c287450d72
commit
32123a8cb9
@ -38,6 +38,7 @@ import processing.app.debug.TargetBoard;
|
|||||||
import processing.app.helpers.PreferencesMap;
|
import processing.app.helpers.PreferencesMap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -61,21 +62,26 @@ public class SerialDiscovery implements Discovery {
|
|||||||
|
|
||||||
for (String port : ports) {
|
for (String port : ports) {
|
||||||
Map<String, Object> boardData = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
|
Map<String, Object> boardData = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
|
||||||
TargetBoard board = (TargetBoard) boardData.get("board");
|
|
||||||
|
|
||||||
BoardPort boardPort = new BoardPort();
|
BoardPort boardPort = new BoardPort();
|
||||||
boardPort.setAddress(port);
|
boardPort.setAddress(port);
|
||||||
boardPort.setProtocol("serial");
|
boardPort.setProtocol("serial");
|
||||||
|
|
||||||
|
String label = port;
|
||||||
|
|
||||||
PreferencesMap prefs = new PreferencesMap();
|
PreferencesMap prefs = new PreferencesMap();
|
||||||
|
|
||||||
|
if (boardData != null) {
|
||||||
prefs.put("vid", boardData.get("vid").toString());
|
prefs.put("vid", boardData.get("vid").toString());
|
||||||
prefs.put("pid", boardData.get("pid").toString());
|
prefs.put("pid", boardData.get("pid").toString());
|
||||||
|
|
||||||
|
TargetBoard board = (TargetBoard) boardData.get("board");
|
||||||
|
if (board != null) {
|
||||||
String warningKey = "vid." + boardData.get("vid").toString() + ".warning";
|
String warningKey = "vid." + boardData.get("vid").toString() + ".warning";
|
||||||
String warning = board.getPreferences().get(warningKey);
|
String warning = board.getPreferences().get(warningKey);
|
||||||
prefs.put("warning", warning);
|
prefs.put("warning", warning);
|
||||||
|
|
||||||
String boardName = board.getName();
|
String boardName = board.getName();
|
||||||
String label = port;
|
|
||||||
if (boardName != null) {
|
if (boardName != null) {
|
||||||
if (warning != null) {
|
if (warning != null) {
|
||||||
label += " (" + boardName + " - " + _(warning) + ")";
|
label += " (" + boardName + " - " + _(warning) + ")";
|
||||||
@ -84,9 +90,10 @@ public class SerialDiscovery implements Discovery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
boardPort.setBoardName(boardName);
|
boardPort.setBoardName(boardName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boardPort.setLabel(label);
|
boardPort.setLabel(label);
|
||||||
|
|
||||||
|
|
||||||
boardPort.setPrefs(prefs);
|
boardPort.setPrefs(prefs);
|
||||||
|
|
||||||
res.add(boardPort);
|
res.add(boardPort);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user