Skip to content

Commit

Permalink
Merge pull request #1137 from kkashiva/networking_filter_serial_ports
Browse files Browse the repository at this point in the history
Filter .tty serial ports in Networking for Mac users (Issue #1097)
  • Loading branch information
retiutut committed Jun 6, 2023
2 parents 3161240 + dc71782 commit 1035abd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion OpenBCI_GUI/W_Networking.pde
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class W_Networking extends Widget {
protocolMode = "UDP"; //Set Default to UDP
protocolIndex = 2; //Set Default to UDP
addDropdown("Protocol", "Protocol", Arrays.asList(settings.nwProtocolArray), protocolIndex);
comPorts = new ArrayList<String>(Arrays.asList(processing.serial.Serial.list()));
// comPorts = new ArrayList<String>(Arrays.asList(processing.serial.Serial.list()));
// calls the new method getCuCommPorts to store the list of only .cu serial ports for Mac users
comPorts = new ArrayList<String>(getCuCommPorts());
verbosePrint("comPorts = " + comPorts);
comPortToSave = 0;

Expand All @@ -173,6 +175,22 @@ class W_Networking extends Widget {
cp5ElementsToCheck.add((controlP5.Controller)cp5_networking_baudRate.get(ScrollableList.class, "baud_rate"));
}

// Filter out .tty ports for Mac users, to only show .cu addresses
private LinkedList<String> getCuCommPorts() {
final SerialPort[] allCommPorts = SerialPort.getCommPorts();
LinkedList<String> cuCommPorts = new LinkedList<String>();
for (SerialPort port : allCommPorts) {
if (isMac() && port.getSystemPortName().startsWith("tty")) {
continue;
}
String found = "";
if (isMac() || isLinux()) found += "/dev/";
found += port.getSystemPortName();
cuCommPorts.add(found);
}
return cuCommPorts;
}

//Used to update the Hashmap
public void putCP5DataIntoMap() {
for (int i = 0; i < datatypeNames.length; i++) {
Expand Down

0 comments on commit 1035abd

Please sign in to comment.