altos/test: Get the flight software test code working again
authorKeith Packard <keithp@keithp.com>
Sun, 12 May 2024 00:52:20 +0000 (17:52 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 12 May 2024 02:04:45 +0000 (19:04 -0700)
This had gotten very stale; much hacking was required. I know the
TeleMega v4 code works, other things "might". At least it seems to
build without errors?

Signed-off-by: Keith Packard <keithp@keithp.com>
13 files changed:
src/Makefile
src/kernel/ao_config.h
src/kernel/ao_convert_pa_test.c
src/kernel/ao_convert_test.c
src/kernel/ao_host.h
src/test/Makefile
src/test/ao_fat_test.c
src/test/ao_flight_test.c
src/test/ao_gps_test.c
src/test/ao_gps_test_skytraq.c
src/test/ao_gps_test_ublox.c
src/test/ao_micropeak_test.c
src/test/plotmm

index c89ac0e0b52ea36094529a9c04fe10881eb21370..b3a3066c34dab114b6dcac5791eada88f6d87005 100644 (file)
@@ -63,7 +63,7 @@ ARMM0DIRS=\
 AVRDIRS=\
        micropeak microkite microsplash
 
-SUBDIRS=draw
+SUBDIRS=draw test
 
 ifeq ($(strip $(HAVE_ARM_M3_CC)),yes)
 SUBDIRS+=$(ARMM3DIRS)
index a8541775ae807272947dbd66b357c05ec2e2ef61..6896eaa973161375adf553c519369eac03ee8e45 100644 (file)
@@ -19,7 +19,9 @@
 #ifndef _AO_CONFIG_H_
 #define _AO_CONFIG_H_
 
+#ifndef AO_FLIGHT_TEST
 #include <ao.h>
+#endif
 
 #if AO_PYRO_NUM
 #include <ao_pyro.h>
index e0ee2928cfa8fd569e260fc05d46161b1d6eefba..e1ca0bf7bb01ee123ec146c2b03aaf9855a525fb 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdint.h>
 #define AO_CONVERT_TEST
+#define AO_TICK_TYPE uint32_t
 typedef int32_t alt_t;
 typedef int32_t pres_t;
 #include "ao_host.h"
index c8debbc57d2df707a3fb1989842bc589d082387d..f3eb0178d1bbe0e9fa882872afcab823a66c959f 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <stdint.h>
+#define AO_TICK_TYPE uint32_t
 #define AO_CONVERT_TEST
 #define AO_NEED_ALTITUDE_TO_PRES 1
 #include "ao_host.h"
index c974a9fe5f1e37c89261245bfa3ab945d1b8bdbf..30df8edc0e66ffc7cc7f610adc57103edbfd881c 100644 (file)
@@ -81,12 +81,20 @@ struct ao_task {
        int dummy;
 };
 
+enum ao_igniter_status {
+       ao_igniter_unknown,     /* unknown status (ambiguous voltage) */
+       ao_igniter_ready,       /* continuity detected */
+       ao_igniter_active,      /* igniter firing */
+       ao_igniter_open,        /* open circuit detected */
+};
+
 #define ao_add_task(t,f,n)
 
 #define ao_log_start()
 #define ao_log_stop()
 
 #define AO_MS_TO_TICKS(ms)     ((ms) / 10)
+#define AO_NS_TO_TICKS(ns)     ((ns) / (10000000L))
 #define AO_SEC_TO_TICKS(s)     ((s) * 100)
 
 #define AO_FLIGHT_TEST
index 55a3fbeb5abda9c98d7bffc7b7e587bd575a092e..2c74780d1fac362f6a9305ac7190196279cc1c9b 100644 (file)
@@ -3,11 +3,12 @@ vpath %.c ..:../kernel:../drivers:../util:../micropeak:../aes:../product
 vpath %.h ..:../kernel:../drivers:../util:../micropeak:../aes:../product
 vpath make-kalman ..:../kernel:../drivers:../util:../micropeak:../aes:../product
 
-PROGS=ao_flight_test ao_flight_test_baro ao_flight_test_accel ao_flight_test_noisy_accel ao_flight_test_mm \
+PROGS=ao_flight_test_mm \
        ao_flight_test_metrum ao_flight_test_mini \
        ao_gps_test ao_gps_test_skytraq ao_gps_test_ublox ao_convert_test ao_convert_pa_test ao_fec_test \
        ao_aprs_test ao_micropeak_test ao_fat_test ao_aes_test ao_int64_test \
-       ao_ms5607_convert_test ao_quaternion_test
+       ao_ms5607_convert_test ao_quaternion_test \
+       ao_flight_test_tmega4
 
 INCS=ao_kalman.h ao_ms5607.h ao_log.h ao_data.h altitude-pa.h altitude.h ao_quaternion.h ao_eeprom_read.h
 TEST_SRC=ao_flight_test.c
@@ -16,7 +17,7 @@ TEST_LIB=-ljson-c
 
 KALMAN=make-kalman 
 
-CFLAGS=-I.. -I. -I../kernel -I../drivers -I../micropeak -I../product -I../lisp -O0 -g -Wall -DAO_LISP_TEST -no-pie
+CFLAGS=-I.. -I. -I../kernel -I../drivers -I../product -I../lisp -O0 -g -Wall -DAO_LISP_TEST -no-pie
 
 all: $(PROGS) ao_aprs_data.wav
 
@@ -40,6 +41,9 @@ ao_flight_test_accel: $(TEST_SRC_ALL) ao_host.h ao_flight.c  ao_sample.c ao_kalm
 ao_flight_test_mm: $(TEST_SRC_ALL) ao_host.h ao_flight.c ao_sample.c ao_kalman.c ao_pyro.c ao_pyro.h $(INCS)
        cc -DTELEMEGA=1 $(CFLAGS) -o $@ $(TEST_SRC)  $(TEST_LIB) -lm
 
+ao_flight_test_tmega4: $(TEST_SRC_ALL) ao_host.h ao_flight.c ao_sample.c ao_kalman.c ao_pyro.c ao_pyro.h $(INCS)
+       cc -DTELEMEGA_V4=1 $(CFLAGS) -o $@ $(TEST_SRC)  $(TEST_LIB) -lm
+
 ao_flight_test_metrum: $(TEST_SRC_ALL) ao_host.h ao_flight.c ao_sample.c ao_kalman.c ao_pyro.c ao_pyro.h $(INCS)
        cc -DTELEMETRUM_V2=1 $(CFLAGS) -o $@ $(TEST_SRC)  $(TEST_LIB) -lm
 
@@ -86,7 +90,7 @@ ao_micropeak_test: ao_micropeak_test.c ao_microflight.c ao_kalman.h
        cc $(CFLAGS) -o $@ ao_micropeak_test.c -lm
 
 ao_fat_test: ao_fat_test.c ao_fat.c ao_bufio.c
-       cc $(CFLAGS) -o $@ ao_fat_test.c -lssl -lcrypto
+       cc $(CFLAGS) -o $@ ao_fat_test.c -Wno-deprecated-declarations -lssl -lcrypto
 
 ao_aes_test: ao_aes_test.c ao_aes.c ao_aes_tables.c
        cc $(CFLAGS) -o $@ ao_aes_test.c
index 63be71c6b378b6b0424bf7cc3ff708ce278a5dc4..dc6337fc29b917e4987a443297623d680523617d 100644 (file)
@@ -485,7 +485,7 @@ long_test_fs(void)
                }
        }
 
-       printf ("\n   **** Write IO: read %llu write %llu data sectors %llu\n", total_reads, total_writes, (total_file_size + 511) / 512);
+       printf ("\n   **** Write IO: read %lu write %lu data sectors %lu\n", total_reads, total_writes, (total_file_size + 511) / 512);
 
        check_bufio("all files created");
        printf ("   **** All done creating files\n");
@@ -518,7 +518,7 @@ long_test_fs(void)
                        check_bufio("file shown");
                }
        }
-       printf ("\n  **** Read IO: read %llu write %llu\n", total_reads, total_writes);
+       printf ("\n  **** Read IO: read %lu write %lu\n", total_reads, total_writes);
 }
 
 char *params[] = {
index fc1dfa8fe6b759b1def1caccc3ffdfa78429210b..e49035b52997abfaf68dfecca0ff25a5dc8b3941 100644 (file)
 #include <math.h>
 #define log ao_log_data
 
+#define AO_TICK_TYPE   uint32_t
+#define AO_TICK_SIGNED int32_t
+
+typedef int32_t pres_t;
+#define pres_to_altitude(p) ao_pa_to_altitude(p)
+#define ao_data_pres_cook(packet) ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked)
+#define ao_data_pres(packet) ((packet)->ms5607_cooked.pres)
+#define AO_ADC_MAX     4095
+#define AO_PYRO_BATTERY_DIV_PLUS       100
+#define AO_PYRO_BATTERY_DIV_MINUS      27
+#define AO_IGNITE_DIV_PLUS     100
+#define AO_IGNITE_DIV_MINUS    27
+#define AO_ADC_REFERENCE_DV    33
+
 #define GRAVITY 9.80665
 
 #define AO_HERTZ       100
@@ -48,7 +62,7 @@
 
 int ao_gps_new;
 
-#if !defined(TELEMEGA) && !defined(TELEMETRUM_V2) && !defined(EASYMINI) && !defined(EASYMOTOR_V_2)
+#if !defined(TELEMEGA) && !defined(TELEMETRUM_V2) && !defined(EASYMINI) && !defined(EASYMOTOR_V_2) && !defined(TELEMEGA_V4)
 #define TELEMETRUM_V1 1
 #endif
 
@@ -71,6 +85,49 @@ struct ao_adc {
 };
 #endif
 
+#if TELEMEGA_V4
+#define AO_ADC_NUM_SENSE       6
+#define HAS_MS5607             1
+#define HAS_BMX160             1
+#define HAS_ADXL375            1
+#define AO_ADXL375_INVERT      1
+#define AO_ADXL375_AXIS                x
+#define HAS_BEEP               1
+#define HAS_BARO               1
+#define AO_CONFIG_MAX_SIZE     1024
+
+struct ao_adc {
+       int16_t                 sense[AO_ADC_NUM_SENSE];
+       int16_t                 v_batt;
+       int16_t                 v_pbatt;
+       int16_t                 temp;
+};
+
+#define ao_data_along(packet)  ((packet)->bmx160.acc_x)
+#define ao_data_across(packet) (-(packet)->bmx160.acc_y)
+#define ao_data_through(packet)        ((packet)->bmx160.acc_z)
+
+#define ao_data_roll(packet)   ((packet)->bmx160.gyr_x)
+#define ao_data_pitch(packet)  (-(packet)->bmx160.gyr_y)
+#define ao_data_yaw(packet)    ((packet)->bmx160.gyr_z)
+
+#define ao_data_mag_along(packet)      ((packet)->bmx160.mag_x)
+#define ao_data_mag_across(packet)     ((packet)->bmx160.mag_y)
+#define ao_data_mag_through(packet)    ((packet)->bmx160.mag_z)
+
+#define ao_data_set_along(packet,v)    ((packet)->bmx160.acc_x = (v))
+#define ao_data_set_across(packet,v)   ((packet)->bmx160.acc_y = -(v))
+#define ao_data_set_through(packet,v)  ((packet)->bmx160.acc_z = (v))
+
+#define ao_data_set_roll(packet,v)     ((packet)->bmx160.gyr_x = (v))
+#define ao_data_set_pitch(packet,v)    ((packet)->bmx160.gyr_y = -(v))
+#define ao_data_set_yaw(packet,v)      ((packet)->bmx160.gyr_z = (v))
+
+#define ao_data_set_mag_along(packet,v)        ((packet)->bmx160.mag_x = (v))
+#define ao_data_set_mag_across(packet,v)       ((packet)->bmx160.mag_y = (v))
+#define ao_data_set_mag_through(packet,v)      ((packet)->bmx160.mag_z = (v))
+#endif
+
 #if TELEMETRUM_V2
 #define AO_ADC_NUM_SENSE       2
 #define HAS_MS5607             1
@@ -149,7 +206,7 @@ struct ao_adc {
 #define HAS_USB 1
 #define HAS_GPS 1
 
-int16_t
+AO_TICK_TYPE
 ao_time(void);
 
 void
@@ -158,12 +215,19 @@ ao_dump_state(void);
 #define ao_tick_count  (ao_time())
 #define ao_wakeup(wchan) ao_dump_state()
 
+enum ao_igniter_status {
+       ao_igniter_unknown,     /* unknown status (ambiguous voltage) */
+       ao_igniter_ready,       /* continuity detected */
+       ao_igniter_active,      /* igniter firing */
+       ao_igniter_open,        /* open circuit detected */
+};
+
 #include <ao_data.h>
 #include <ao_log.h>
 #include <ao_telemetry.h>
 #include <ao_sample.h>
 
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
 int ao_gps_count;
 struct ao_telemetry_location ao_gps_first;
 struct ao_telemetry_location ao_gps_prev;
@@ -289,12 +353,12 @@ double    drogue_time;
 int    main_height;
 double main_time;
 
-int    tick_offset;
+uint32_t       tick_offset;
 
 static ao_k_t  ao_k_height;
 static double  simple_speed;
 
-int16_t
+AO_TICK_TYPE
 ao_time(void)
 {
        return ao_data_static.tick;
@@ -360,12 +424,12 @@ struct ao_cmds {
 };
 
 #define AO_NEED_ALTITUDE_TO_PRES 1
-#if TELEMEGA || TELEMETRUM_V2 || EASYMINI
+#if TELEMEGA || TELEMETRUM_V2 || EASYMINI || TELEMEGA_V4
 #include "ao_convert_pa.c"
 #include <ao_ms5607.h>
 struct ao_ms5607_prom  ao_ms5607_prom;
 #include "ao_ms5607_convert.c"
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
 #define AO_PYRO_NUM    4
 #include <ao_pyro.h>
 #endif
@@ -388,7 +452,7 @@ extern int16_t ao_accel_2g;
 typedef int16_t        accel_t;
 
 uint16_t       ao_serial_number;
-int16_t                ao_flight_number;
+uint16_t       ao_flight_number;
 
 extern AO_TICK_TYPE    ao_sample_tick;
 
@@ -406,6 +470,7 @@ double ao_sample_qangle;
 
 AO_TICK_TYPE   ao_sample_prev_tick;
 AO_TICK_TYPE   prev_tick;
+AO_TICK_TYPE   start_tick;
 
 
 #include "ao_kalman.c"
@@ -413,7 +478,7 @@ AO_TICK_TYPE        prev_tick;
 #include "ao_sample.c"
 #include "ao_flight.c"
 #include "ao_data.c"
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
 #define AO_PYRO_NUM    4
 
 #define AO_PYRO_0      0
@@ -426,7 +491,6 @@ AO_TICK_TYPE        prev_tick;
 static void
 ao_pyro_pin_set(uint8_t pin, uint8_t value)
 {
-       printf ("set pyro %d %d\n", pin, value);
 }
 
 #include "ao_pyro.c"
@@ -459,6 +523,9 @@ static uint16_t     pyros_fired;
 #if HAS_MPU6000
 static struct ao_mpu6000_sample        ao_ground_mpu6000;
 #endif
+#if HAS_BMX160
+static struct ao_bmx160_sample ao_ground_bmx160;
+#endif
 
 void
 ao_test_exit(void)
@@ -497,7 +564,7 @@ ao_test_exit(void)
        exit(0);
 }
 
-#ifdef TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
 struct ao_azel {
        int     az;
        int     el;
@@ -529,9 +596,9 @@ ao_insert(void)
 #endif
 
                (void) accel;
-               if (!tick_offset)
-                       tick_offset = -ao_data_static.tick;
-               if ((prev_tick - ao_data_static.tick) > 0x400)
+               if (!start_tick)
+                       start_tick = ao_data_static.tick;
+               if ((AO_TICK_SIGNED) (prev_tick - ao_data_static.tick) > 0x400)
                        tick_offset += 65536;
                if (prev_tick) {
                        int ticks = ao_data_static.tick - prev_tick;
@@ -540,11 +607,11 @@ ao_insert(void)
                        simple_speed += accel * ticks / 100.0;
                }
                prev_tick = ao_data_static.tick;
-               time = (double) (ao_data_static.tick + tick_offset) / 100;
+               time = (double) (ao_data_static.tick + tick_offset - start_tick) / 100;
 
                double height = 0;
 #if HAS_BARO
-#if TELEMEGA || TELEMETRUM_V2 || EASYMINI
+#if TELEMEGA || TELEMETRUM_V2 || EASYMINI || TELEMEGA_V4
                ao_ms5607_convert(&ao_data_static.ms5607_raw, &ao_data_static.ms5607_cooked);
                height = ao_pa_to_altitude(ao_data_static.ms5607_cooked.pres) - ao_ground_height;
 
@@ -589,7 +656,7 @@ ao_insert(void)
                }
 
                if (!ao_summary) {
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
                        static struct ao_quaternion     ao_ground_mag;
                        static int                      ao_ground_mag_set;
 
@@ -680,10 +747,10 @@ ao_insert(void)
 #if 1
                        printf("%7.2f height %8.2f accel %8.3f accel_speed %8.3f "
                               "state %d k_height %8.2f k_speed %8.3f k_accel %8.3f avg_height %5d drogue %4d main %4d error %5d"
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
                               " angle %5d "
                               "accel_x %8.3f accel_y %8.3f accel_z %8.3f gyro_x %8.3f gyro_y %8.3f gyro_z %8.3f mag_x %8d mag_y %8d, mag_z %8d mag_angle %4d "
-                              "avg_accel %8.3f "
+                              "avg_accel %8.3f pyro %d inhibited %d"
 #endif
                               "\n",
                               time,
@@ -711,7 +778,26 @@ ao_insert(void)
                               ao_data_static.hmc5883.y,
                               ao_data_static.hmc5883.z,
                               ao_mag_angle,
-                              ao_coast_avg_accel / 16.0
+                              ao_coast_avg_accel / 16.0,
+                              ao_pyro_fired * 10,
+                              ao_pyro_inhibited * 10
+#endif
+#if TELEMEGA_V4
+                              , ao_sample_orient,
+
+                              ao_bmx160_accel(ao_data_static.bmx160.acc_x),
+                              ao_bmx160_accel(ao_data_static.bmx160.acc_y),
+                              ao_bmx160_accel(ao_data_static.bmx160.acc_z),
+                              ao_bmx160_gyro(ao_data_static.bmx160.gyr_x - ao_ground_bmx160.gyr_x),
+                              ao_bmx160_gyro(ao_data_static.bmx160.gyr_y - ao_ground_bmx160.gyr_y),
+                              ao_bmx160_gyro(ao_data_static.bmx160.gyr_z - ao_ground_bmx160.gyr_z),
+                              ao_data_static.bmx160.mag_x,
+                              ao_data_static.bmx160.mag_y,
+                              ao_data_static.bmx160.mag_z,
+                              ao_mag_angle,
+                              ao_coast_avg_accel / 16.0,
+                              ao_pyro_fired * 10,
+                              ao_pyro_inhibited * 10
 #endif
                                );
 #endif
@@ -769,7 +855,7 @@ void
 ao_sleep(void *wchan)
 {
        if (wchan == &ao_data_head) {
-#if TELEMEGA
+#if TELEMEGA || TELEMEGA_V4
                if (ao_flight_state >= ao_flight_boost && ao_flight_state < ao_flight_landed)
                        ao_pyro_check();
 #endif
@@ -780,6 +866,9 @@ ao_sleep(void *wchan)
 #if TELEMEGA
                                ao_data_static.mpu6000 = ao_ground_mpu6000;
 #endif
+#if TELEMEGA_V4
+                               ao_data_static.bmx160 = ao_ground_bmx160;
+#endif
 #if TELEMETRUM_V1
                                ao_data_static.adc.accel = ao_flight_ground_accel;
 #endif
@@ -792,7 +881,7 @@ ao_sleep(void *wchan)
                        }
 
                        if (eeprom) {
-#if TELEMEGA || EASYMOTOR_V_2
+#if TELEMEGA || EASYMOTOR_V_2 || TELEMEGA_V4
                                struct ao_log_mega      *log_mega;
 #endif
 #if EASYMOTOR_V_2
@@ -892,6 +981,102 @@ ao_sleep(void *wchan)
                                        }
                                        break;
 #endif
+#if TELEMEGA_V4
+                               case AO_LOG_FORMAT_TELEMEGA_4:
+                                       log_mega = (struct ao_log_mega *) &eeprom->data[eeprom_offset];
+                                       eeprom_offset += sizeof (*log_mega);
+                                       switch (log_mega->type) {
+                                       case AO_LOG_FLIGHT:
+                                               ao_flight_number = log_mega->u.flight.flight;
+                                               ao_flight_ground_accel = log_mega->u.flight.ground_accel;
+                                               ao_flight_started = 1;
+                                               ao_ground_pres = log_mega->u.flight.ground_pres;
+                                               ao_ground_height = ao_pa_to_altitude(ao_ground_pres);
+                                               ao_ground_accel_along = log_mega->u.flight.ground_accel_along;
+                                               ao_ground_accel_across = log_mega->u.flight.ground_accel_across;
+                                               ao_ground_accel_through = log_mega->u.flight.ground_accel_through;
+                                               ao_ground_roll = log_mega->u.flight.ground_roll;
+                                               ao_ground_pitch = log_mega->u.flight.ground_pitch;
+                                               ao_ground_yaw = log_mega->u.flight.ground_yaw;
+                                               ao_ground_bmx160.acc_x = ao_ground_accel_along;
+                                               ao_ground_bmx160.acc_y = -ao_ground_accel_across;
+                                               ao_ground_bmx160.acc_z = ao_ground_accel_through;
+                                               ao_ground_bmx160.gyr_x = ao_ground_roll >> 9;
+                                               ao_ground_bmx160.gyr_y = -(ao_ground_pitch >> 9);
+                                               ao_ground_bmx160.gyr_z = ao_ground_yaw >> 9;
+                                               break;
+                                       case AO_LOG_STATE:
+                                               break;
+                                       case AO_LOG_SENSOR:
+                                               ao_data_static.tick = log_mega->tick;
+                                               ao_data_static.ms5607_raw.pres = log_mega->u.sensor.pres;
+                                               ao_data_static.ms5607_raw.temp = log_mega->u.sensor.temp;
+                                               ao_data_set_along(&ao_data_static, log_mega->u.sensor.accel_along);
+                                               ao_data_set_across(&ao_data_static, log_mega->u.sensor.accel_across);
+                                               ao_data_set_through(&ao_data_static, log_mega->u.sensor.accel_through);
+                                               ao_data_set_roll(&ao_data_static, log_mega->u.sensor.gyro_roll);
+                                               ao_data_set_pitch(&ao_data_static, log_mega->u.sensor.gyro_pitch);
+                                               ao_data_set_yaw(&ao_data_static, log_mega->u.sensor.gyro_yaw);
+                                               ao_data_set_mag_along(&ao_data_static, log_mega->u.sensor.mag_along);
+                                               ao_data_set_mag_across(&ao_data_static, log_mega->u.sensor.mag_across);
+                                               ao_data_set_mag_through(&ao_data_static, log_mega->u.sensor.mag_through);
+#if AO_ADXL375_INVERT
+                                               ao_data_static.adxl375.AO_ADXL375_AXIS = ao_data_accel_invert(log_mega->u.sensor.accel);
+#else
+                                               ao_data_static.adxl375.AO_ADXL375_AXIS = log_mega->u.sensor.accel;
+#endif
+                                               if (ao_config.pad_orientation != AO_PAD_ORIENTATION_ANTENNA_UP)
+                                                       ao_data_static.adxl375.AO_ADXL375_AXIS = ao_data_accel_invert(ao_data_static.adxl375.AO_ADXL375_AXIS);
+                                               ao_records_read++;
+                                               ao_insert();
+                                               return;
+                                       case AO_LOG_TEMP_VOLT:
+                                               if (pyros_fired != log_mega->u.volt.pyro) {
+                                                       printf("pyro changed %x -> %x\n", pyros_fired, log_mega->u.volt.pyro);
+                                                       pyros_fired = log_mega->u.volt.pyro;
+                                               }
+                                               break;
+                                       case AO_LOG_GPS_TIME:
+                                               ao_gps_prev = ao_gps_static;
+                                               ao_gps_static.tick = log_mega->tick;
+                                               ao_gps_static.latitude = log_mega->u.gps.latitude;
+                                               ao_gps_static.longitude = log_mega->u.gps.longitude;
+                                               {
+                                                       int16_t altitude_low = log_mega->u.gps.altitude_low;
+                                                       int16_t altitude_high = log_mega->u.gps.altitude_high;
+                                                       int32_t altitude = altitude_low | ((int32_t) altitude_high << 16);
+
+                                                       AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_static, altitude);
+                                               }
+                                               ao_gps_static.flags = log_mega->u.gps.flags;
+                                               if (!ao_gps_count)
+                                                       ao_gps_first = ao_gps_static;
+                                               ao_gps_count++;
+                                               break;
+                                       case AO_LOG_GPS_SAT:
+                                               break;
+                                       }
+                                       break;
+#endif
+#ifdef foo_TELEMEGA_V4
+                               case AO_LOG_FORMAT_TELEMEGA_4:
+                                       log_mega = (struct ao_log_mega *) &eeprom->data[eeprom_offset];
+                                       eeprom_offset += sizeof (*log_mega);
+                                       switch (log_mega->type) {
+                                       case AO_LOG_FLIGHT:
+                                               ao_flight_number = log_mega->u.flight.flight;
+                                               ao_flight_ground_accel = log_mega->u.flight.ground_accel;
+                                               ao_flight_started = 1;
+                                               break;
+                                       case AO_LOG_SENSOR:
+                                               ao_data_static.tick = log_mega->tick;
+                                               ao_data_static.adxl375.AO_ADXL375_AXIS = log_mega->u.sensor.accel;
+                                               ao_records_read++;
+                                               ao_insert();
+                                               return;
+                                       }
+                                       break;
+#endif
 #if TELEMETRUM_V2
                                case AO_LOG_FORMAT_TELEMETRUM:
                                        log_metrum = (struct ao_log_metrum *) &eeprom->data[eeprom_offset];
index 7c1ecc15f50607a20ee3cbcd1d0a7c688aea8ba6..1e7847e5603995b842cfec83918b6e7f5a9bd76b 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define AO_GPS_TEST
+#define AO_TICK_TYPE uint32_t
 #include "ao_host.h"
 #include <termios.h>
 #include <errno.h>
index 11c54601b9cee77d5a784848afb3a7f44033114b..bd8998b77e959741daff920669cc13b78d606329 100644 (file)
@@ -17,7 +17,9 @@
  */
 
 #define AO_GPS_TEST
+#define AO_TICK_TYPE uint32_t
 #define HAS_GPS 1
+#define tick_count 0
 #include "ao_host.h"
 #include <termios.h>
 #include <errno.h>
@@ -49,6 +51,8 @@ struct ao_gps_orig {
        int16_t                 altitude;       /* m */
        uint16_t                ground_speed;   /* cm/s */
        uint8_t                 course;         /* degrees / 2 */
+       uint8_t                 pdop;           /* unused */
+       uint8_t                 vdop;           /* unused */
        uint8_t                 hdop;           /* * 5 */
        int16_t                 climb_rate;     /* cm/s */
        uint16_t                h_error;        /* m */
index 0833e4f60a3c158b5dabb61768991b60893bed80..6cccf0e51b3af18e43e62a75a44bf920f56fbf02 100644 (file)
  */
 
 #define AO_GPS_TEST
+#define AO_TICK_TYPE uint32_t
 #define HAS_GPS        1
+#define ao_tick_count 0
 #include "ao_host.h"
 #include <termios.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdbool.h>
 #include <fcntl.h>
 #include <unistd.h>
 #define AO_GPS_NUM_SAT_MASK    (0xf << 0)
index 952460d0c2831c2daf12808037ffa947ee019171..ac4a69bd4702f13a930a3c907bbe98c3f0b0d79d 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#define AO_TICK_TYPE uint32_t
 
 #include <stdint.h>
 #include <stdio.h>
index 27f8ddcdeedc832fab8a40574195551850c72c26..87f34cd9fee155de93d2b277efab6f327efc4ff5 100755 (executable)
@@ -14,7 +14,7 @@ case $# in
        exit 1
 esac
 
-gnuplot -persist << EOF
+cat - /dev/tty <<EOF | gnuplot
 set ylabel "distance (m)"
 set y2label "angle (d)"
 set xlabel "time (s)"
@@ -22,8 +22,12 @@ set xtics border out nomirror
 set ytics border out nomirror
 set y2tics border out nomirror
 set title "$title"
-plot "$file" using 1:5 with lines axes x1y1 title "height",\
-"$file" using 1:7 with lines axes x1y2 title "angle",\
-"$file" using 1:13 with lines axes x1y2 title "gps angle",\
-"$file" using 1:15 with lines axes x1y2 title "sats"
+plot "$file" using 1:3 with lines axes x1y1 title "height",\
+"$file" using 1:7 with lines axes x1y1 title "speed", \
+"$file" using 1:5 with lines axes x1y1 title "accel", \
+"$file" using 1:13 with lines axes x1y1 title "k_speed",\
+"$file" using 1:15 with lines axes x1y1 title "k_accel",\
+"$file" using 1:25 with lines axes x1y2 title "angle",\
+"$file" using 1:49 with lines axes x1y2 title "pyro",\
+"$file" using 1:51 with lines axes x1y2 title "inhibited"
 EOF