Skip to content

Commit cf3e948

Browse files
committed
Merge pull request arduino#2626 from ffissore/hide-cu-devs-on-mac
Macosx: filter out /dev/cu* ports
2 parents 5687528 + a49963d commit cf3e948

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
@@ -1004,6 +1004,8 @@ protected void populatePortMenu() {
10041004

10051005
List<BoardPort> ports = Base.getDiscoveryManager().discovery();
10061006

1007+
ports = Base.getPlatform().filterPorts(ports, Preferences.getBoolean("serial.ports.showall"));
1008+
10071009
Collections.sort(ports, new Comparator<BoardPort>() {
10081010
@Override
10091011
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)