projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/ao_stdio: use uint8_t for stdio index
[fw/altos]
/
altoslib
/
AltosLog.java
diff --git
a/altoslib/AltosLog.java
b/altoslib/AltosLog.java
index ab0d398799f7661ec46d89f064c954f84a4caa97..7dc9fd4c4ae2621210ad694ff879f92998448a8d 100644
(file)
--- a/
altoslib/AltosLog.java
+++ b/
altoslib/AltosLog.java
@@
-16,7
+16,7
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_1
2
;
+package org.altusmetrum.altoslib_1
4
;
import java.io.*;
import java.text.*;
import java.io.*;
import java.text.*;
@@
-37,6
+37,12
@@
public class AltosLog implements Runnable {
Thread log_thread;
AltosFile file;
AltosLink link;
Thread log_thread;
AltosFile file;
AltosLink link;
+ AltosLogTrace trace;
+
+ private void trace(String format, Object ... arguments) {
+ if (trace != null)
+ trace.trace(format, arguments);
+ }
private void close_log_file() {
if (log_file != null) {
private void close_log_file() {
if (log_file != null) {
@@
-62,10
+68,25
@@
public class AltosLog implements Runnable {
}
boolean open (AltosCalData cal_data) throws IOException, InterruptedException {
}
boolean open (AltosCalData cal_data) throws IOException, InterruptedException {
+ trace("open serial %d flight %d receiver_serial %d",
+ cal_data.serial,
+ cal_data.flight,
+ cal_data.receiver_serial);
+
AltosFile a = new AltosFile(cal_data);
AltosFile a = new AltosFile(cal_data);
- log_file = new FileWriter(a, true);
+ trace("open file %s\n", a.getPath());
+
+ try {
+ log_file = new FileWriter(a, true);
+ } catch (IOException ie) {
+ log_file = null;
+ trace("open file failed\n");
+ if (trace != null)
+ trace.open_failed(a);
+ }
if (log_file != null) {
if (log_file != null) {
+ trace("open file success\n");
while (!pending_queue.isEmpty()) {
String s = pending_queue.take();
log_file.write(s);
while (!pending_queue.isEmpty()) {
String s = pending_queue.take();
log_file.write(s);
@@
-79,6
+100,7
@@
public class AltosLog implements Runnable {
}
public void run () {
}
public void run () {
+ trace("log run start\n");
try {
AltosConfigData receiver_config = link.config_data();
AltosCalData cal_data = new AltosCalData();
try {
AltosConfigData receiver_config = link.config_data();
AltosCalData cal_data = new AltosCalData();
@@
-92,7
+114,7
@@
public class AltosLog implements Runnable {
AltosTelemetry telem = AltosTelemetry.parse(line.line);
if (state == null)
state = new AltosState(cal_data);
AltosTelemetry telem = AltosTelemetry.parse(line.line);
if (state == null)
state = new AltosState(cal_data);
- telem.provide_data(state
, cal_data
);
+ telem.provide_data(state);
if (cal_data.serial != serial ||
cal_data.flight != flight ||
if (cal_data.serial != serial ||
cal_data.flight != flight ||
@@
-117,21
+139,30
@@
public class AltosLog implements Runnable {
pending_queue.put(line.line);
}
} catch (InterruptedException ie) {
pending_queue.put(line.line);
}
} catch (InterruptedException ie) {
+ trace("interrupted exception\n");
} catch (TimeoutException te) {
} catch (TimeoutException te) {
+ trace("timeout exception\n");
} catch (IOException ie) {
} catch (IOException ie) {
+ trace("io exception %s message %s\n", ie.toString(), ie.getMessage());
}
}
+ trace("log run done\n");
close();
}
close();
}
- public AltosLog (AltosLink link) {
+ public AltosLog (AltosLink link
, AltosLogTrace trace
) {
pending_queue = new LinkedBlockingQueue<String> ();
input_queue = new LinkedBlockingQueue<AltosLine> ();
link.add_monitor(input_queue);
serial = -1;
flight = -1;
pending_queue = new LinkedBlockingQueue<String> ();
input_queue = new LinkedBlockingQueue<AltosLine> ();
link.add_monitor(input_queue);
serial = -1;
flight = -1;
+ this.trace = trace;
this.link = link;
log_file = null;
log_thread = new Thread(this);
log_thread.start();
}
this.link = link;
log_file = null;
log_thread = new Thread(this);
log_thread.start();
}
+
+ public AltosLog (AltosLink link) {
+ this(link, null);
+ }
}
}