use of com.neuronrobotics.sdk.common.MissingNativeLibraryException in project java-bowler by NeuronRobotics.
the class SerialConnection method connect.
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.common.BowlerAbstractConnection#connect()
*/
@Override
public boolean connect() {
if (isConnected()) {
Log.error(port + " is already connected.");
return true;
}
try {
if (serial != null)
serial.disconnect();
serial = new NRSerialPort(getPort(), baud);
serial.connect();
setDataIns(new DataInputStream(serial.getInputStream()));
setDataOuts(new DataOutputStream(serial.getOutputStream()));
setConnected(true);
} catch (UnsatisfiedLinkError e) {
throw new MissingNativeLibraryException(e.getMessage());
} catch (Exception e) {
Log.error("Failed to connect on port: " + port + " exception: ");
e.printStackTrace();
setConnected(false);
}
if (isConnected()) {
serial.notifyOnDataAvailable(true);
}
return isConnected();
}
use of com.neuronrobotics.sdk.common.MissingNativeLibraryException in project java-bowler by NeuronRobotics.
the class SerialConnection method disconnect.
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.common.BowlerAbstractConnection#disconnect()
*/
@Override
public void disconnect() {
if (isConnected())
// new RuntimeException().printStackTrace();
Log.warning("Disconnecting Serial Connection");
try {
try {
serial.disconnect();
} catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException(e);
}
serial = null;
setConnected(false);
} catch (UnsatisfiedLinkError e) {
throw new MissingNativeLibraryException(e.getMessage());
}
}
use of com.neuronrobotics.sdk.common.MissingNativeLibraryException in project java-bowler by NeuronRobotics.
the class SerialConnectionPanel method refresh.
public void refresh() {
connectionCbo.removeAllItems();
String m = "NRSDK not installed properly, native library not found\n\n" + "librxtxSerial.so in Linux\n" + "librxtxSerial.jnilib in OSX\n" + "rxtxSerial.dll in Windows\n\n" + "This must be in your JVM or system library path. See:\n" + "http://neuronrobotics.com/wiki/Installing_The_Native_Serial_Library";
try {
List<String> prts = SerialConnection.getAvailableSerialPorts();
for (int i = 0; i < prts.size(); i++) {
String s = prts.get(i);
if (s.contains("DyIO") || s.contains("Bootloader"))
connectionCbo.addItem(prts.remove(i));
}
for (String s : prts) {
if (!(s.contains("ttyS") || s.equals("COM1") || s.equals("COM2") || s.contains("ttyACM")))
connectionCbo.addItem(s);
else {
// TODO maybe add the others if you can change the color?
}
}
connectionCbo.addItem(null);
for (String s : prts) {
if ((s.contains("ttyS") || s.equals("COM1") || s.equals("COM2") || s.contains("ttyACM")))
connectionCbo.addItem(s);
}
} catch (MissingNativeLibraryException e) {
JOptionPane.showMessageDialog(this, m, "NRSDK not installed properly", JOptionPane.ERROR_MESSAGE);
throw new MissingNativeLibraryException(m);
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, m, "NRSDK not installed properly", JOptionPane.ERROR_MESSAGE);
throw new MissingNativeLibraryException(m);
} catch (Error e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, m, "NRSDK not installed properly", JOptionPane.ERROR_MESSAGE);
throw new MissingNativeLibraryException(m);
}
getConnectionDialog().pack();
}
use of com.neuronrobotics.sdk.common.MissingNativeLibraryException in project java-bowler by NeuronRobotics.
the class BlueCoveManager method disconnect.
/**
*/
public synchronized void disconnect() {
Log.info("Disconnecting: " + selected);
deviceList.clear();
try {
if (ins != null)
ins.close();
if (outs != null)
outs.close();
if (conn != null)
conn.close();
LocalDevice.getLocalDevice().getDiscoveryAgent().cancelInquiry(this);
if (searchId != 0xffff)
LocalDevice.getLocalDevice().getDiscoveryAgent().cancelServiceSearch(searchId);
} catch (Exception e) {
throw new MissingNativeLibraryException(e.getMessage());
}
Log.info("Disconnected");
}
use of com.neuronrobotics.sdk.common.MissingNativeLibraryException in project java-bowler by NeuronRobotics.
the class BluetoothSerialConnection method connect.
/* (non-Javadoc)
* @see com.neuronrobotics.sdk.common.BowlerAbstractConnection#connect()
*/
@Override
public synchronized boolean connect() {
if (isConnected()) {
Log.error(bluetoothAddress + " is already connected.");
return true;
}
try {
setConnected(true);
connecting = true;
blue.connect(bluetoothAddress);
setDataIns(blue.getDataIns());
setDataOuts(blue.getDataOuts());
connecting = false;
} catch (UnsatisfiedLinkError e) {
setConnected(false);
throw new MissingNativeLibraryException(e.getMessage());
} catch (Exception e) {
setConnected(false);
System.err.println("Failed to connect on port:" + bluetoothAddress + " exception: ");
e.printStackTrace();
return false;
}
return isConnected();
}
Aggregations