@@ -154,7 +154,9 @@ class W_Networking extends Widget {
154154 protocolMode = " UDP" ; // Set Default to UDP
155155 protocolIndex = 2 ; // Set Default to UDP
156156 addDropdown(" Protocol" , " Protocol" , Arrays . asList(settings. nwProtocolArray), protocolIndex);
157- comPorts = new ArrayList<String > (Arrays . asList(processing.serial. Serial . list()));
157+ // comPorts = new ArrayList<String>(Arrays.asList(processing.serial.Serial.list()));
158+ // calls the new method getCuCommPorts to store the list of only .cu serial ports for Mac users
159+ comPorts = new ArrayList<String > (getCuCommPorts());
158160 verbosePrint(" comPorts = " + comPorts);
159161 comPortToSave = 0 ;
160162
@@ -173,6 +175,22 @@ class W_Networking extends Widget {
173175 cp5ElementsToCheck. add((controlP5. Controller )cp5_networking_baudRate. get(ScrollableList . class, " baud_rate" ));
174176 }
175177
178+ // Filter out .tty ports for Mac users, to only show .cu addresses
179+ private LinkedList<String > getCuCommPorts () {
180+ final SerialPort [] allCommPorts = SerialPort . getCommPorts();
181+ LinkedList<String > cuCommPorts = new LinkedList<String > ();
182+ for (SerialPort port : allCommPorts) {
183+ if (isMac() && port. getSystemPortName(). startsWith(" tty" )) {
184+ continue ;
185+ }
186+ String found = " " ;
187+ if (isMac() || isLinux()) found += " /dev/" ;
188+ found += port. getSystemPortName();
189+ cuCommPorts. add(found);
190+ }
191+ return cuCommPorts;
192+ }
193+
176194 // Used to update the Hashmap
177195 public void putCP5DataIntoMap () {
178196 for (int i = 0 ; i < datatypeNames. length; i++ ) {
0 commit comments