Skip to content

Commit b92e754

Browse files
committed
adding the exception fail over for the serial port connection dialog
1 parent 67e899d commit b92e754

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

javasdk/NRSDK/addons/com/neuronrobotics/sdk/ui/ConnectionDialog.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,14 @@ public void windowGainedFocus(WindowEvent e) {
108108

109109
private void loadDefaultConnections() {
110110
try{
111-
if(!OsInfoUtil.isWindows() || OsInfoUtil.getOsName().contains("Windows 8") ){
112-
111+
try{
113112
addConnectionPanel(new UsbConnectionPanel());
114-
}else{
115-
System.out.println(OsInfoUtil.getOsName());
113+
addConnectionPanel(new BluetoothConnectionPanel());
116114
addConnectionPanel(new SerialConnectionPanel());
117-
}
118-
addConnectionPanel(new BluetoothConnectionPanel());
119-
//serial at the end if USB is enabled
120-
if(!OsInfoUtil.isWindows())
115+
}catch(Exception ex){
121116
addConnectionPanel(new SerialConnectionPanel());
122-
117+
addConnectionPanel(new BluetoothConnectionPanel());
118+
}
123119
}catch(Error e){
124120
e.printStackTrace();
125121
Log.error("This is not a java 8 compliant system, removing the serial, bluetooth and usb connections");

javasdk/NRSDK/addons/com/neuronrobotics/sdk/ui/UsbConnectionPanel.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,25 @@ public void refresh() {
110110
System.err.println("Refreshing USB");
111111
connectionCbo.removeAllItems();
112112

113-
List<UsbDevice> prts;
114-
try {
115-
prts = UsbCDCSerialConnection.getAllUsbBowlerDevices();
113+
List<UsbDevice> prts=null;
114+
115+
try {
116+
prts = UsbCDCSerialConnection.getAllUsbBowlerDevices();
117+
} catch (UnsupportedEncodingException | UsbDisconnectedException
118+
| SecurityException | UsbException e1) {
119+
e1.printStackTrace();
120+
throw new RuntimeException(e1);
121+
}
116122
for(int i=0;i<prts.size();i++) {
117-
String s = UsbCDCSerialConnection.getUniqueID(prts.get(i));
118-
connectionCbo.addItem(s);
123+
try {
124+
String s = UsbCDCSerialConnection.getUniqueID(prts.get(i));
125+
connectionCbo.addItem(s);
126+
} catch (Exception e) {
127+
e.printStackTrace();
128+
throw new RuntimeException(e);
129+
}
119130
}
120-
} catch (Exception e) {
121-
e.printStackTrace();
122-
}
131+
123132

124133
}
125134

0 commit comments

Comments
 (0)