- if (data != null) {
- if (data.crc_valid) {
- owner = owner.SetData(data);
- MicroSave save = new MicroSave(owner, data);
- if (save.runDialog())
- owner.SetName(data.name);
+ dispose();
+
+ if (data != null && data.crc_valid) {
+ status_value.setText("Received MicroPeak Data");
+ owner = owner.SetData(data);
+ MicroSave save = new MicroSave(owner, data);
+ if (save.runDialog())
+ owner.SetName(data.name);
+ } else {
+ JOptionPane.showMessageDialog(owner,
+ "Download Failed",
+ "Flight data corrupted",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void drain_queue() {
+ for (;;) {
+ int c;
+ synchronized(this) {
+ if (log_queue.isEmpty()) {
+ log_run = null;
+ break;
+ }
+ c = log_queue.remove();
+ }
+ if (c == '\r')
+ continue;
+ if (c == '\0')
+ continue;
+ String s;
+ if (c == '\n') {
+ s = "\n";
+ log_column = 0;
+ } else if (' ' <= c && c <= '~') {
+ byte[] bytes = new byte[1];
+ bytes[0] = (byte) c;
+ s = new String(bytes, AltosLib.unicode_set);
+ log_column += 1;