mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
LoadVIDPIDSpecificPreferences was giving for granted that the attached board provided VID & PID. This is not always true, especially with counterfeits. Fixes #3738
This commit is contained in:
parent
ece6500967
commit
f2427b47f0
@ -30,6 +30,7 @@
|
||||
package cc.arduino;
|
||||
|
||||
import cc.arduino.packages.BoardPort;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.PreferencesData;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
@ -45,7 +46,13 @@ public class LoadVIDPIDSpecificPreferences {
|
||||
return;
|
||||
}
|
||||
|
||||
int VIDPIDIndex = findVIDPIDIndex(prefs, boardPort.getPrefs().get("vid").toUpperCase(), boardPort.getPrefs().get("pid").toUpperCase());
|
||||
String vid = boardPort.getPrefs().get("vid");
|
||||
String pid = boardPort.getPrefs().get("pid");
|
||||
if (StringUtils.isEmpty(vid) || StringUtils.isEmpty(pid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int VIDPIDIndex = findVIDPIDIndex(prefs, vid.toUpperCase(), pid.toUpperCase());
|
||||
if (VIDPIDIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -37,7 +37,11 @@ public class BoardPort {
|
||||
private String protocol;
|
||||
private String boardName;
|
||||
private String label;
|
||||
private PreferencesMap prefs;
|
||||
private final PreferencesMap prefs;
|
||||
|
||||
public BoardPort() {
|
||||
this.prefs = new PreferencesMap();
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
@ -63,10 +67,6 @@ public class BoardPort {
|
||||
this.boardName = boardName;
|
||||
}
|
||||
|
||||
public void setPrefs(PreferencesMap prefs) {
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
public PreferencesMap getPrefs() {
|
||||
return prefs;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import cc.arduino.packages.discoverers.network.BoardReachabilityFilter;
|
||||
import cc.arduino.packages.discoverers.network.NetworkChecker;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.zeroconf.jmdns.ArduinoDNSTaskStarter;
|
||||
|
||||
import javax.jmdns.*;
|
||||
@ -135,16 +134,16 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
|
||||
String address = inetAddress.getHostAddress();
|
||||
String name = serviceEvent.getName();
|
||||
|
||||
PreferencesMap prefs = null;
|
||||
BoardPort port = new BoardPort();
|
||||
|
||||
String board = null;
|
||||
String description = null;
|
||||
if (info.hasData()) {
|
||||
prefs = new PreferencesMap();
|
||||
board = info.getPropertyString("board");
|
||||
description = info.getPropertyString("description");
|
||||
prefs.put("board", board);
|
||||
prefs.put("distro_version", info.getPropertyString("distro_version"));
|
||||
prefs.put("port", "" + info.getPort());
|
||||
port.getPrefs().put("board", board);
|
||||
port.getPrefs().put("distro_version", info.getPropertyString("distro_version"));
|
||||
port.getPrefs().put("port", "" + info.getPort());
|
||||
}
|
||||
|
||||
String label = name + " at " + address;
|
||||
@ -157,11 +156,9 @@ public class NetworkDiscovery implements Discovery, ServiceListener, cc.arduino.
|
||||
label += " (" + description + ")";
|
||||
}
|
||||
|
||||
BoardPort port = new BoardPort();
|
||||
port.setAddress(address);
|
||||
port.setBoardName(name);
|
||||
port.setProtocol("network");
|
||||
port.setPrefs(prefs);
|
||||
port.setLabel(label);
|
||||
|
||||
synchronized (boardPortsDiscoveredWithJmDNS) {
|
||||
|
@ -35,7 +35,6 @@ import processing.app.BaseNoGui;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Serial;
|
||||
import processing.app.debug.TargetBoard;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -84,11 +83,9 @@ public class SerialBoardsLister extends TimerTask {
|
||||
|
||||
String label = port;
|
||||
|
||||
PreferencesMap prefs = new PreferencesMap();
|
||||
|
||||
if (boardData != null) {
|
||||
prefs.put("vid", boardData.get("vid").toString());
|
||||
prefs.put("pid", boardData.get("pid").toString());
|
||||
boardPort.getPrefs().put("vid", boardData.get("vid").toString());
|
||||
boardPort.getPrefs().put("pid", boardData.get("pid").toString());
|
||||
|
||||
TargetBoard board = (TargetBoard) boardData.get("board");
|
||||
if (board != null) {
|
||||
@ -101,7 +98,6 @@ public class SerialBoardsLister extends TimerTask {
|
||||
}
|
||||
|
||||
boardPort.setLabel(label);
|
||||
boardPort.setPrefs(prefs);
|
||||
|
||||
boardPorts.add(boardPort);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user