Skip to content

Commit c0e50b6

Browse files
PaulStoffregenfacchinm
authored andcommitted
Move BoardPort fixed fields into prefs
1 parent 0c32fa3 commit c0e50b6

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,31 +33,25 @@
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;
3939
private String boardId;
40-
private String vid;
41-
private String pid;
42-
private String iserial;
43-
private String label;
44-
private final PreferencesMap prefs;
45-
private boolean online;
40+
private String label; // friendly name shown in Ports menu
41+
private final PreferencesMap prefs; // "vendorId", "productId", "serialNumber"
42+
private boolean online; // used by SerialBoardsLister (during upload??)
4643

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

5148
public BoardPort(BoardPort bp) {
52-
prefs = new PreferencesMap();
53-
// TODO: copy bp.prefs to prefs
49+
prefs = new PreferencesMap(bp.prefs);
5450
address = bp.address;
5551
protocol = bp.protocol;
5652
boardName = bp.boardName;
57-
vid = bp.vid;
58-
pid = bp.pid;
59-
iserial = bp.iserial;
6053
label = bp.label;
54+
online = bp.online;
6155
}
6256

6357
public String getAddress() {
@@ -113,27 +107,39 @@ public boolean isOnline() {
113107
}
114108

115109
public void setVIDPID(String vid, String pid) {
116-
this.vid = vid;
117-
this.pid = pid;
110+
if (vid == null) {
111+
prefs.remove("vendorId");
112+
} else {
113+
prefs.put("vendorId", vid);
114+
}
115+
if (pid == null) {
116+
prefs.remove("productId");
117+
} else {
118+
prefs.put("productId", pid);
119+
}
118120
}
119121

120122
public String getVID() {
121-
return vid;
123+
return prefs.get("vendorId");
122124
}
123125

124126
public String getPID() {
125-
return pid;
127+
return prefs.get("productId");
126128
}
127129

128130
public void setISerial(String iserial) {
129-
this.iserial = iserial;
131+
if (iserial == null) {
132+
prefs.remove("serialNumber");
133+
} else {
134+
prefs.put("serialNumber", iserial);
135+
}
130136
}
131137
public String getISerial() {
132-
return iserial;
138+
return prefs.get("serialNumber");
133139
}
134140

135141
@Override
136142
public String toString() {
137-
return this.address+"_"+this.vid+"_"+this.pid;
143+
return this.address+"_"+getVID()+"_"+getPID();
138144
}
139145
}

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)