Display all serial input, including telemetry.
Wait to display serial output until flush time, to debug missing flushing.
Show when devices are opened and closed.
Signed-off-by: Keith Packard <keithp@keithp.com>
int line_count;
boolean monitor_mode;
static boolean debug;
int line_count;
boolean monitor_mode;
static boolean debug;
+ LinkedList<String> pending_output = new LinkedList<String>();
static void set_debug(boolean new_debug) {
debug = new_debug;
static void set_debug(boolean new_debug) {
debug = new_debug;
for (int i = 0; i < line_count; i++)
line = line + line_bytes[i];
}
for (int i = 0; i < line_count; i++)
line = line + line_bytes[i];
}
+ if (debug)
+ System.out.printf("\t\t\t\t\t%s\n", line);
if (line.startsWith("VERSION") || line.startsWith("CRC")) {
for (int e = 0; e < monitors.size(); e++) {
LinkedBlockingQueue<AltosLine> q = monitors.get(e);
q.put(new AltosLine (line));
}
} else {
if (line.startsWith("VERSION") || line.startsWith("CRC")) {
for (int e = 0; e < monitors.size(); e++) {
LinkedBlockingQueue<AltosLine> q = monitors.get(e);
q.put(new AltosLine (line));
}
} else {
- if (debug)
- System.out.printf("\t\t\t\t\t%s\n", line);
reply_queue.put(new AltosLine (line));
}
line_count = 0;
reply_queue.put(new AltosLine (line));
}
line_count = 0;
}
public void flush_output() {
}
public void flush_output() {
+ if (altos != null) {
+ for (String s : pending_output)
+ System.out.print(s);
+ pending_output.clear();
libaltos.altos_flush(altos);
libaltos.altos_flush(altos);
}
public void flush_input() {
}
public void flush_input() {
synchronized (devices_opened) {
devices_opened.remove(device.getPath());
}
synchronized (devices_opened) {
devices_opened.remove(device.getPath());
}
+ if (debug)
+ System.out.printf("Closing %s\n", device.getPath());
}
private void putc(char c) {
}
private void putc(char c) {
public void print(String data) {
if (debug)
public void print(String data) {
if (debug)
- System.out.printf("%s", data);
+ pending_output.add(data);
for (int i = 0; i < data.length(); i++)
putc(data.charAt(i));
}
for (int i = 0; i < data.length(); i++)
putc(data.charAt(i));
}
close();
throw new FileNotFoundException(device.toShortString());
}
close();
throw new FileNotFoundException(device.toShortString());
}
+ if (debug)
+ System.out.printf("Open %s\n", device.getPath());
input_thread = new Thread(this);
input_thread.start();
print("~\nE 0\n");
input_thread = new Thread(this);
input_thread.start();
print("~\nE 0\n");