forked from GideonLeGrange/panstamp-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDeviceStore.java
More file actions
52 lines (39 loc) · 1.25 KB
/
TestDeviceStore.java
File metadata and controls
52 lines (39 loc) · 1.25 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
package example;
import me.legrange.panstamp.ModemException;
import me.legrange.panstamp.Network;
import me.legrange.panstamp.NetworkException;
/**
* @author Gideon le Grange https://github.com/GideonLeGrange
*/
public class TestDeviceStore extends TestEvents {
private static final String PORT = "/dev/tty.usbserial-A800HNMV";
private static final int BAUD = 38400;
private Network nw;
private int seq = 0;
public static void main(String... args) throws Exception {
TestDeviceStore te = new TestDeviceStore();
te.connect();
te.setupDeviceStore();
while (true) {
Thread.sleep(1000);
}
}
/** Connect to serial port and start the network */
private void connect() throws NetworkException {
nw = Network.openSerial(PORT, BAUD);
}
private void setupDeviceStore() {
nw.setDeviceStore(new ConfigDeviceStateStore());
}
private void disconnect() throws ModemException {
nw.close();
}
private synchronized void say(String fmt, Object... args) {
System.out.printf("[%04d] ", seq);
System.out.printf(fmt, args);
if (!fmt.endsWith("\n")) {
System.out.println();
}
seq++;
}
}