Skip to content

Commit 22dfa98

Browse files
author
Federico Fissore
committed
Merge branch 'ide-1.5.x' into ide-1.5.x-preproc
2 parents 12446a2 + 77635aa commit 22dfa98

File tree

4 files changed

+183
-11
lines changed

4 files changed

+183
-11
lines changed

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class SystemProfilerParser {
1414
private static final String VID = "vid";
1515
private static final String PID = "pid";
1616
private static final String SERIAL_NUMBER = "serial_number";
17-
private static final String DEV_TTY = "/dev/tty.";
17+
private static final String DEV_TTY_USBSERIAL = "/dev/tty.usbserial-";
18+
private static final String DEV_CU_USBSERIAL = "/dev/cu.usbserial-";
1819
private static final String DEV_TTY_USBMODEM = "/dev/tty.usbmodem";
1920
private static final String DEV_CU_USBMODEM = "/dev/cu.usbmodem";
2021

@@ -34,7 +35,11 @@ public String extractVIDAndPID(String output, String serial) throws IOException
3435
BufferedReader reader = new BufferedReader(new StringReader(output));
3536

3637
String devicePrefix;
37-
if (serial.startsWith(DEV_TTY)) {
38+
if (serial.startsWith(DEV_TTY_USBSERIAL)) {
39+
devicePrefix = DEV_TTY_USBSERIAL;
40+
} else if (serial.startsWith(DEV_CU_USBSERIAL)) {
41+
devicePrefix = DEV_CU_USBSERIAL;
42+
} else if (serial.startsWith(DEV_TTY_USBMODEM)) {
3843
devicePrefix = DEV_TTY_USBMODEM;
3944
} else {
4045
devicePrefix = DEV_CU_USBMODEM;
@@ -50,19 +55,24 @@ public String extractVIDAndPID(String output, String serial) throws IOException
5055

5156
if ((matcher = serialNumberRegex.matcher(line)).matches()) {
5257
device.put(SERIAL_NUMBER, matcher.group(1));
53-
} else if ((matcher = locationRegex.matcher(line)).matches()) {
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";
58+
if ((serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL))) {
59+
String devicePath = devicePrefix + matcher.group(1);
60+
device.put(DEVICE_PATH, devicePath);
6061
}
62+
} else if ((serial.startsWith(DEV_TTY_USBMODEM) || serial.startsWith(DEV_CU_USBMODEM)) && (matcher = locationRegex.matcher(line)).matches()) {
63+
String suffix = matcher.group(1).substring(2, 6).replaceAll("0", "");
64+
String devicePath = devicePrefix + suffix + "1";
6165
device.put(DEVICE_PATH, devicePath);
6266
} else if ((matcher = pidRegex.matcher(line)).matches()) {
63-
device.put(PID, matcher.group(1));
67+
String pid = matcher.group(1);
68+
if (pid.indexOf(" ") > 0)
69+
pid = pid.substring(0, pid.indexOf(" ")); // Remove any text after the hex number
70+
device.put(PID, pid);
6471
} else if ((matcher = vidRegex.matcher(line)).matches()) {
65-
device.put(VID, matcher.group(1));
72+
String vid = matcher.group(1);
73+
if (vid.indexOf(" ") > 0)
74+
vid = vid.substring(0, vid.indexOf(" ")); // Remove any text after the hex number
75+
device.put(VID, vid);
6676
} else if (line.equals("")) {
6777
if (device.containsKey(DEVICE_PATH) && device.get(DEVICE_PATH).equals(serial)) {
6878
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,12 @@ public void shouldCorrectlyParse() throws Exception {
3838

3939
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem1421"));
4040
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem1421"));
41+
42+
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output7.txt"));
43+
44+
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem24131"));
45+
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem24131"));
46+
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbserial-DN0031EV"));
47+
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbserial-DN0031EV"));
4148
}
4249
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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: 0x0d9d
8+
PCI Revision ID: 0x00a2
9+
PCI Vendor ID: 0x10de
10+
Bus Number: 0x26
11+
12+
Internal Memory Card Reader:
13+
14+
Product ID: 0x8403
15+
Vendor ID: 0x05ac (Apple Inc.)
16+
Version: 98,33
17+
Serial Number: 9833
18+
Speed: Up to 480 Mb/sec
19+
Manufacturer: Apple
20+
Location ID: 0x26100000 / 2
21+
Current Available (mA): 500
22+
Current Required (mA): 500
23+
24+
USB Hi-Speed Bus:
25+
26+
Host Controller Location: Built-in USB
27+
Host Controller Driver: AppleUSBEHCI
28+
PCI Device ID: 0x0d9d
29+
PCI Revision ID: 0x00a2
30+
PCI Vendor ID: 0x10de
31+
Bus Number: 0x24
32+
33+
USB 2.0 Hub:
34+
35+
Product ID: 0x0101
36+
Vendor ID: 0x1a40 (TERMINUS TECHNOLOGY INC.)
37+
Version: 1,11
38+
Speed: Up to 480 Mb/sec
39+
Location ID: 0x24100000 / 3
40+
Current Available (mA): 500
41+
Current Required (mA): 100
42+
43+
FT230X Basic UART:
44+
45+
Product ID: 0x6015
46+
Vendor ID: 0x0403 (Future Technology Devices International Limited)
47+
Version: 10,00
48+
Serial Number: DN0031EV
49+
Speed: Up to 12 Mb/sec
50+
Manufacturer: FTDI
51+
Location ID: 0x24120000 / 7
52+
Current Available (mA): 500
53+
Current Required (mA): 90
54+
55+
Arduino Leonardo:
56+
57+
Product ID: 0x8036
58+
Vendor ID: 0x2341
59+
Version: 1,00
60+
Speed: Up to 12 Mb/sec
61+
Manufacturer: Arduino LLC
62+
Location ID: 0x24130000 / 6
63+
Current Available (mA): 500
64+
Current Required (mA): 500
65+
66+
USB Receiver:
67+
68+
Product ID: 0xc521
69+
Vendor ID: 0x046d (Logitech Inc.)
70+
Version: 57,01
71+
Speed: Up to 1.5 Mb/sec
72+
Manufacturer: Logitech
73+
Location ID: 0x24140000 / 5
74+
Current Available (mA): 500
75+
Current Required (mA): 98
76+
77+
Built-in iSight:
78+
79+
Product ID: 0x8507
80+
Vendor ID: 0x05ac (Apple Inc.)
81+
Version: 4,35
82+
Serial Number: 8JA9E1A6TDCLNL00
83+
Speed: Up to 480 Mb/sec
84+
Manufacturer: Apple Inc.
85+
Location ID: 0x24600000 / 2
86+
Current Available (mA): 500
87+
Current Required (mA): 500
88+
89+
USB Bus:
90+
91+
Host Controller Location: Built-in USB
92+
Host Controller Driver: AppleUSBOHCI
93+
PCI Device ID: 0x0d9c
94+
PCI Revision ID: 0x00a1
95+
PCI Vendor ID: 0x10de
96+
Bus Number: 0x06
97+
98+
BRCM2046 Hub:
99+
100+
Product ID: 0x4500
101+
Vendor ID: 0x0a5c (Broadcom Corp.)
102+
Version: 1,00
103+
Speed: Up to 12 Mb/sec
104+
Manufacturer: Apple Inc.
105+
Location ID: 0x06600000 / 4
106+
Current Available (mA): 500
107+
Current Required (mA): 0
108+
109+
Bluetooth USB Host Controller:
110+
111+
Product ID: 0x8213
112+
Vendor ID: 0x05ac (Apple Inc.)
113+
Version: 2,06
114+
Serial Number: C8BCC8B0B471
115+
Speed: Up to 12 Mb/sec
116+
Manufacturer: Apple Inc.
117+
Location ID: 0x06610000 / 5
118+
Current Available (mA): 500
119+
Current Required (mA): 0
120+
121+
IR Receiver:
122+
123+
Product ID: 0x8242
124+
Vendor ID: 0x05ac (Apple Inc.)
125+
Version: 0,16
126+
Speed: Up to 1.5 Mb/sec
127+
Manufacturer: Apple Computer, Inc.
128+
Location ID: 0x06500000 / 3
129+
Current Available (mA): 500
130+
Current Required (mA): 100
131+
132+
Apple Internal Keyboard / Trackpad:
133+
134+
Product ID: 0x0237
135+
Vendor ID: 0x05ac (Apple Inc.)
136+
Version: 0,90
137+
Speed: Up to 12 Mb/sec
138+
Manufacturer: Apple Inc.
139+
Location ID: 0x06300000 / 2
140+
Current Available (mA): 500
141+
Current Required (mA): 40
142+
143+
USB Bus:
144+
145+
Host Controller Location: Built-in USB
146+
Host Controller Driver: AppleUSBOHCI
147+
PCI Device ID: 0x0d9c
148+
PCI Revision ID: 0x00a1
149+
PCI Vendor ID: 0x10de
150+
Bus Number: 0x04
151+

hardware/arduino/avr/boards.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ yun.build.extra_flags={build.usb_flags}
4141
##############################################################
4242

4343
uno.name=Arduino Uno
44+
4445
uno.vid.0=0x2341
4546
uno.pid.0=0x0043
47+
uno.vid.1=0x2341
48+
uno.pid.1=0x0001
49+
4650
uno.upload.tool=avrdude
4751
uno.upload.protocol=arduino
4852
uno.upload.maximum_size=32256

0 commit comments

Comments
 (0)