diff --git a/app/build.xml b/app/build.xml
index 8603d6101..9c00cab6f 100644
--- a/app/build.xml
+++ b/app/build.xml
@@ -76,13 +76,13 @@
-
-
+
+
+
+-->
+
- packages) {
+ return null;
+ }
+
+ public String resolveDeviceByVendorIdProductId(Map packages, String vendorId, String productId) {
+ for (TargetPackage targetPackage : packages.values()) {
+ for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
+ for (PreferencesMap board : targetPlatform.getBoards().values()) {
+ if (board.containsKey("vid_pid")) {
+ String[] vidPids = board.get("vid_pid").split(",");
+ for (String vidPid : vidPids) {
+ if (vidPid.toUpperCase().equals(vendorId + "_" + productId)) {
+ return board.get("name");
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
+
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
diff --git a/app/src/processing/app/linux/Platform.java b/app/src/processing/app/linux/Platform.java
index c084ae70f..5f4a169f4 100644
--- a/app/src/processing/app/linux/Platform.java
+++ b/app/src/processing/app/linux/Platform.java
@@ -22,11 +22,18 @@
package processing.app.linux;
-import java.io.File;
+import java.io.*;
+import java.util.Map;
+import java.util.Properties;
import javax.swing.UIManager;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.exec.Executor;
import processing.app.Preferences;
+import processing.app.debug.TargetPackage;
import processing.core.PConstants;
@@ -124,4 +131,51 @@ public class Platform extends processing.app.Platform {
public String getName() {
return PConstants.platformNames[PConstants.LINUX];
}
+
+ @Override
+ public String resolveDeviceAttachedTo(String serial, Map packages) {
+ Executor executor = new DefaultExecutor();
+
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ executor.setStreamHandler(new ExecuteStreamHandler() {
+ @Override
+ public void setProcessInputStream(OutputStream outputStream) throws IOException {
+ }
+
+ @Override
+ public void setProcessErrorStream(InputStream inputStream) throws IOException {
+ }
+
+ @Override
+ public void setProcessOutputStream(InputStream inputStream) throws IOException {
+ byte[] buf = new byte[4096];
+ int bytes = -1;
+ while ((bytes = inputStream.read(buf)) != -1) {
+ baos.write(buf, 0, bytes);
+ }
+ }
+
+ @Override
+ public void start() throws IOException {
+ }
+
+ @Override
+ public void stop() {
+ }
+ });
+
+ try {
+ CommandLine toDevicePath = CommandLine.parse("udevadm info -q path -n " + serial);
+ executor.execute(toDevicePath);
+ String devicePath = new String(baos.toByteArray());
+ baos.reset();
+ CommandLine commandLine = CommandLine.parse("udevadm info --query=property -p " + devicePath);
+ executor.execute(commandLine);
+ Properties properties = new Properties();
+ properties.load(new ByteArrayInputStream(baos.toByteArray()));
+ return super.resolveDeviceByVendorIdProductId(packages, properties.get("ID_VENDOR_ID").toString().toUpperCase(), properties.get("ID_MODEL_ID").toString().toUpperCase());
+ } catch (IOException e) {
+ return null;
+ }
+ }
}
diff --git a/build/build.xml b/build/build.xml
index 35e6fcc7a..22917e80f 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -25,6 +25,7 @@
+
diff --git a/core/build.xml b/core/build.xml
index 307999071..1798a55c1 100644
--- a/core/build.xml
+++ b/core/build.xml
@@ -13,7 +13,7 @@
-
diff --git a/hardware/arduino/avr/boards.txt b/hardware/arduino/avr/boards.txt
index 7d740bd26..2150aa637 100644
--- a/hardware/arduino/avr/boards.txt
+++ b/hardware/arduino/avr/boards.txt
@@ -5,6 +5,7 @@ menu.cpu=Processor
##############################################################
uno.name=Arduino Uno
+uno.vid_pid=2341_0043
uno.upload.tool=avrdude
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
@@ -119,6 +120,7 @@ nano.menu.cpu.atmega168.build.mcu=atmega168
##############################################################
mega2560.name=Arduino Mega 2560 or Mega ADK
+mega2560.vid_pid=2341_0044,2341_003f
mega2560.cpu=2560 or ADK
mega2560.upload.tool=avrdude
@@ -167,6 +169,7 @@ mega.build.variant=mega
##############################################################
leonardo.name=Arduino Leonardo
+leonardo.vid_pid=2341_0036,2341_8036
leonardo.upload.tool=avrdude
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672
@@ -225,6 +228,7 @@ micro.build.extra_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid}
##############################################################
esplora.name=Arduino Esplora
+esplora.vid_pid=2341_003c,2341_8036
esplora.upload.tool=avrdude
esplora.upload.protocol=avr109
esplora.upload.maximum_size=28672
diff --git a/hardware/arduino/sam/boards.txt b/hardware/arduino/sam/boards.txt
index c61b01fac..f563828f0 100644
--- a/hardware/arduino/sam/boards.txt
+++ b/hardware/arduino/sam/boards.txt
@@ -1,5 +1,6 @@
arduino_due_x_dbg.name=Arduino Due (Programming Port)
+arduino_due_x_dbg.vid_pid=2341_003d
arduino_due_x_dbg.upload.tool=bossac
arduino_due_x_dbg.upload.protocol=sam-ba
arduino_due_x_dbg.upload.maximum_size=524288
@@ -18,6 +19,7 @@ arduino_due_x_dbg.build.vid=0x2341
arduino_due_x_dbg.build.pid=0x003e
arduino_due_x.name=Arduino Due (Native USB Port)
+arduino_due_x.vid_pid=2341_003e
arduino_due_x.upload.tool=bossac
arduino_due_x.upload.protocol=sam-ba
arduino_due_x.upload.maximum_size=524288