use of com.neuronrobotics.sdk.serial.SerialConnection in project java-bowler by NeuronRobotics.
the class SerialConnectionPanel method getConnection.
public BowlerAbstractConnection getConnection() {
try {
int baud = Integer.parseInt(baudrateTxt.getText());
if (baud < 0) {
throw new NumberFormatException();
}
String port = connectionCbo.getSelectedItem().toString();
connection = new SerialConnection(port, baud);
Log.info("Using port:" + port + "\n");
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid baudrate given. Please review the list of valid baudrates.", "Invalid Baudrate", JOptionPane.ERROR_MESSAGE);
} catch (Exception e) {
} finally {
setVisible(false);
}
return connection;
}
use of com.neuronrobotics.sdk.serial.SerialConnection in project java-bowler by NeuronRobotics.
the class SimpleConnection method main.
/**
* @param args
*/
public static void main(String[] args) {
SerialConnection s = null;
System.out.println("Connecting and disconnecting");
// Windows
// s=new SerialConnection("COM5");
// OSX
// s=new SerialConnection("/dev/tty.usbmodemfd13411");
// Linux
s = new SerialConnection("/dev/DyIO.74F726800079");
GenericDevice dyio = new GenericDevice(s);
// Log.enableDebugPrint(true);
dyio.connect();
double avg = 0;
long start = System.currentTimeMillis();
int i;
for (i = 0; i < 500; i++) {
dyio.ping();
double ms = System.currentTimeMillis() - start;
avg += ms;
start = System.currentTimeMillis();
}
System.out.println("Average cycle time for ping: " + (avg / i) + " ms");
dyio.disconnect();
System.exit(0);
// while(true);
}
Aggregations