Skip to content

Commit 05092bf

Browse files
PaulStoffregencmaglie
authored andcommitted
Move BoardPort fixed fields into prefs
1 parent e029acc commit 05092bf

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

arduino-core/src/cc/arduino/packages/BoardPort.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,24 @@
3333

3434
public class BoardPort {
3535

36-
private String address;
37-
private String protocol;
36+
private String address; // unique name for this port, used by Preferences
37+
private String protocol; // how to communicate, used for Ports menu sections
3838
private String boardName;
39-
private String vid;
40-
private String pid;
41-
private String iserial;
42-
private String label;
43-
private final PreferencesMap prefs;
44-
private boolean online;
39+
private String label; // friendly name shown in Ports menu
40+
private final PreferencesMap prefs; // "vendorId", "productId", "serialNumber"
41+
private boolean online; // used by SerialBoardsLister (during upload??)
4542

4643
public BoardPort() {
4744
this.prefs = new PreferencesMap();
4845
}
4946

5047
public BoardPort(BoardPort bp) {
51-
prefs = new PreferencesMap();
52-
// TODO: copy bp.prefs to prefs
48+
prefs = new PreferencesMap(bp.prefs);
5349
address = bp.address;
5450
protocol = bp.protocol;
5551
boardName = bp.boardName;
56-
vid = bp.vid;
57-
pid = bp.pid;
58-
iserial = bp.iserial;
5952
label = bp.label;
53+
online = bp.online;
6054
}
6155

6256
public String getAddress() {
@@ -104,27 +98,39 @@ public boolean isOnline() {
10498
}
10599

106100
public void setVIDPID(String vid, String pid) {
107-
this.vid = vid;
108-
this.pid = pid;
101+
if (vid == null) {
102+
prefs.remove("vendorId");
103+
} else {
104+
prefs.put("vendorId", vid);
105+
}
106+
if (pid == null) {
107+
prefs.remove("productId");
108+
} else {
109+
prefs.put("productId", pid);
110+
}
109111
}
110112

111113
public String getVID() {
112-
return vid;
114+
return prefs.get("vendorId");
113115
}
114116

115117
public String getPID() {
116-
return pid;
118+
return prefs.get("productId");
117119
}
118120

119121
public void setISerial(String iserial) {
120-
this.iserial = iserial;
122+
if (iserial == null) {
123+
prefs.remove("serialNumber");
124+
} else {
125+
prefs.put("serialNumber", iserial);
126+
}
121127
}
122128
public String getISerial() {
123-
return iserial;
129+
return prefs.get("serialNumber");
124130
}
125131

126132
@Override
127133
public String toString() {
128-
return this.address+"_"+this.vid+"_"+this.pid;
134+
return this.address+"_"+getVID()+"_"+getPID();
129135
}
130136
}

arduino-core/src/cc/arduino/packages/discoverers/PluggableDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void run() {
7474
while (program != null && program.isAlive()) {
7575
PluggableDiscoveryMessage msg = mapper.readValue(parser, PluggableDiscoveryMessage.class);
7676
if (msg != null) {
77-
System.out.println(discoveryName + ": received json");
77+
System.out.println(discoveryName + ": received json: vid=" + msg.getVID() + ", pid=" + msg.getPID() + ", sernum=" + msg.getISerial());
7878
String event = msg.getEventType();
7979
if (event != null) {
8080
if (event.equals("Error: START_SYNC not supported")) {

0 commit comments

Comments
 (0)