altosui: Eliminate inter-chunk flush_input calls
authorKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 04:09:19 +0000 (21:09 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 04:09:19 +0000 (21:09 -0700)
Once the serial line is nicely synchronized, we don't need to flush
input between chunks. This speeds up eeprom downloading quite a bit.

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

index fb632a3f50fd6f8b9b8964ae3cefb33221d47eef..59767c2aa60d1bad4eb355d71bdfda58de8d330f 100644 (file)
@@ -59,14 +59,15 @@ public class AltosEepromChunk {
                return true;
        }
 
-       public AltosEepromChunk(AltosSerial serial_line, int block)
+       public AltosEepromChunk(AltosSerial serial_line, int block, boolean flush)
                throws TimeoutException, InterruptedException {
 
                int     offset;
 
                data = new int[chunk_size];
                address = block * chunk_size;
-               serial_line.flush_input();
+               if (flush)
+                       serial_line.flush_input();
                serial_line.printf("e %x\n", block);
 
                for (offset = 0; offset < chunk_size; offset += per_line) {
index 6112a3b1cdce943febb0e87eb8b2d247ee71ad08..b44a1451b241db864a3790df8ff00389e95678a3 100644 (file)
@@ -275,7 +275,7 @@ public class AltosEepromDownload implements Runnable {
                for (block = log.start_block; !done && block < log.end_block; block++) {
                        monitor.set_value(Altos.state_to_string[state], state, block - state_block);
 
-                       AltosEepromChunk        eechunk = new AltosEepromChunk(serial_line, block);
+                       AltosEepromChunk        eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block);
 
                        /*
                         * Guess what kind of data is there if the device
index be2549cb84dafed1af59c61c0f48f8e43164b38c..ee77e5c84046fee5f1e4a4fa75e00b7cd8932948 100644 (file)
@@ -82,7 +82,7 @@ public class AltosEepromLog {
                                in_end_block = in_start_block + 2;
 
                        for (block = in_start_block; block < in_end_block; block++) {
-                               AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block);
+                               AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == in_start_block);
 
                                for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) {
                                        try {