Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
authorBdale Garbee <bdale@gag.com>
Thu, 7 Oct 2021 18:11:06 +0000 (12:11 -0600)
committerBdale Garbee <bdale@gag.com>
Thu, 7 Oct 2021 18:11:06 +0000 (12:11 -0600)
12 files changed:
Releasing
altoslib/AltosEepromRecordSet.java
configure.ac
doc/Makefile.am
doc/easymini-release-notes.inc
doc/release-notes-1.9.9.inc [new file with mode: 0644]
doc/release-notes.inc
doc/telegps-release-notes.inc
src/drivers/ao_mmc5983.c
src/drivers/ao_mmc5983.h
src/kernel/ao_config.h
src/kernel/ao_pyro.c

index 555ae122fab2d4822fef66bb935276945d865931..2dda5ec5bb794c07e4281e9e6a5c811efdf8452d 100644 (file)
--- a/Releasing
+++ b/Releasing
@@ -19,6 +19,8 @@ These are Keith's notes on how to do a release
 
        - update the version and date in configure.ac if Bdale hasn't already
 
+       - update the ANDROID_VERSION in configure.ac if releasing AltosDroid
+
        - follow instructions in doc/RELNOTES
 
        - make sure there is a doc/release-notes-<version>.inc
@@ -29,6 +31,7 @@ These are Keith's notes on how to do a release
 
        - confirm doc/header.inc has correct copyright year
 
+
 These are Bdale's notes on how to do a release.
 
        - make sure Debian build environment is up to date
index 2a7d97e3002dc93b662452ed255f912f0f3043cf..3b19ee682ff9b633884c45fdf33584f5447affa6 100644 (file)
@@ -86,6 +86,7 @@ public class AltosEepromRecordSet implements AltosRecordSet {
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
                case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_4:
+               case AltosLib.AO_LOG_FORMAT_TELEMEGA_5:
                        record = new AltosEepromRecordMega(eeprom);
                        break;
                case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
index b00dd70dd6b2d944450ded40b1351fbe15fa0adf..71a334b2eb2ed86fc8b70a3def48e8c262c0de65 100644 (file)
@@ -18,13 +18,13 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([altos], 1.9.8)
-ANDROID_VERSION=29
+AC_INIT([altos], 1.9.9)
+ANDROID_VERSION=31
 AC_CONFIG_SRCDIR([src/kernel/ao.h])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-RELEASE_DATE=2021-09-20
+RELEASE_DATE=2021-10-06
 AC_SUBST(RELEASE_DATE)
 
 DOC_DATE=`LC_ALL=C date -d $RELEASE_DATE +'%d %b %Y'`
index 0f76136ca601ac367290699031b5ef44fa7b3e4c..52c408e367ecec5dde92f1ced747ecf190f6c5e1 100644 (file)
@@ -17,6 +17,7 @@ FAKETIME=TZ=UTC faketime -f '$(RELEASE_DATE) 00:00:00 i0'
 endif
 
 RELNOTES_INC=\
+       release-notes-1.9.9.inc \
        release-notes-1.9.8.inc \
        release-notes-1.9.7.inc \
        release-notes-1.9.6.inc \
index 2549c3cf3542e15f980a7fb09b4bc0b4b880d1c7..a1b4415a9985ebfa38f7a85c66309c367b1e7dde 100644 (file)
@@ -1,5 +1,9 @@
 [appendix]
 == Release Notes
+       :leveloffset: 2
+       include::release-notes-1.9.9.adoc[]
+
+       <<<<
        :leveloffset: 2
        include::release-notes-1.9.8.adoc[]
 
diff --git a/doc/release-notes-1.9.9.inc b/doc/release-notes-1.9.9.inc
new file mode 100644 (file)
index 0000000..2c30772
--- /dev/null
@@ -0,0 +1,39 @@
+= Release Notes for Version 1.9.9
+include::release-head.adoc[]
+:doctype: article
+
+       Version 1.9.9
+
+       This release contains a critical bug fix for a problem
+       introduced in version 1.9.8 for TeleMega and EasyMega
+       boards. This problem occurs when using the stored
+       configuration from 1.9.7 or earlier.
+
+       If you are running 1.9.8 or are upgrading from 1.9.8 on any
+       version of TeleMega or EasyMega, you must reconfigure all pyro
+       channels, recalibrate accelerometers, reset the APRS interval,
+       adjust the beep tone and reset the pyro time.
+
+       == AltOS
+
+       * Fix EasyMega and TeleMega upgrade process from 1.9.7 or
+         earlier.  1.9.8 introduced larger delay values, which
+         required modifying the configuration in-place, and the 1.9.8
+         version had a flaw which broke the pyro channel config and
+         all of the config values beyond that in memory, including
+         APRS interval, IMU accel calibation, beep tone and pyro
+         time.
+
+       * Fix TeleMega v5.0 mag sensor driver. This driver was quite
+         broken due to developing it in the presence of the magnetic
+         beeper on the board. Because of that beeper, the values this
+         sensor records are not accurate. Fortunately, they are not
+         used for controlling the flight.
+
+       == AltosUI
+
+       * Parse TeleMega v5.0 log files. A missing check in the code
+          meant that the TeleMega v5.0 log files would cause an error
+          when attempting to load them. Logs saved with AltosUI
+          1.9.8 were not affected, only the presentation of the data
+          was broken.
index b33e0204a7abc6269024ef9c0a4d6d9c607b3286..4a76c96f09e08a4fd7bfa86475b073f24ce4c679 100644 (file)
@@ -1,5 +1,9 @@
 [appendix]
 == Release Notes
+       :leveloffset: 2
+       include::release-notes-1.9.9.adoc[]
+
+       <<<<
        :leveloffset: 2
        include::release-notes-1.9.8.adoc[]
 
index e4df90e8db89dd01a2e0c4921d6b22a17d5c66d9..90f2e27e0d5947e57414e77e91e3936bedaddc04 100644 (file)
@@ -1,5 +1,9 @@
 [appendix]
 == Release Notes
+       :leveloffset: 2
+       include::release-notes-1.9.9.adoc[]
+
+       <<<<
        :leveloffset: 2
        include::release-notes-1.9.8.adoc[]
 
index 5d97d757f3fd1fedaeafcf300f7428c0de12c060..4dd4a598c2c0ba04a3df2471e89c9b9af49f4e66 100644 (file)
 
 #if HAS_MMC5983
 
+#define DEBUG_MMC5983  0
+
 struct ao_mmc5983_sample       ao_mmc5983_current;
+static struct ao_mmc5983_sample        ao_mmc5983_offset;
 
 static uint8_t ao_mmc5983_configured;
 
@@ -57,20 +60,14 @@ ao_mmc5983_reg_read(uint8_t addr)
 }
 
 static void
-ao_mmc5983_sample(struct ao_mmc5983_sample *sample)
+ao_mmc5983_raw(struct ao_mmc5983_raw *raw)
 {
-       struct ao_mmc5983_raw   raw;
-
        ao_i2c_bit_start(MMC5983_I2C_ADDR);
-       raw.addr = MMC5983_X_OUT_0;
-       ao_i2c_bit_send(&raw.addr, 1);
+       raw->addr = MMC5983_X_OUT_0;
+       ao_i2c_bit_send(&(raw->addr), 1);
        ao_i2c_bit_restart(MMC5983_I2C_ADDR | 1);
-       ao_i2c_bit_recv(&raw.x0, 7);
+       ao_i2c_bit_recv(&(raw->x0), sizeof(*raw) - 1);
        ao_i2c_bit_stop();
-
-       sample->x = raw.x0 << 10 | raw.x1 << 2 | ((raw.xyz2 >> 6) & 3);
-       sample->y = raw.y0 << 10 | raw.y1 << 2 | ((raw.xyz2 >> 4) & 3);
-       sample->z = raw.z0 << 10 | raw.z1 << 2 | ((raw.xyz2 >> 2) & 3);
 }
 
 #else
@@ -126,36 +123,145 @@ ao_mmc5983_duplex(uint8_t *dst, uint8_t len)
 }
 
 static void
-ao_mmc5983_sample(struct ao_mmc5983_sample *sample)
+ao_mmc5983_raw(struct ao_mmc5983_raw *raw)
 {
-       struct ao_mmc5983_raw   raw;
+       raw->addr = MMC5983_X_OUT_0 | MMC5983_READ;
+       ao_mmc5983_duplex((uint8_t *) raw, sizeof (*raw));
+}
+#endif
 
-       raw.addr = MMC5983_X_OUT_0 | MMC5983_READ;
-       ao_mmc5983_duplex((uint8_t *) &raw, sizeof (raw));
+/* Saturating subtraction. Keep the result within range
+ * of an int16_t
+ */
+static int16_t
+sat_sub(int16_t a, int16_t b)
+{
+       int32_t v = (int32_t) a - (int32_t) b;
+       if (v < -32768)
+               v = -32768;
+       if (v > 32767)
+               v = 32767;
+       return v;
+}
 
-       sample->x = raw.x0 << 10 | raw.x1 << 2 | ((raw.xyz2 >> 6) & 3);
-       sample->y = raw.y0 << 10 | raw.y1 << 2 | ((raw.xyz2 >> 4) & 3);
-       sample->z = raw.z0 << 10 | raw.z1 << 2 | ((raw.xyz2 >> 2) & 3);
+/* Wait for a synchronous sample to finish */
+static void
+ao_mmc5983_wait(void)
+{
+       for (;;) {
+               uint8_t status = ao_mmc5983_reg_read(MMC5983_STATUS);
+               if ((status & (1 << MMC5983_STATUS_MEAS_M_DONE)) != 0)
+                       break;
+               ao_delay(0);
+       }
 }
-#endif
 
-static uint8_t product_id;
+static void
+ao_mmc5983_set(void)
+{
+       ao_mmc5983_reg_write(MMC5983_CONTROL_0,
+                            (1 << MMC5983_CONTROL_0_SET));
+}
 
-static uint8_t
-ao_mmc5983_setup(void)
+static void
+ao_mmc5983_reset(void)
 {
+       ao_mmc5983_reg_write(MMC5983_CONTROL_0,
+                            (1 << MMC5983_CONTROL_0_RESET));
+}
 
-       if (ao_mmc5983_configured)
-               return 1;
+static struct ao_mmc5983_raw raw;
 
-       /* Delay for power up time (10ms) */
-       ao_delay(AO_MS_TO_TICKS(10));
+/* Read the sensor values and convert to a sample struct */
+static void
+ao_mmc5983_sample(struct ao_mmc5983_sample *s)
+{
+       ao_mmc5983_raw(&raw);
+
+       /* Bias by 32768 to convert from uint16_t to int16_t */
+       s->x = (int32_t) (((uint16_t) raw.x0 << 8) | raw.x1) - 32768;
+       s->y = (int32_t) (((uint16_t) raw.y0 << 8) | raw.y1) - 32768;
+       s->z = (int32_t) (((uint16_t) raw.z0 << 8) | raw.z1) - 32768;;
+}
+
+/* Synchronously sample the sensors */
+static void
+ao_mmc5983_sync_sample(struct ao_mmc5983_sample *v)
+{
+       ao_mmc5983_reg_write(MMC5983_CONTROL_0,
+                            (1 << MMC5983_CONTROL_0_TM_M));
+       ao_mmc5983_wait();
+       ao_mmc5983_sample(v);
+}
+
+static struct ao_mmc5983_sample        set, reset;
+
+/* Calibrate the device by finding the zero point */
+static void
+ao_mmc5983_cal(void)
+{
+       /* Compute offset */
+
+       ao_delay(AO_MS_TO_TICKS(100));
+
+       /* Measure in 'SET' mode */
+       ao_mmc5983_set();
+       ao_delay(AO_MS_TO_TICKS(100));
+       ao_mmc5983_sync_sample(&set);
+
+       ao_delay(AO_MS_TO_TICKS(100));
+
+       /* Measure in 'RESET' mode */
+       ao_mmc5983_reset();
+       ao_delay(AO_MS_TO_TICKS(100));
+       ao_mmc5983_sync_sample(&reset);
+
+       /* The zero point is the average of SET and RESET values */
+       ao_mmc5983_offset.x = ((int32_t) set.x + (int32_t) reset.x) / 2;
+       ao_mmc5983_offset.y = ((int32_t) set.y + (int32_t) reset.y) / 2;
+       ao_mmc5983_offset.z = ((int32_t) set.z + (int32_t) reset.z) / 2;
+}
+
+/* Configure the device to automatically sample at 200Hz */
+static void
+ao_mmc5983_run(void)
+{
+       /* Set bandwidth to 200Hz */
+       ao_mmc5983_reg_write(MMC5983_CONTROL_1,
+                            MMC5983_CONTROL_1_BW_200 << MMC5983_CONTROL_1_BW);
+
+       /* Measure at 200Hz so we get recent samples by just reading
+        * the registers
+        */
+       ao_mmc5983_reg_write(MMC5983_CONTROL_2,
+                            (1 << MMC5983_CONTROL_2_CMM_EN) |
+                            (MMC5983_CONTROL_2_CM_FREQ_200HZ << MMC5983_CONTROL_2_CM_FREQ) |
+                            (0 << MMC5983_CONTROL_2_EN_PRD_SET) |
+                            (MMC5983_CONTROL_2_PRD_SET_1000));
+       ao_mmc5983_configured = 1;
+}
+
+/* Reboot the device by setting the SW_RST bit and waiting 10ms */
+static void
+ao_mmc5983_reboot(void)
+{
+       ao_mmc5983_configured = 0;
 
        ao_mmc5983_reg_write(MMC5983_CONTROL_1,
                             1 << MMC5983_CONTROL_1_SW_RST);
 
        /* Delay for power up time (10ms) */
        ao_delay(AO_MS_TO_TICKS(10));
+}
+
+/* Configure the device for operation */
+static uint8_t
+ao_mmc5983_setup(void)
+{
+       uint8_t product_id;
+
+       /* Reboot the device */
+       ao_mmc5983_reboot();
 
        /* Check product ID */
        product_id = ao_mmc5983_reg_read(MMC5983_PRODUCT_ID);
@@ -165,18 +271,12 @@ ao_mmc5983_setup(void)
                AO_SENSOR_ERROR(AO_DATA_MMC5983);
        }
 
-       /* Set bandwidth to 200Hz */
-       ao_mmc5983_reg_write(MMC5983_CONTROL_1,
-                            MMC5983_CONTROL_1_BW_200 << MMC5983_CONTROL_1_BW);
+       /* Calibrate */
+       ao_mmc5983_cal();
 
-       /* Measure at 200Hz so we get recent samples by just reading
-        * the registers
-        */
-       ao_mmc5983_reg_write(MMC5983_CONTROL_2,
-                            (1 << MMC5983_CONTROL_2_CMM_EN) |
-                            (MMC5983_CONTROL_2_CM_FREQ_200HZ << MMC5983_CONTROL_2_CM_FREQ));
+       /* Start automatic sampling */
+       ao_mmc5983_run();
 
-       ao_mmc5983_configured = 1;
        return 1;
 }
 
@@ -188,7 +288,11 @@ ao_mmc5983(void)
        struct ao_mmc5983_sample        sample;
        ao_mmc5983_setup();
        for (;;) {
-               ao_mmc5983_sample(&sample);
+               if (ao_mmc5983_configured)
+                       ao_mmc5983_sample(&sample);
+               sample.x = sat_sub(sample.x, ao_mmc5983_offset.x);
+               sample.y = sat_sub(sample.y, ao_mmc5983_offset.y);
+               sample.z = sat_sub(sample.z, ao_mmc5983_offset.z);
                ao_arch_block_interrupts();
                ao_mmc5983_current = sample;
                AO_DATA_PRESENT(AO_DATA_MMC5983);
@@ -202,14 +306,48 @@ static struct ao_task ao_mmc5983_task;
 static void
 ao_mmc5983_show(void)
 {
+#if DEBUG_MMC5983
+       printf ("x0 %02x x1 %02x y0 %02x y1 %02x z0 %02x z1 %02x\n",
+               raw.x0, raw.x1, raw.y0, raw.y1, raw.z0, raw.z1);
+
+       printf ("set.x %d set.y %d set.z %d\n",
+               set.x, set.y, set.z);
+
+       printf ("reset.x %d reset.y %d reset.z %d\n",
+               reset.x, reset.y, reset.z);
+
+       printf ("offset.x %d offset.y %d offset.z %d\n",
+               ao_mmc5983_offset.x,
+               ao_mmc5983_offset.y,
+               ao_mmc5983_offset.z);
+#endif
        printf ("MMC5983: %d %d %d\n",
                ao_mmc5983_along(&ao_mmc5983_current),
                ao_mmc5983_across(&ao_mmc5983_current),
                ao_mmc5983_through(&ao_mmc5983_current));
 }
 
+#if DEBUG_MMC5983
+static void
+ao_mmc5983_recal(void)
+{
+       printf("recal\n"); fflush(stdout);
+       ao_mmc5983_reboot();
+       printf("reboot\n"); fflush(stdout);
+       ao_mmc5983_cal();
+       printf("cal\n"); fflush(stdout);
+       ao_mmc5983_show();
+       printf("show\n"); fflush(stdout);
+       ao_mmc5983_run();
+       printf("run\n"); fflush(stdout);
+}
+#endif
+
 static const struct ao_cmds ao_mmc5983_cmds[] = {
        { ao_mmc5983_show,      "M\0Show MMC5983 status" },
+#if DEBUG_MMC5983
+       { ao_mmc5983_recal,     "m\0Recalibrate MMC5983" },
+#endif
        { 0, NULL }
 };
 
index 7bff54b10cc4961bb3c43e27d064fb8f0072fe0d..103d595f7586c8c9d5bf25f82d6065f545432251 100644 (file)
@@ -142,7 +142,6 @@ struct ao_mmc5983_raw {
        uint8_t         y1;
        uint8_t         z0;
        uint8_t         z1;
-       uint8_t         xyz2;
 };
 
 extern struct ao_mmc5983_sample        ao_mmc5983_current;
index c668b71a1979c418c5f39b145b8e72cb9a65b95e..1d5a0fb022deab4964b97f857769adf66b867ece 100644 (file)
@@ -128,6 +128,70 @@ struct ao_config {
 #endif
 };
 
+struct ao_config_1_24 {
+       uint8_t         major;
+       uint8_t         minor;
+       uint16_t        main_deploy;
+       int16_t         accel_plus_g;           /* changed for minor version 2 */
+       uint8_t         _legacy_radio_channel;
+       char            callsign[AO_MAX_CALLSIGN + 1];
+       uint8_t         apogee_delay;           /* minor version 1 */
+       int16_t         accel_minus_g;          /* minor version 2 */
+       uint32_t        radio_cal;              /* minor version 3 */
+       uint32_t        flight_log_max;         /* minor version 4 */
+       uint8_t         ignite_mode;            /* minor version 5 */
+       uint8_t         pad_orientation;        /* minor version 6 */
+       uint32_t        radio_setting;          /* minor version 7 */
+       uint8_t         radio_enable;           /* minor version 8 */
+       uint8_t         aes_key[AO_AES_LEN];    /* minor version 9 */
+       uint32_t        frequency;              /* minor version 10 */
+       uint16_t        apogee_lockout;         /* minor version 11 */
+#if AO_PYRO_NUM
+       struct ao_pyro_1_24     pyro[AO_PYRO_NUM];      /* minor version 12 */
+#endif
+       uint16_t        aprs_interval;          /* minor version 13 */
+#if HAS_RADIO_POWER
+       uint8_t         radio_power;            /* minor version 14 */
+#endif
+#if HAS_RADIO_AMP
+       uint8_t         radio_amp;              /* minor version 14 */
+#endif
+#if HAS_IMU
+       int16_t         accel_zero_along;       /* minor version 15 */
+       int16_t         accel_zero_across;      /* minor version 15 */
+       int16_t         accel_zero_through;     /* minor version 15 */
+#endif
+#if HAS_BEEP
+       uint8_t         mid_beep;               /* minor version 16 */
+#endif
+#if HAS_TRACKER
+       uint16_t        tracker_motion;         /* minor version 17 */
+       uint8_t         tracker_interval;       /* minor version 17 */
+#endif
+#if AO_PYRO_NUM
+       uint16_t        pyro_time;              /* minor version 18 */
+#endif
+#if HAS_APRS
+       uint8_t         aprs_ssid;              /* minor version 19 */
+#endif
+#if HAS_RADIO_RATE
+       uint8_t         radio_rate;             /* minor version 20 */
+#endif
+#if HAS_RADIO_FORWARD
+       uint32_t        send_frequency;         /* minor version 21 */
+#endif
+#if HAS_APRS
+       uint8_t         aprs_format;            /* minor version 22 */
+#endif
+#if HAS_FIXED_PAD_BOX
+       uint8_t         pad_box;                /* minor version 22 */
+       uint8_t         pad_idle;               /* minor version 23 */
+#endif
+#if HAS_APRS
+       uint8_t         aprs_offset;            /* minor version 24 */
+#endif
+};
+
 #define AO_APRS_FORMAT_COMPRESSED      0
 #define AO_APRS_FORMAT_UNCOMPRESSED    1
 #define AO_CONFIG_DEFAULT_APRS_FORMAT  AO_APRS_FORMAT_COMPRESSED
index 07a8278d560a85f4d913ccf7a735645131d31cc6..6160410000d9d0af2a5733a811e67d38c1c73ab4 100644 (file)
@@ -640,18 +640,22 @@ ao_pyro_update_version(void)
 
                /* First, move all of the config bits that follow the pyro data */
 
-               char    *pyro_base = (void *) &ao_config.pyro;
-               char    *after_pyro_new = pyro_base + AO_PYRO_NUM * sizeof (struct ao_pyro);
-               char    *after_pyro_1_24 = pyro_base + AO_PYRO_NUM * sizeof (struct ao_pyro_1_24);
-               char    *config_end = (void *) (&ao_config + 1);
-               size_t  to_move = config_end - after_pyro_new;
+               struct ao_config_1_24 *ao_config_1_24 = (void *) &ao_config;
+               struct ao_pyro          *pyro_1_25 = &ao_config.pyro[0];
+               struct ao_pyro_1_24     *pyro_1_24 = &(ao_config_1_24->pyro)[0];
 
-               memmove(after_pyro_new, after_pyro_1_24, to_move);
 
-               /* Now, adjust all of the pyro entries */
+               char    *pyro_base_1_25 = (void *) pyro_1_25;
+               char    *pyro_base_1_24 = (void *) pyro_1_24;
+               char    *after_pyro_1_25 = pyro_base_1_25 + AO_PYRO_NUM * sizeof (struct ao_pyro);
+               char    *after_pyro_1_24 = pyro_base_1_24 + AO_PYRO_NUM * sizeof (struct ao_pyro_1_24);
+
+               char    *config_end_1_25 = (void *) (&ao_config + 1);
+               size_t  to_move = config_end_1_25 - after_pyro_1_25;
 
-               struct ao_pyro          *pyro_new = ao_config.pyro;
-               struct ao_pyro_1_24     *pyro_old = (void *) ao_config.pyro;
+               memmove(after_pyro_1_25, after_pyro_1_24, to_move);
+
+               /* Now, adjust all of the pyro entries */
 
                int p = AO_PYRO_NUM;
 
@@ -664,15 +668,15 @@ ao_pyro_update_version(void)
                        struct ao_pyro  tmp;
 
                        memset(&tmp, '\0', sizeof(tmp));
-                       tmp.flags = pyro_old[p].flags;
+                       tmp.flags = pyro_1_24[p].flags;
 
                        for (v = 0; v < NUM_PYRO_VALUES; v++)
                        {
-                               value = ao_pyro_get_1_24(&pyro_old[v], ao_pyro_values[v].flag);
+                               value = ao_pyro_get_1_24(&pyro_1_24[p], ao_pyro_values[v].flag);
                                ao_pyro_put(&tmp, ao_pyro_values[v].offset,
                                            ao_pyro_size(ao_pyro_values[v].flag), value);
                        }
-                       memcpy(&pyro_new[p], &tmp, sizeof(tmp));
+                       memcpy(&pyro_1_25[p], &tmp, sizeof(tmp));
                }
        }
 }