|
22 | 22 |
|
23 | 23 | package processing.app;
|
24 | 24 |
|
| 25 | +import jssc.SerialPortList; |
25 | 26 | import processing.app.debug.*;
|
26 | 27 | import processing.app.syntax.*;
|
27 | 28 | import processing.app.tools.*;
|
|
43 | 44 | import javax.swing.text.*;
|
44 | 45 | import javax.swing.undo.*;
|
45 | 46 |
|
46 |
| -import gnu.io.*; |
47 |
| - |
48 | 47 | /**
|
49 | 48 | * Main editor panel for the Processing Development Environment.
|
50 | 49 | */
|
@@ -979,36 +978,19 @@ protected void populateSerialMenu() {
|
979 | 978 | serialMenu.removeAll();
|
980 | 979 | boolean empty = true;
|
981 | 980 |
|
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 |
| - |
| 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; |
1004 | 988 | }
|
1005 |
| - |
1006 |
| - catch (Exception exception) |
1007 |
| - { |
1008 |
| - System.out.println(_("error retrieving port list")); |
1009 |
| - exception.printStackTrace(); |
| 989 | + if (!empty) { |
| 990 | + //System.out.println("enabling the serialMenu"); |
| 991 | + serialMenu.setEnabled(true); |
1010 | 992 | }
|
1011 |
| - |
| 993 | + |
1012 | 994 | if (serialMenu.getItemCount() == 0) {
|
1013 | 995 | serialMenu.setEnabled(false);
|
1014 | 996 | }
|
|
0 commit comments