altos/altosui: Report log format in the version command
authorKeith Packard <keithp@keithp.com>
Sat, 13 Aug 2011 04:43:56 +0000 (21:43 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 01:44:26 +0000 (18:44 -0700)
This will make it easier to figure out what the contents of the flash
should look like from altosui; the current 'guessing' mechanism will
not scale to many more formats.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/Altos.java
altosui/AltosConfig.java
altosui/AltosConfigData.java
altosui/AltosEepromDownload.java
altosui/AltosEepromRecord.java
src/ao.h
src/ao_cmd.c
src/ao_log.c
src/ao_log_tiny.c
src/ao_telebt.c

index 73dc746..416d932 100644 (file)
@@ -51,6 +51,7 @@ public class Altos {
        static final int AO_LOG_MANUFACTURER = 2000;
        static final int AO_LOG_PRODUCT = 2001;
        static final int AO_LOG_SERIAL_NUMBER = 2002;
+       static final int AO_LOG_LOG_FORMAT = 2003;
        static final int AO_LOG_SOFTWARE_VERSION = 9999;
 
        /* Added to flag invalid records */
@@ -177,6 +178,13 @@ public class Altos {
        static final int AO_GPS_NUM_SAT_SHIFT = 0;
        static final int AO_GPS_NUM_SAT_MASK = 0xf;
 
+       static final int AO_LOG_FORMAT_UNKNOWN = 0;
+       static final int AO_LOG_FORMAT_FULL = 1;
+       static final int AO_LOG_FORMAT_TINY = 2;
+       static final int AO_LOG_FORMAT_TELEMETRY = 3;
+       static final int AO_LOG_FORMAT_TELESCIENCE = 4;
+       static final int AO_LOG_FORMAT_NONE = 127;
+
        static boolean isspace(int c) {
                switch (c) {
                case ' ':
@@ -404,12 +412,36 @@ public class Altos {
                return 0x000e;
        }
 
+       static int usb_product_telelaunch() {
+               load_library();
+               return 0x000f;
+       }
+
+       static int usb_product_telelco() {
+               load_library();
+               return 0x0010;
+       }
+
+       static int usb_product_telescience() {
+               load_library();
+               return 0x0011;
+       }
+
+       static int usb_product_telepyro() {
+               load_library();
+               return 0x0012;
+       }
+
        public final static int vendor_altusmetrum = usb_vendor_altusmetrum();
        public final static int product_altusmetrum = usb_product_altusmetrum();
        public final static int product_telemetrum = usb_product_telemetrum();
        public final static int product_teledongle = usb_product_teledongle();
        public final static int product_teleterra = usb_product_teleterra();
        public final static int product_telebt = usb_product_telebt();
+       public final static int product_telelaunch = usb_product_telelaunch();
+       public final static int product_tele10 = usb_product_telelco();
+       public final static int product_telescience = usb_product_telescience();
+       public final static int product_telepyro = usb_product_telepyro();
        public final static int product_altusmetrum_min = usb_product_altusmetrum_min();
        public final static int product_altusmetrum_max = usb_product_altusmetrum_max();
 
index 7312ea6..ffabe20 100644 (file)
@@ -67,6 +67,7 @@ public class AltosConfig implements ActionListener {
        AltosConfigData remote_config_data;
        double          remote_frequency;
        int_ref         serial;
+       int_ref         log_format;
        int_ref         main_deploy;
        int_ref         apogee_delay;
        int_ref         radio_channel;
@@ -153,6 +154,7 @@ public class AltosConfig implements ActionListener {
                        return;
                }
                get_int(line, "serial-number", serial);
+               get_int(line, "log-format", log_format);
                get_int(line, "Main deploy:", main_deploy);
                get_int(line, "Apogee delay:", apogee_delay);
                get_int(line, "Radio channel:", radio_channel);
@@ -374,6 +376,7 @@ public class AltosConfig implements ActionListener {
                owner = given_owner;
 
                serial = new int_ref(0);
+               log_format = new int_ref(Altos.AO_LOG_FORMAT_UNKNOWN);
                main_deploy = new int_ref(250);
                apogee_delay = new int_ref(0);
                radio_channel = new int_ref(0);
index 016033a..710231d 100644 (file)
@@ -36,6 +36,7 @@ public class AltosConfigData implements Iterable<String> {
        String  manufacturer;
        String  product;
        String  version;
+       int     log_format;
        int     serial;
 
        /* Strings returned */
@@ -94,6 +95,7 @@ public class AltosConfigData implements Iterable<String> {
                                continue;
                        lines.add(line);
                        try { serial = get_int(line, "serial-number"); } catch (Exception e) {}
+                       try { log_format = get_int(line, "log-format"); } catch (Exception e) {}
                        try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {}
                        try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {}
                        try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {}
index 64dcdff..417aab0 100644 (file)
@@ -89,9 +89,6 @@ public class AltosEepromDownload implements Runnable {
                }
        }
 
-       static final int        log_full = 1;
-       static final int        log_tiny = 2;
-
        boolean                 done;
        int                     state;
 
@@ -186,7 +183,7 @@ public class AltosEepromDownload implements Runnable {
 
        void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException {
                int                     block, state_block = 0;
-               int                     log_style = 0;
+               int                     log_format = flights.config_data.log_format;
 
                state = 0;
                done = false;
@@ -215,21 +212,24 @@ public class AltosEepromDownload implements Runnable {
                        AltosEepromChunk        eechunk = new AltosEepromChunk(serial_line, block);
 
                        /*
-                        * Figure out what kind of data is there
+                        * Guess what kind of data is there if the device
+                        * didn't tell us
                         */
 
-                       if (block == log.start_block) {
-                               if (eechunk.data(0) == Altos.AO_LOG_FLIGHT)
-                                       log_style = log_full;
-                               else
-                                       log_style = log_tiny;
+                       if (log_format == Altos.AO_LOG_FORMAT_UNKNOWN) {
+                               if (block == log.start_block) {
+                                       if (eechunk.data(0) == Altos.AO_LOG_FLIGHT)
+                                               log_format = Altos.AO_LOG_FORMAT_FULL;
+                                       else
+                                               log_format = Altos.AO_LOG_FORMAT_TINY;
+                               }
                        }
 
-                       switch (log_style) {
-                       case log_full:
+                       switch (log_format) {
+                       case Altos.AO_LOG_FORMAT_FULL:
                                CaptureFull(eechunk);
                                break;
-                       case log_tiny:
+                       case Altos.AO_LOG_FORMAT_TINY:
                                CaptureTiny(eechunk);
                                break;
                        }
index 52acb43..c0f9703 100644 (file)
@@ -143,6 +143,9 @@ public class AltosEepromRecord {
                                } else if (tokens[0].equals("serial-number")) {
                                        cmd = Altos.AO_LOG_SERIAL_NUMBER;
                                        a = Integer.parseInt(tokens[1]);
+                               } else if (tokens[0].equals("log-format")) {
+                                       cmd = Altos.AO_LOG_LOG_FORMAT;
+                                       a = Integer.parseInt(tokens[1]);
                                } else if (tokens[0].equals("software-version")) {
                                        cmd = Altos.AO_LOG_SOFTWARE_VERSION;
                                        data = tokens[1];
index 0699fc2..1c8f5bb 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -539,6 +539,15 @@ extern __pdata enum flight_state ao_log_state;
 
 /* required functions from the underlying log system */
 
+#define AO_LOG_FORMAT_UNKNOWN          0       /* unknown; altosui will have to guess */
+#define AO_LOG_FORMAT_FULL             1       /* 8 byte typed log records */
+#define AO_LOG_FORMAT_TINY             2       /* two byte state/baro records */
+#define AO_LOG_FORMAT_TELEMETRY                3       /* 32 byte ao_telemetry records */
+#define AO_LOG_FORMAT_TELESCIENCE      4       /* 32 byte typed telescience records */
+#define AO_LOG_FORMAT_NONE             127     /* No log at all */
+
+extern __code uint8_t ao_log_format;
+
 /* Return the flight number from the given log slot, 0 if none */
 uint16_t
 ao_log_flight(uint8_t slot);
index 6d3ae38..1442ebe 100644 (file)
@@ -219,6 +219,9 @@ version(void)
        printf("manufacturer     %s\n", ao_manufacturer);
        printf("product          %s\n", ao_product);
        printf("serial-number    %u\n", ao_serial_number);
+#if HAS_EEPROM
+       printf("log-format       %u\n", ao_log_format);
+#endif
        printf("software-version %s\n", ao_version);
 }
 
index 80d7243..6d3ad53 100644 (file)
@@ -24,6 +24,8 @@ __xdata uint8_t       ao_log_running;
 __pdata enum flight_state ao_log_state;
 __xdata uint16_t ao_flight_number;
 
+__code uint8_t ao_log_format = AO_LOG_FORMAT_FULL;
+
 void
 ao_log_flush(void)
 {
index d26e008..d5a3b99 100644 (file)
@@ -28,6 +28,8 @@ static __data uint16_t        ao_log_tiny_interval;
 #define AO_PAD_RING    2
 #endif
 
+__code uint8_t ao_log_format = AO_LOG_FORMAT_TINY;
+
 void
 ao_log_tiny_set_interval(uint16_t ticks)
 {
index 8e77c4d..8556517 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "ao.h"
 
+__code uint8_t ao_log_format = AO_LOG_FORMAT_NONE;     /* until we actually log stuff */
+
 void
 main(void)
 {