-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPingSpeedTest.java
More file actions
62 lines (56 loc) · 1.78 KB
/
PingSpeedTest.java
File metadata and controls
62 lines (56 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.neuronrobotics.test.nrdk;
import java.net.InetAddress;
import com.neuronrobotics.sdk.common.BowlerAbstractConnection;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.genericdevice.GenericDevice;
import com.neuronrobotics.sdk.network.UDPBowlerConnection;
import com.neuronrobotics.sdk.serial.SerialConnection;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
// Auto-generated Javadoc
/**
* The Class PingSpeedTest.
*/
@SuppressWarnings("unused")
public class PingSpeedTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
BowlerAbstractConnection c = new SerialConnection("/dev/ttyACM0",9600);
// BowlerAbstractConnection c = new SerialConnection("COM65");
//BowlerAbstractConnection c = ConnectionDialog.promptConnection();
// BowlerAbstractConnection c=null;
// try {
// //c = new BowlerTCPClient("192.168.1.10", 1866);
// c = new UDPBowlerConnection(InetAddress.getByName("130.215.49.37"), 1865);
// } catch (Exception e) {
// // Auto-generated catch block
// e.printStackTrace();
// System.exit(1);
// }
if(c==null)
System.exit(1);
com.neuronrobotics.sdk.common.Log.error("Starting test");
Log.enableInfoPrint();
GenericDevice dev = new GenericDevice(c);
dev.connect();
long start;
double avg=0;
int i;
avg=0;
dev.ping();
for(i=1;i<5000000 && dev.isAvailable();i++) {
start = System.currentTimeMillis();
dev.ping();
double ms=System.currentTimeMillis()-start;
avg +=ms;
com.neuronrobotics.sdk.common.Log.error("Average cycle time: "+(int)(avg/i)+"ms\t\t\t this loop was: "+ms);
dev.getNamespaces();
}
com.neuronrobotics.sdk.common.Log.error("Average cycle time for ping: "+(avg/i)+" ms");
dev.disconnect();
System.exit(0);
}
}