diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/Makefile | 8 | ||||
| -rw-r--r-- | src/test/ao_aprs_test.c | 39 | ||||
| -rw-r--r-- | src/test/ao_flight_test.c | 54 | ||||
| -rw-r--r-- | src/test/ao_ms5607_convert_test.c | 2 | 
4 files changed, 69 insertions, 34 deletions
diff --git a/src/test/Makefile b/src/test/Makefile index c6025219..017f7f71 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -1,4 +1,4 @@ -vpath % ..:../core:../drivers:../util:../micropeak:../aes:../product +vpath % ..:../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 \  	ao_gps_test ao_gps_test_skytraq ao_gps_test_ublox ao_convert_test ao_convert_pa_test ao_fec_test \ @@ -9,7 +9,7 @@ INCS=ao_kalman.h ao_ms5607.h ao_log.h ao_data.h altitude-pa.h altitude.h ao_quat  KALMAN=make-kalman  -CFLAGS=-I.. -I. -I../core -I../drivers -I../micropeak -I../product -O0 -g -Wall +CFLAGS=-I.. -I. -I../kernel -I../drivers -I../micropeak -I../product -O0 -g -Wall  all: $(PROGS) ao_aprs_data.wav @@ -52,10 +52,10 @@ ao_kalman.h: $(KALMAN)  	(cd .. && make ao_kalman.h)  ao_fec_test: ao_fec_test.c ao_fec_tx.c ao_fec_rx.c -	cc $(CFLAGS) -DAO_FEC_DEBUG=1 -o $@ ao_fec_test.c ../core/ao_fec_tx.c ../core/ao_fec_rx.c -lm +	cc $(CFLAGS) -DAO_FEC_DEBUG=1 -o $@ ao_fec_test.c ../kernel/ao_fec_tx.c ../kernel/ao_fec_rx.c -lm  ao_aprs_test: ao_aprs_test.c ao_aprs.c -	cc $(CFLAGS) -o $@ ao_aprs_test.c +	cc $(CFLAGS) -o $@ ao_aprs_test.c -lm  SOX_INPUT_ARGS=--type raw --encoding unsigned-integer -b 8 -c 1 -r 9600  SOX_OUTPUT_ARGS=--type wav diff --git a/src/test/ao_aprs_test.c b/src/test/ao_aprs_test.c index 69147786..86cf527a 100644 --- a/src/test/ao_aprs_test.c +++ b/src/test/ao_aprs_test.c @@ -23,7 +23,16 @@  #include <ao_telemetry.h> +#define AO_GPS_NUM_SAT_MASK	(0xf << 0) +#define AO_GPS_NUM_SAT_SHIFT	(0) + +#define AO_GPS_VALID		(1 << 4) +#define AO_GPS_RUNNING		(1 << 5) +#define AO_GPS_DATE_VALID	(1 << 6) +#define AO_GPS_COURSE_VALID	(1 << 7) +  struct ao_telemetry_location ao_gps_data; +struct ao_telemetry_satellite ao_gps_tracking_data;  #define AO_APRS_TEST @@ -73,7 +82,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill);   *  You should have received a copy of the GNU General Public License   *  along with this program; if not, write to the Free Software   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - *   + *   */ @@ -88,14 +97,42 @@ audio_gap(int secs)  #endif  } +#include <math.h> + +int +ao_aprs_encode_altitude_expensive(int meters) +{ +	double	feet = meters / 0.3048; + +	double	encode = log(feet) / log(1.002); +	return floor(encode + 0.5); +} +  // This is where we go after reset.  int main(int argc, char **argv)  { +	int	e, x; +	int	a; + +	for (a = 1; a < 100000; a++) { +		e = ao_aprs_encode_altitude(a); +		x = ao_aprs_encode_altitude_expensive(a); + +		if (e != x) { +			double	back_feet, back_meters; +			back_feet = pow(1.002, e); +			back_meters = back_feet * 0.3048; +			fprintf (stderr, "APRS altitude encoding failure: altitude %d actual %d expected %d actual meters %f\n", +				 a, e, x, back_meters); +		} +	} +      audio_gap(1);      ao_gps_data.latitude = (45.0 + 28.25 / 60.0) * 10000000;      ao_gps_data.longitude = (-(122 + 44.2649 / 60.0)) * 10000000;      ao_gps_data.altitude = 84; +    ao_gps_data.flags = (AO_GPS_VALID|AO_GPS_RUNNING);      /* Transmit one packet */      ao_aprs_send(); diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 0abb4090..0647fc6c 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -49,13 +49,12 @@ int ao_gps_new;  #define HAS_MPU6000		1  #define HAS_MMA655X		1  #define HAS_HMC5883 		1 +#define HAS_BEEP		1  struct ao_adc {  	int16_t			sense[AO_ADC_NUM_SENSE];  	int16_t			v_batt;  	int16_t			v_pbatt; -	int16_t			accel_ref; -	int16_t			accel;  	int16_t			temp;  };  #else @@ -309,7 +308,7 @@ struct ao_cmds {  #if TELEMEGA  #include "ao_convert_pa.c"  #include <ao_ms5607.h> -struct ao_ms5607_prom	ms5607_prom; +struct ao_ms5607_prom	ao_ms5607_prom;  #include "ao_ms5607_convert.c"  #define AO_PYRO_NUM	4  #include <ao_pyro.h> @@ -317,22 +316,8 @@ struct ao_ms5607_prom	ms5607_prom;  #include "ao_convert.c"  #endif -struct ao_config { -	uint16_t	main_deploy; -	int16_t		accel_plus_g; -	int16_t		accel_minus_g; -	uint8_t		pad_orientation; -	uint16_t	apogee_lockout; -#if TELEMEGA -	struct ao_pyro	pyro[AO_PYRO_NUM];	/* minor version 12 */ -	int16_t		accel_zero_along; -	int16_t		accel_zero_across; -	int16_t		accel_zero_through; -#endif -}; - -#define AO_PAD_ORIENTATION_ANTENNA_UP	0 -#define AO_PAD_ORIENTATION_ANTENNA_DOWN	1 +#include <ao_config.h> +#include <ao_fake_flight.h>  #define ao_config_get() @@ -732,6 +717,18 @@ ao_sleep(void *wchan)  					ao_flight_started = 1;  					ao_ground_pres = int32(bytes, 4);  					ao_ground_height = ao_pa_to_altitude(ao_ground_pres); +					ao_ground_accel_along = int16(bytes, 8); +					ao_ground_accel_across = int16(bytes, 10); +					ao_ground_accel_through = int16(bytes, 12); +					ao_ground_roll = int16(bytes, 14); +					ao_ground_pitch = int16(bytes, 16); +					ao_ground_yaw = int16(bytes, 18); +					ao_ground_mpu6000.accel_x = ao_ground_accel_across; +					ao_ground_mpu6000.accel_y = ao_ground_accel_along; +					ao_ground_mpu6000.accel_z = ao_ground_accel_through; +					ao_ground_mpu6000.gyro_x = ao_ground_pitch >> 9; +					ao_ground_mpu6000.gyro_y = ao_ground_roll >> 9; +					ao_ground_mpu6000.gyro_z = ao_ground_yaw >> 9;  					break;  				case 'A':  					ao_data_static.tick = tick; @@ -768,21 +765,21 @@ ao_sleep(void *wchan)  				continue;  			} else if (nword == 3 && strcmp(words[0], "ms5607") == 0) {  				if (strcmp(words[1], "reserved:") == 0) -					ms5607_prom.reserved = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.reserved = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "sens:") == 0) -					ms5607_prom.sens = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.sens = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "off:") == 0) -					ms5607_prom.off = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.off = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "tcs:") == 0) -					ms5607_prom.tcs = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.tcs = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "tco:") == 0) -					ms5607_prom.tco = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.tco = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "tref:") == 0) -					ms5607_prom.tref = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.tref = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "tempsens:") == 0) -					ms5607_prom.tempsens = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.tempsens = strtoul(words[2], NULL, 10);  				else if (strcmp(words[1], "crc:") == 0) -					ms5607_prom.crc = strtoul(words[2], NULL, 10); +					ao_ms5607_prom.crc = strtoul(words[2], NULL, 10);  				continue;  			} else if (nword >= 3 && strcmp(words[0], "Pyro") == 0) {  				int	p = strtoul(words[1], NULL, 10); @@ -791,7 +788,7 @@ ao_sleep(void *wchan)  				for (i = 2; i < nword; i++) {  					for (j = 0; j < NUM_PYRO_VALUES; j++) -						if (!strcmp (words[2], ao_pyro_values[j].name)) +						if (!strcmp (words[i], ao_pyro_values[j].name))  							break;  					if (j == NUM_PYRO_VALUES)  						continue; @@ -991,6 +988,7 @@ void run_flight_fixed(char *name, FILE *f, int summary, char *info)  	emulator_in = f;  	emulator_info = info;  	ao_summary = summary; +  	ao_flight_init();  	ao_flight();  } diff --git a/src/test/ao_ms5607_convert_test.c b/src/test/ao_ms5607_convert_test.c index ad593204..1c571f1c 100644 --- a/src/test/ao_ms5607_convert_test.c +++ b/src/test/ao_ms5607_convert_test.c @@ -23,7 +23,7 @@  #include <stdint.h>  #include <ao_ms5607.h> -struct ao_ms5607_prom ms5607_prom = { +struct ao_ms5607_prom ao_ms5607_prom = {  	0x002c,  	0xa6e0,  	0x988e,  | 
