mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
MacOSX: SystemProfilerParser nows claims to have found the device even if the name is not exactly the same
This commit is contained in:
parent
54971e451f
commit
64fcc716c9
@ -74,5 +74,9 @@ public class SystemProfilerParserTest {
|
||||
assertEquals("0X2341_0X8036", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem24131"));
|
||||
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbserial-DN0031EV"));
|
||||
assertEquals("0X0403_0X6015", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbserial-DN0031EV"));
|
||||
|
||||
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output8.txt"));
|
||||
|
||||
assertEquals("0X03EB_0X2157", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodemfd132"));
|
||||
}
|
||||
}
|
||||
|
96
app/test/processing/app/macosx/system_profiler_output8.txt
Normal file
96
app/test/processing/app/macosx/system_profiler_output8.txt
Normal file
@ -0,0 +1,96 @@
|
||||
USB:
|
||||
|
||||
USB Hi-Speed Bus:
|
||||
|
||||
Host Controller Location: Built-in USB
|
||||
Host Controller Driver: AppleUSBEHCI
|
||||
PCI Device ID: 0x1c2d
|
||||
PCI Revision ID: 0x0005
|
||||
PCI Vendor ID: 0x8086
|
||||
Bus Number: 0xfa
|
||||
|
||||
Hub:
|
||||
|
||||
Product ID: 0x2513
|
||||
Vendor ID: 0x0424 (SMSC)
|
||||
Version: b.b3
|
||||
Speed: Up to 480 Mb/sec
|
||||
Location ID: 0xfa100000 / 2
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 2
|
||||
|
||||
Arduino Leonardo:
|
||||
|
||||
Product ID: 0x8036
|
||||
Vendor ID: 0x2341
|
||||
Version: 1.00
|
||||
Speed: Up to 12 Mb/sec
|
||||
Manufacturer: Arduino LLC
|
||||
Location ID: 0xfa120000 / 5
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 500
|
||||
|
||||
BRCM20702 Hub:
|
||||
|
||||
Product ID: 0x4500
|
||||
Vendor ID: 0x0a5c (Broadcom Corp.)
|
||||
Version: 1.00
|
||||
Speed: Up to 12 Mb/sec
|
||||
Manufacturer: Apple Inc.
|
||||
Location ID: 0xfa110000 / 3
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 94
|
||||
|
||||
Bluetooth USB Host Controller:
|
||||
|
||||
Product ID: 0x8281
|
||||
Vendor ID: 0x05ac (Apple Inc.)
|
||||
Version: 1.25
|
||||
Speed: Up to 12 Mb/sec
|
||||
Manufacturer: Apple Inc.
|
||||
Location ID: 0xfa113000 / 4
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 0
|
||||
|
||||
USB Hi-Speed Bus:
|
||||
|
||||
Host Controller Location: Built-in USB
|
||||
Host Controller Driver: AppleUSBEHCI
|
||||
PCI Device ID: 0x1c26
|
||||
PCI Revision ID: 0x0005
|
||||
PCI Vendor ID: 0x8086
|
||||
Bus Number: 0xfd
|
||||
|
||||
Hub:
|
||||
|
||||
Product ID: 0x2513
|
||||
Vendor ID: 0x0424 (SMSC)
|
||||
Version: b.b3
|
||||
Speed: Up to 480 Mb/sec
|
||||
Location ID: 0xfd100000 / 2
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 2
|
||||
|
||||
EDBG CMSIS-DAP:
|
||||
|
||||
Product ID: 0x2157
|
||||
Vendor ID: 0x03eb (Atmel Corporation)
|
||||
Version: 1.01
|
||||
Serial Number: 00000000AZE000000310
|
||||
Speed: Up to 480 Mb/sec
|
||||
Manufacturer: Atmel Corp.
|
||||
Location ID: 0xfd130000 / 4
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 500
|
||||
|
||||
IR Receiver:
|
||||
|
||||
Product ID: 0x8242
|
||||
Vendor ID: 0x05ac (Apple Inc.)
|
||||
Version: 0.16
|
||||
Speed: Up to 1.5 Mb/sec
|
||||
Manufacturer: Apple Computer, Inc.
|
||||
Location ID: 0xfd110000 / 3
|
||||
Current Available (mA): 500
|
||||
Current Required (mA): 100
|
||||
|
@ -55,7 +55,7 @@ public class SystemProfilerParser {
|
||||
|
||||
if ((matcher = serialNumberRegex.matcher(line)).matches()) {
|
||||
device.put(SERIAL_NUMBER, matcher.group(1));
|
||||
if ((serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL))) {
|
||||
if (serial.startsWith(DEV_TTY_USBSERIAL) || serial.startsWith(DEV_CU_USBSERIAL)) {
|
||||
String devicePath = devicePrefix + matcher.group(1);
|
||||
device.put(DEVICE_PATH, devicePath);
|
||||
}
|
||||
@ -65,17 +65,24 @@ public class SystemProfilerParser {
|
||||
device.put(DEVICE_PATH, devicePath);
|
||||
} else if ((matcher = pidRegex.matcher(line)).matches()) {
|
||||
String pid = matcher.group(1);
|
||||
if (pid.indexOf(" ") > 0)
|
||||
if (pid.indexOf(" ") > 0) {
|
||||
pid = pid.substring(0, pid.indexOf(" ")); // Remove any text after the hex number
|
||||
}
|
||||
device.put(PID, pid);
|
||||
} else if ((matcher = vidRegex.matcher(line)).matches()) {
|
||||
String vid = matcher.group(1);
|
||||
if (vid.indexOf(" ") > 0)
|
||||
if (vid.indexOf(" ") > 0) {
|
||||
vid = vid.substring(0, vid.indexOf(" ")); // Remove any text after the hex number
|
||||
}
|
||||
device.put(VID, vid);
|
||||
} else if (line.equals("")) {
|
||||
if (device.containsKey(DEVICE_PATH) && device.get(DEVICE_PATH).equals(serial)) {
|
||||
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
|
||||
if (device.containsKey(DEVICE_PATH)) {
|
||||
String computedDevicePath = device.get(DEVICE_PATH);
|
||||
String computedDevicePathMinusChar = computedDevicePath.substring(0, computedDevicePath.length() - 1);
|
||||
String serialMinusChar = serial.substring(0, serial.length() - 1);
|
||||
if (computedDevicePath.equals(serial) || computedDevicePathMinusChar.equals(serialMinusChar)) {
|
||||
return (device.get(VID) + "_" + device.get(PID)).toUpperCase();
|
||||
}
|
||||
}
|
||||
device = new HashMap<String, String>();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user