projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More ALtosUI changes
[fw/altos]
/
ao-tools
/
altosui
/
AltosSerial.java
diff --git
a/ao-tools/altosui/AltosSerial.java
b/ao-tools/altosui/AltosSerial.java
index e4cedde22b6d6b9c0deedc6c2a506a94f32d0516..03ab28c55376ff635c4c7b964304f0ab7cd1b269 100644
(file)
--- a/
ao-tools/altosui/AltosSerial.java
+++ b/
ao-tools/altosui/AltosSerial.java
@@
-36,7
+36,7
@@
import altosui.AltosSerialMonitor;
*/
class AltosSerialReader implements Runnable {
InputStream serial_in;
*/
class AltosSerialReader implements Runnable {
InputStream serial_in;
- Linked
BlockingQueue<String> monitor_queue
;
+ Linked
List<LinkedBlockingQueue<String>> monitors
;
LinkedBlockingQueue<String> reply_queue;
Thread input_thread;
String line;
LinkedBlockingQueue<String> reply_queue;
Thread input_thread;
String line;
@@
-56,9
+56,12
@@
class AltosSerialReader implements Runnable {
synchronized(this) {
if (c == '\n') {
if (line != "") {
synchronized(this) {
if (c == '\n') {
if (line != "") {
- if (line.startsWith("VERSION"))
- monitor_queue.put(line);
- else
+ if (line.startsWith("VERSION")) {
+ for (int e = 0; e < monitors.size(); e++) {
+ LinkedBlockingQueue<String> q = monitors.get(e);
+ q.put(line);
+ }
+ } else
reply_queue.put(line);
line = "";
}
reply_queue.put(line);
line = "";
}
@@
-72,16
+75,18
@@
class AltosSerialReader implements Runnable {
}
}
}
}
- public String get_telem() throws InterruptedException {
- String s = monitor_queue.take();
- System.out.println(s);
- return s;
- }
-
public String get_reply() throws InterruptedException {
return reply_queue.take();
}
public String get_reply() throws InterruptedException {
return reply_queue.take();
}
+ public void add_monitor(LinkedBlockingQueue<String> q) {
+ monitors.add(q);
+ }
+
+ public void remove_monitor(LinkedBlockingQueue<String> q) {
+ monitors.remove(q);
+ }
+
public void flush () {
synchronized(this) {
if (!"VERSION".startsWith(line) && !line.startsWith("VERSION"))
public void flush () {
synchronized(this) {
if (!"VERSION".startsWith(line) && !line.startsWith("VERSION"))
@@
-132,7
+137,7
@@
class AltosSerialReader implements Runnable {
serial_in = null;
input_thread = null;
line = "";
serial_in = null;
input_thread = null;
line = "";
- monitor
_queue = new LinkedBlockingQueue<String
> ();
+ monitor
s = new LinkedList<LinkedBlockingQueue<String>
> ();
reply_queue = new LinkedBlockingQueue<String> ();
}
reply_queue = new LinkedBlockingQueue<String> ();
}
@@
-142,10
+147,6
@@
public class AltosSerial {
OutputStream serial_out = null;
AltosSerialReader reader = null;
OutputStream serial_out = null;
AltosSerialReader reader = null;
- public String get_telem() throws InterruptedException {
- return reader.get_telem();
- }
-
CommPort comm_port = null;
public void close() {
CommPort comm_port = null;
public void close() {
@@
-178,6
+179,14
@@
public class AltosSerial {
reader = new AltosSerialReader();
}
reader = new AltosSerialReader();
}
+ public void add_monitor(LinkedBlockingQueue<String> q) {
+ reader.add_monitor(q);
+ }
+
+ public void remove_monitor(LinkedBlockingQueue<String> q) {
+ reader.remove_monitor(q);
+ }
+
public AltosSerial() {
init();
}
public AltosSerial() {
init();
}