Skip to content

Commit 59de784

Browse files
author
Federico Fissore
committed
Trying to fix macosx system_profiler parser
1 parent 0732d5a commit 59de784

File tree

3 files changed

+175
-5
lines changed

3 files changed

+175
-5
lines changed

app/src/processing/app/macosx/SystemProfilerParser.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ public String extractVIDAndPID(String output, String serial) throws IOException
5151
if ((matcher = serialNumberRegex.matcher(line)).matches()) {
5252
device.put(SERIAL_NUMBER, matcher.group(1));
5353
} else if ((matcher = locationRegex.matcher(line)).matches()) {
54-
device.put(DEVICE_PATH, devicePrefix + matcher.group(1).substring(2, 6) + "1");
54+
String devicePath = devicePrefix;
55+
String suffix = matcher.group(1).substring(2, 6);
56+
try {
57+
devicePath = devicePath + (Integer.parseInt(suffix) + 1);
58+
} catch (NumberFormatException e) {
59+
devicePath = devicePath + suffix + "1";
60+
}
61+
device.put(DEVICE_PATH, devicePath);
5562
} else if ((matcher = pidRegex.matcher(line)).matches()) {
5663
device.put(PID, matcher.group(1));
5764
} else if ((matcher = vidRegex.matcher(line)).matches()) {

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ public void shouldCorrectlyParse() throws Exception {
2626

2727
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output4.txt"));
2828

29-
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem04101"));
30-
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem04101"));
29+
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem411"));
30+
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem411"));
3131

3232
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output5.txt"));
3333

34-
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem06201"));
35-
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem06201"));
34+
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem621"));
35+
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem621"));
36+
37+
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output6.txt"));
38+
39+
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem1421"));
40+
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem1421"));
3641
}
3742
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
USB:
2+
3+
USB 3.0 SuperSpeed Bus:
4+
5+
Host Controller Location: Built-in USB
6+
Host Controller Driver: AppleUSBXHCI
7+
PCI Device ID: 0x1e31
8+
PCI Revision ID: 0x0004
9+
PCI Vendor ID: 0x8086
10+
Bus Number: 0x0a
11+
12+
USB Hi-Speed Bus:
13+
14+
Host Controller Location: Built-in USB
15+
Host Controller Driver: AppleUSBEHCI
16+
PCI Device ID: 0x1e2d
17+
PCI Revision ID: 0x0004
18+
PCI Vendor ID: 0x8086
19+
Bus Number: 0x1a
20+
21+
Hub:
22+
23+
Product ID: 0x0024
24+
Vendor ID: 0x8087 (Intel Corporation)
25+
Version: 0.00
26+
Speed: Up to 480 Mb/sec
27+
Location ID: 0x1a100000 / 2
28+
Current Available (mA): 500
29+
Current Required (mA): 0
30+
31+
FaceTime HD Camera (Built-in):
32+
33+
Product ID: 0x8510
34+
Vendor ID: 0x05ac (Apple Inc.)
35+
Version: 80.25
36+
Serial Number: DJHC8MZ5E1DNYGE0
37+
Speed: Up to 480 Mb/sec
38+
Manufacturer: Apple Inc.
39+
Location ID: 0x1a110000 / 3
40+
Current Available (mA): 500
41+
Current Required (mA): 500
42+
43+
USB Hi-Speed Bus:
44+
45+
Host Controller Location: Built-in USB
46+
Host Controller Driver: AppleUSBEHCI
47+
PCI Device ID: 0x1e26
48+
PCI Revision ID: 0x0004
49+
PCI Vendor ID: 0x8086
50+
Bus Number: 0x1d
51+
52+
Hub:
53+
54+
Product ID: 0x0024
55+
Vendor ID: 0x8087 (Intel Corporation)
56+
Version: 0.00
57+
Speed: Up to 480 Mb/sec
58+
Location ID: 0x1d100000 / 2
59+
Current Available (mA): 500
60+
Current Required (mA): 0
61+
62+
Keyboard Hub:
63+
64+
Product ID: 0x1006
65+
Vendor ID: 0x05ac (Apple Inc.)
66+
Version: 96.15
67+
Serial Number: 0
68+
Speed: Up to 480 Mb/sec
69+
Manufacturer: Apple, Inc.
70+
Location ID: 0x1d110000 / 6
71+
Current Available (mA): 500
72+
Current Required (mA): 300
73+
74+
Optical USB Mouse:
75+
76+
Product ID: 0xc016
77+
Vendor ID: 0x046d (Logitech Inc.)
78+
Version: 3.40
79+
Speed: Up to 1.5 Mb/sec
80+
Manufacturer: Logitech
81+
Location ID: 0x1d113000 / 9
82+
Current Available (mA): 100
83+
Current Required (mA): 100
84+
85+
Apple Keyboard:
86+
87+
Product ID: 0x0250
88+
Vendor ID: 0x05ac (Apple Inc.)
89+
Version: 0.74
90+
Speed: Up to 1.5 Mb/sec
91+
Manufacturer: Apple Inc.
92+
Location ID: 0x1d112000 / 7
93+
Current Available (mA): 100
94+
Current Required (mA): 20
95+
96+
Hub:
97+
98+
Product ID: 0x2512
99+
Vendor ID: 0x0424 (SMSC)
100+
Version: b.b3
101+
Speed: Up to 480 Mb/sec
102+
Location ID: 0x1d180000 / 3
103+
Current Available (mA): 500
104+
Current Required (mA): 2
105+
106+
BRCM20702 Hub:
107+
108+
Product ID: 0x4500
109+
Vendor ID: 0x0a5c (Broadcom Corp.)
110+
Version: 1.00
111+
Speed: Up to 12 Mb/sec
112+
Manufacturer: Apple Inc.
113+
Location ID: 0x1d181000 / 5
114+
Current Available (mA): 500
115+
Current Required (mA): 94
116+
117+
Bluetooth USB Host Controller:
118+
119+
Product ID: 0x8286
120+
Vendor ID: 0x05ac (Apple Inc.)
121+
Version: 1.25
122+
Speed: Up to 12 Mb/sec
123+
Manufacturer: Apple Inc.
124+
Location ID: 0x1d181300 / 8
125+
Current Available (mA): 500
126+
Current Required (mA): 0
127+
128+
Apple Internal Keyboard / Trackpad:
129+
130+
Product ID: 0x0262
131+
Vendor ID: 0x05ac (Apple Inc.)
132+
Version: 2.22
133+
Speed: Up to 12 Mb/sec
134+
Manufacturer: Apple Inc.
135+
Location ID: 0x1d182000 / 4
136+
Current Available (mA): 500
137+
Current Required (mA): 40
138+
139+
USB 3.0 Hi-Speed Bus:
140+
141+
Host Controller Location: Built-in USB
142+
Host Controller Driver: AppleUSBXHCI
143+
PCI Device ID: 0x1e31
144+
PCI Revision ID: 0x0004
145+
PCI Vendor ID: 0x8086
146+
Bus Number: 0x0a
147+
148+
Arduino Yun:
149+
150+
Product ID: 0x8041
151+
Vendor ID: 0x2341
152+
Version: 1.00
153+
Speed: Up to 12 Mb/sec
154+
Manufacturer: Arduino LLC
155+
Location ID: 0x14200000 / 12
156+
Current Available (mA): 500
157+
Current Required (mA): 500
158+

0 commit comments

Comments
 (0)