Skip to content

Commit 428cdf1

Browse files
committed
Add iSerial to reported VID_PID string
serial.port.iserial holds the iSerial value
1 parent 3122d18 commit 428cdf1

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ 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()));
170+
PreferencesData.set("serial.port.iserial", readVIDPID.substring(vidPid.length()+1));
169171
return boardData;
170172
}
171173
}

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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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.indexOf("PID_")+8);
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)