Skip to content

Commit 3c16ac0

Browse files
committed
Add iSerial to reported VID_PID string
serial.port.iserial holds the iSerial value
1 parent 00ba7aa commit 3c16ac0

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

arduino-core/src/cc/arduino/packages/discoverers/serial/SerialBoardsLister.java

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void run() {
8686
if (boardData != null) {
8787
boardPort.getPrefs().put("vid", boardData.get("vid").toString());
8888
boardPort.getPrefs().put("pid", boardData.get("pid").toString());
89+
boardPort.getPrefs().put("iserial", boardData.get("iserial").toString());
8990

9091
TargetBoard board = (TargetBoard) boardData.get("board");
9192
if (board != null) {

arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import cc.arduino.LoadVIDPIDSpecificPreferences;
3838
import cc.arduino.packages.Uploader;
3939
import processing.app.*;
40+
import cc.arduino.packages.BoardPort;
4041
import processing.app.debug.RunnerException;
4142
import processing.app.debug.TargetPlatform;
4243
import processing.app.helpers.OSUtils;
@@ -152,6 +153,11 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
152153
}
153154
}
154155

156+
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
157+
if (boardPort.getPrefs().get("iserial") != null) {
158+
prefs.put("serial.port.iserial", boardPort.getPrefs().get("iserial"));
159+
}
160+
155161
prefs.put("build.path", buildPath);
156162
prefs.put("build.project_name", className);
157163
if (verbose) {

arduino-core/src/processing/app/Platform.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ protected Map<String, Object> resolveDeviceByVendorIdProductId(Map<String, Targe
161161
List<String> pids = new LinkedList<String>(board.getPreferences().subTree("pid", 1).values());
162162
for (int i = 0; i < vids.size(); i++) {
163163
String vidPid = vids.get(i) + "_" + pids.get(i);
164-
if (vidPid.toUpperCase().equals(readVIDPID)) {
164+
if (readVIDPID.contains(vidPid.toUpperCase())) {
165165
Map<String, Object> boardData = new HashMap<String, Object>();
166166
boardData.put("board", board);
167167
boardData.put("vid", vids.get(i));
168168
boardData.put("pid", pids.get(i));
169+
boardData.put("iserial", readVIDPID.substring(vidPid.length()+1));
169170
return boardData;
170171
}
171172
}

arduino-core/src/processing/app/linux/UDevAdmParser.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ public String extractVIDAndPID(String output) throws IOException {
1212

1313
Object vid = properties.get("ID_VENDOR_ID");
1414
Object pid = properties.get("ID_MODEL_ID");
15+
Object serial = properties.get("ID_SERIAL_SHORT");
1516
if (vid == null || pid == null)
1617
return null;
17-
return ("0x" + vid + "_0x" + pid).toUpperCase();
18+
if (serial == null) {
19+
serial = "";
20+
}
21+
return ("0x" + vid + "_0x" + pid).toUpperCase() + "_" + serial;
1822
}
1923

2024
}

arduino-core/src/processing/app/macosx/SystemProfilerParser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String extractVIDAndPID(String output, String serial) throws IOException
8181
String computedDevicePathMinusChar = computedDevicePath.substring(0, computedDevicePath.length() - 1);
8282
String serialMinusChar = serial.substring(0, serial.length() - 1);
8383
if (computedDevicePath.equalsIgnoreCase(serial) || computedDevicePathMinusChar.equalsIgnoreCase(serialMinusChar)) {
84-
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
84+
return (device.get(VID) + "_" + device.get(PID)).toUpperCase() + "_" + device.get(SERIAL_NUMBER);
8585
}
8686
}
8787
device = new HashMap<>();

arduino-core/src/processing/app/windows/ListComPortsParser.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public String extractVIDAndPID(String output, String serial) throws IOException
5959
String vidPidPart = lineParts[lineParts.length - 1];
6060
Matcher vidMatcher = vidRegExp.matcher(vidPidPart);
6161
Matcher pidMatcher = pidRegExp.matcher(vidPidPart);
62+
String iSerial = vidPidPart.substring(vidPidPart.lastIndexOf("\\")+1);
6263
if (vidMatcher.find() && pidMatcher.find()) {
63-
return ("0x" + vidMatcher.group(1) + "_0x" + pidMatcher.group(1)).toUpperCase();
64+
return ("0x" + vidMatcher.group(1) + "_0x" + pidMatcher.group(1)).toUpperCase() + "_" + iSerial;
6465
}
6566
}
6667
}

0 commit comments

Comments
 (0)