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
Latest commit
52 lines (39 loc) · 1.25 KB
/
Copy pathTestDeviceStore.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
packageexample;
importme.legrange.panstamp.ModemException;
importme.legrange.panstamp.Network;
importme.legrange.panstamp.NetworkException;
/**
* @author Gideon le Grange https://github.com/GideonLeGrange
*/
publicclassTestDeviceStoreextendsTestEvents {
privatestaticfinalStringPORT = "/dev/tty.usbserial-A800HNMV";
privatestaticfinalintBAUD = 38400;
privateNetworknw;
privateintseq = 0;
publicstaticvoidmain(String... args) throwsException {
TestDeviceStorete = newTestDeviceStore();
te.connect();
te.setupDeviceStore();
while (true) {
Thread.sleep(1000);
}
}
/** Connect to serial port and start the network */
privatevoidconnect() throwsNetworkException {
nw = Network.openSerial(PORT, BAUD);
}
privatevoidsetupDeviceStore() {
nw.setDeviceStore(newConfigDeviceStateStore());
}
privatevoiddisconnect() throwsModemException {
nw.close();
}
privatesynchronizedvoidsay(Stringfmt, Object... args) {
System.out.printf("[%04d] ", seq);
System.out.printf(fmt, args);
if (!fmt.endsWith("\n")) {
System.out.println();
}
seq++;
}
}