|
22 | 22 |
|
23 | 23 | package processing.app;
|
24 | 24 |
|
25 |
| -import jssc.SerialPortList; |
26 | 25 | import processing.app.debug.*;
|
27 | 26 | import processing.app.syntax.*;
|
28 | 27 | import processing.app.tools.*;
|
|
44 | 43 | import javax.swing.text.*;
|
45 | 44 | import javax.swing.undo.*;
|
46 | 45 |
|
| 46 | +import gnu.io.*; |
| 47 | + |
47 | 48 | /**
|
48 | 49 | * Main editor panel for the Processing Development Environment.
|
49 | 50 | */
|
@@ -978,19 +979,36 @@ protected void populateSerialMenu() {
|
978 | 979 | serialMenu.removeAll();
|
979 | 980 | boolean empty = true;
|
980 | 981 |
|
981 |
| - String[] portNames = SerialPortList.getPortNames(); |
982 |
| - for (String curr_port : portNames) { |
983 |
| - rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port"))); |
984 |
| - rbMenuItem.addActionListener(serialMenuListener); |
985 |
| - //serialGroup.add(rbMenuItem); |
986 |
| - serialMenu.add(rbMenuItem); |
987 |
| - empty = false; |
988 |
| - } |
989 |
| - if (!empty) { |
990 |
| - //System.out.println("enabling the serialMenu"); |
991 |
| - serialMenu.setEnabled(true); |
| 982 | + try |
| 983 | + { |
| 984 | + for (Enumeration enumeration = CommPortIdentifier.getPortIdentifiers(); enumeration.hasMoreElements();) |
| 985 | + { |
| 986 | + CommPortIdentifier commportidentifier = (CommPortIdentifier)enumeration.nextElement(); |
| 987 | + //System.out.println("Found communication port: " + commportidentifier); |
| 988 | + if (commportidentifier.getPortType() == CommPortIdentifier.PORT_SERIAL) |
| 989 | + { |
| 990 | + //System.out.println("Adding port to serial port menu: " + commportidentifier); |
| 991 | + String curr_port = commportidentifier.getName(); |
| 992 | + rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port"))); |
| 993 | + rbMenuItem.addActionListener(serialMenuListener); |
| 994 | + //serialGroup.add(rbMenuItem); |
| 995 | + serialMenu.add(rbMenuItem); |
| 996 | + empty = false; |
| 997 | + } |
| 998 | + } |
| 999 | + if (!empty) { |
| 1000 | + //System.out.println("enabling the serialMenu"); |
| 1001 | + serialMenu.setEnabled(true); |
| 1002 | + } |
| 1003 | + |
992 | 1004 | }
|
993 | 1005 |
|
| 1006 | + catch (Exception exception) |
| 1007 | + { |
| 1008 | + System.out.println(_("error retrieving port list")); |
| 1009 | + exception.printStackTrace(); |
| 1010 | + } |
| 1011 | + |
994 | 1012 | if (serialMenu.getItemCount() == 0) {
|
995 | 1013 | serialMenu.setEnabled(false);
|
996 | 1014 | }
|
|
0 commit comments