arduino/arduino-1.0-use_system_rxtx.patch

46 lines
1.5 KiB
Diff
Raw Normal View History

diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java
index b4fedbc..a002e39 100644
--- a/app/src/processing/app/Editor.java
+++ b/app/src/processing/app/Editor.java
@@ -98,6 +98,7 @@ public class Editor extends JFrame implements RunnerListener {
static SerialMenuListener serialMenuListener;
static SerialMonitor serialMonitor;
+ boolean serialScanned;
EditorHeader header;
EditorStatus status;
@@ -940,6 +941,32 @@ public class Editor extends JFrame implements RunnerListener {
serialMenu.removeAll();
boolean empty = true;
+ if ( System.getProperty("os.name").equals("Linux")
+ && ( serialScanned
+ || System.getProperty("gnu.io.rxtx.SerialPorts") == null ) ) {
+ String[] prefixes = {
+ "ttyS", "ttyUSB", "ttyACM"
+ };
+ String SerialPorts = null;
+ File devicesDir = new File("/dev/");
+ for ( String device : devicesDir.list() ) {
+ for ( String prefix : prefixes ) {
+ if ( device.startsWith(prefix) ) {
+ if ( SerialPorts == null ) {
+ SerialPorts = "/dev/" + device;
+ }
+ else {
+ SerialPorts += ":/dev/" + device;
+ }
+ }
+ }
+ }
+ if ( SerialPorts != null ) {
+ System.setProperty("gnu.io.rxtx.SerialPorts", SerialPorts);
+ serialScanned = true;
+ }
+ }
+
try
{
for (Enumeration enumeration = CommPortIdentifier.getPortIdentifiers(); enumeration.hasMoreElements();)