Skip to content

Commit a49963d

Browse files
author
Federico Fissore
committed
Filter out /dev/cu* ports, can be re-enabled manually adding "serial.ports.showall=true" into preferences.txt file
Closes arduino#2624
1 parent 0094145 commit a49963d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

app/src/processing/app/Editor.java

+2
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,8 @@ protected void populatePortMenu() {
10001000

10011001
List<BoardPort> ports = Base.getDiscoveryManager().discovery();
10021002

1003+
ports = Base.getPlatform().filterPorts(ports, Preferences.getBoolean("serial.ports.showall"));
1004+
10031005
Collections.sort(ports, new Comparator<BoardPort>() {
10041006
@Override
10051007
public int compare(BoardPort o1, BoardPort o2) {

arduino-core/src/processing/app/Platform.java

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import javax.swing.UIManager;
3232

33+
import cc.arduino.packages.BoardPort;
3334
import com.sun.jna.Library;
3435
import com.sun.jna.Native;
3536
import processing.app.debug.TargetBoard;
@@ -217,4 +218,8 @@ protected void showLauncherWarning() {
217218
_("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
218219
null);
219220
}
221+
222+
public List<BoardPort> filterPorts(List<BoardPort> ports, boolean aBoolean) {
223+
return new LinkedList<BoardPort>(ports);
224+
}
220225
}

arduino-core/src/processing/app/macosx/Platform.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package processing.app.macosx;
2424

25+
import cc.arduino.packages.BoardPort;
2526
import com.apple.eio.FileManager;
2627
import org.apache.commons.exec.CommandLine;
2728
import org.apache.commons.exec.Executor;
@@ -35,7 +36,8 @@
3536
import java.io.*;
3637
import java.lang.reflect.Method;
3738
import java.net.URI;
38-
import java.util.Map;
39+
import java.util.*;
40+
import java.util.List;
3941

4042

4143
/**
@@ -239,4 +241,20 @@ public String preListAllCandidateDevices() {
239241
return super.preListAllCandidateDevices();
240242
}
241243
}
244+
245+
@Override
246+
public java.util.List<BoardPort> filterPorts(java.util.List<BoardPort> ports, boolean showAll) {
247+
if (showAll) {
248+
return super.filterPorts(ports, true);
249+
}
250+
251+
List<BoardPort> filteredPorts = new LinkedList<BoardPort>();
252+
for (BoardPort port : ports) {
253+
if (!port.getAddress().startsWith("/dev/cu.")) {
254+
filteredPorts.add(port);
255+
}
256+
}
257+
258+
return filteredPorts;
259+
}
242260
}

0 commit comments

Comments
 (0)