altosui: Make flight data download work through TeleBT
authorKeith Packard <keithp@keithp.com>
Tue, 19 Apr 2011 22:29:39 +0000 (15:29 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 19 Apr 2011 22:29:39 +0000 (15:29 -0700)
This required flushing input before reading data blocks and adjusting
some delays.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromChunk.java
altosui/AltosEepromList.java
altosui/AltosEepromLog.java
altosui/libaltos/libaltos.c

index 8eec407df395e4aa3ea3f4265f2a14ce6f7ffa1a..1e42077ff01f5168593ca3df415cedf34b12540a 100644 (file)
@@ -59,6 +59,7 @@ public class AltosEepromChunk {
 
                data = new int[chunk_size];
                address = block * chunk_size;
+               serial_line.flush_input();
                serial_line.printf("e %x\n", block);
 
                for (offset = 0; offset < chunk_size; offset += per_line) {
index 575c0bc2c3f044977468eab46b579166de1f006c..185fec9118a146d228367b8ff813a3ac36383f16 100644 (file)
@@ -114,7 +114,7 @@ public class AltosEepromList extends ArrayList<AltosEepromLog> {
                         */
                        for (AltosEepromFlight flight : flights) {
                                add(new AltosEepromLog(serial_line, config_data.serial,
-                                                      flight.start, flight.end));
+                                                      flight.flight, flight.start, flight.end));
                        }
                } finally {
                        if (remote)
index f7fb39e1e19c33e91ab0ee314007132c17bf212c..0cf420d9c7d2a45b5bf89abb4d32bbfa551c45a0 100644 (file)
@@ -47,7 +47,8 @@ public class AltosEepromLog {
        boolean         delete;
 
        public AltosEepromLog(AltosSerial serial_line, int in_serial,
-                             int in_start_block, int in_end_block)
+                             int in_flight, int in_start_block,
+                             int in_end_block)
                throws InterruptedException, TimeoutException {
 
                int             block;
@@ -73,8 +74,8 @@ public class AltosEepromLog {
                        AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block);
 
                        if (block == in_start_block) {
-                               if (eechunk.data(0) != Altos.AO_LOG_FLIGHT) {
-                                       flight = eechunk.data16(0);
+                               if (eechunk.data16(0) == in_flight) {
+                                       flight = in_flight;
                                        has_flight = true;
                                        break;
                                }
index c5bcf90070682a6f1974300ef916eeef941fc508..5e507cdff2251da8743f82fd8c6c59489b641fb3 100644 (file)
@@ -698,7 +698,7 @@ altos_bt_open(struct altos_bt_device *device)
                perror("connect");
                goto no_link;
        }
-       sleep(2);
+       sleep(1);
 
 #ifdef USE_POLL
        pipe(file->pipe);