Skip to content

Commit 64fcc71

Browse files
author
Federico Fissore
committed
MacOSX: SystemProfilerParser nows claims to have found the device even if the name is not exactly the same
1 parent 54971e4 commit 64fcc71

File tree

3 files changed

+112
-5
lines changed

3 files changed

+112
-5
lines changed

app/test/processing/app/macosx/SystemProfilerParserTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@ public void shouldCorrectlyParse() throws Exception {
7474
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem24131"));
7575
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbserial-DN0031EV"));
7676
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbserial-DN0031EV"));
77+
78+
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output8.txt"));
79+
80+
assertEquals("0X03EB_0X2157", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfd132"));
7781
}
7882
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
USB:
2+
3+
USB Hi-Speed Bus:
4+
5+
Host Controller Location: Built-in USB
6+
Host Controller Driver: AppleUSBEHCI
7+
PCI Device ID: 0x1c2d
8+
PCI Revision ID: 0x0005
9+
PCI Vendor ID: 0x8086
10+
Bus Number: 0xfa
11+
12+
Hub:
13+
14+
Product ID: 0x2513
15+
Vendor ID: 0x0424 (SMSC)
16+
Version: b.b3
17+
Speed: Up to 480 Mb/sec
18+
Location ID: 0xfa100000 / 2
19+
Current Available (mA): 500
20+
Current Required (mA): 2
21+
22+
Arduino Leonardo:
23+
24+
Product ID: 0x8036
25+
Vendor ID: 0x2341
26+
Version: 1.00
27+
Speed: Up to 12 Mb/sec
28+
Manufacturer: Arduino LLC
29+
Location ID: 0xfa120000 / 5
30+
Current Available (mA): 500
31+
Current Required (mA): 500
32+
33+
BRCM20702 Hub:
34+
35+
Product ID: 0x4500
36+
Vendor ID: 0x0a5c (Broadcom Corp.)
37+
Version: 1.00
38+
Speed: Up to 12 Mb/sec
39+
Manufacturer: Apple Inc.
40+
Location ID: 0xfa110000 / 3
41+
Current Available (mA): 500
42+
Current Required (mA): 94
43+
44+
Bluetooth USB Host Controller:
45+
46+
Product ID: 0x8281
47+
Vendor ID: 0x05ac (Apple Inc.)
48+
Version: 1.25
49+
Speed: Up to 12 Mb/sec
50+
Manufacturer: Apple Inc.
51+
Location ID: 0xfa113000 / 4
52+
Current Available (mA): 500
53+
Current Required (mA): 0
54+
55+
USB Hi-Speed Bus:
56+
57+
Host Controller Location: Built-in USB
58+
Host Controller Driver: AppleUSBEHCI
59+
PCI Device ID: 0x1c26
60+
PCI Revision ID: 0x0005
61+
PCI Vendor ID: 0x8086
62+
Bus Number: 0xfd
63+
64+
Hub:
65+
66+
Product ID: 0x2513
67+
Vendor ID: 0x0424 (SMSC)
68+
Version: b.b3
69+
Speed: Up to 480 Mb/sec
70+
Location ID: 0xfd100000 / 2
71+
Current Available (mA): 500
72+
Current Required (mA): 2
73+
74+
EDBG CMSIS-DAP:
75+
76+
Product ID: 0x2157
77+
Vendor ID: 0x03eb (Atmel Corporation)
78+
Version: 1.01
79+
Serial Number: 00000000AZE000000310
80+
Speed: Up to 480 Mb/sec
81+
Manufacturer: Atmel Corp.
82+
Location ID: 0xfd130000 / 4
83+
Current Available (mA): 500
84+
Current Required (mA): 500
85+
86+
IR Receiver:
87+
88+
Product ID: 0x8242
89+
Vendor ID: 0x05ac (Apple Inc.)
90+
Version: 0.16
91+
Speed: Up to 1.5 Mb/sec
92+
Manufacturer: Apple Computer, Inc.
93+
Location ID: 0xfd110000 / 3
94+
Current Available (mA): 500
95+
Current Required (mA): 100
96+

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public String extractVIDAndPID(String output, String serial) throws IOException
5555

5656
if ((matcher = serialNumberRegex.matcher(line)).matches()) {
5757
device.put(SERIAL_NUMBER, matcher.group(1));
58-
if ((serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL))) {
58+
if (serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL)) {
5959
String devicePath = devicePrefix + matcher.group(1);
6060
device.put(DEVICE_PATH, devicePath);
6161
}
@@ -65,17 +65,24 @@ public String extractVIDAndPID(String output, String serial) throws IOException
6565
device.put(DEVICE_PATH, devicePath);
6666
} else if ((matcher = pidRegex.matcher(line)).matches()) {
6767
String pid = matcher.group(1);
68-
if (pid.indexOf(" ") > 0)
68+
if (pid.indexOf(" ") > 0) {
6969
pid = pid.substring(0, pid.indexOf(" ")); // Remove any text after the hex number
70+
}
7071
device.put(PID, pid);
7172
} else if ((matcher = vidRegex.matcher(line)).matches()) {
7273
String vid = matcher.group(1);
73-
if (vid.indexOf(" ") > 0)
74+
if (vid.indexOf(" ") > 0) {
7475
vid = vid.substring(0, vid.indexOf(" ")); // Remove any text after the hex number
76+
}
7577
device.put(VID, vid);
7678
} else if (line.equals("")) {
77-
if (device.containsKey(DEVICE_PATH) && device.get(DEVICE_PATH).equals(serial)) {
78-
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
79+
if (device.containsKey(DEVICE_PATH)) {
80+
String computedDevicePath = device.get(DEVICE_PATH);
81+
String computedDevicePathMinusChar = computedDevicePath.substring(0, computedDevicePath.length() - 1);
82+
String serialMinusChar = serial.substring(0, serial.length() - 1);
83+
if (computedDevicePath.equals(serial) || computedDevicePathMinusChar.equals(serialMinusChar)) {
84+
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
85+
}
7986
}
8087
device = new HashMap<String, String>();
8188
}

0 commit comments

Comments
 (0)