diff --git a/app/src/processing/app/windows/ListComPortsParser.java b/app/src/processing/app/windows/ListComPortsParser.java new file mode 100644 index 000000000..14a679956 --- /dev/null +++ b/app/src/processing/app/windows/ListComPortsParser.java @@ -0,0 +1,40 @@ +package processing.app.windows; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Interprets the output of listComPorts.exe + *
+ * https://github.com/todbot/usbSearch/ + */ +public class ListComPortsParser { + + private final Pattern vidRegExp; + private final Pattern pidRegExp; + + public ListComPortsParser() { + vidRegExp = Pattern.compile("VID_(\\w\\w\\w\\w)"); + pidRegExp = Pattern.compile("PID_(\\w\\w\\w\\w)"); + } + + public String extractVIDAndPID(String output, String serial) throws IOException { + BufferedReader reader = new BufferedReader(new StringReader(output)); + String line; + while ((line = reader.readLine()) != null) { + if (line.startsWith(serial.toUpperCase())) { + Matcher vidMatcher = vidRegExp.matcher(line); + Matcher pidMatcher = pidRegExp.matcher(line); + if (vidMatcher.find() && pidMatcher.find()) { + return vidMatcher.group(1).toUpperCase() + "_" + pidMatcher.group(1).toUpperCase(); + } + } + } + + return null; + } + +} diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index f45db5a68..9cac00bda 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -22,18 +22,24 @@ package processing.app.windows; -import java.io.File; -import java.io.UnsupportedEncodingException; - import com.sun.jna.Library; import com.sun.jna.Native; - +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.Executor; import processing.app.Base; import processing.app.Preferences; +import processing.app.debug.TargetPackage; +import processing.app.tools.ExternalProcessExecutor; import processing.app.windows.Registry.REGISTRY_ROOT_KEY; import processing.core.PApplet; import processing.core.PConstants; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Map; + // http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html // HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\QuickTime\QTSysDir @@ -309,4 +315,27 @@ public class Platform extends processing.app.Platform { return PConstants.platformNames[PConstants.WINDOWS]; } + @Override + public String resolveDeviceAttachedTo(String serial, Map