testsuite.h 8.06 KB
Newer Older
lm's avatar
lm committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/** @file
 *	@brief MAVLink comm protocol testsuite generated from ualberta.xml
 *	@see http://qgroundcontrol.org/mavlink/
 */
#ifndef UALBERTA_TESTSUITE_H
#define UALBERTA_TESTSUITE_H

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MAVLINK_TEST_ALL
#define MAVLINK_TEST_ALL
LM's avatar
LM committed
14 15
static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg);
static void mavlink_test_ualberta(uint8_t, uint8_t, mavlink_message_t *last_msg);
lm's avatar
lm committed
16

LM's avatar
LM committed
17
static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
lm's avatar
lm committed
18
{
LM's avatar
LM committed
19 20
	mavlink_test_common(system_id, component_id, last_msg);
	mavlink_test_ualberta(system_id, component_id, last_msg);
lm's avatar
lm committed
21 22 23 24 25 26
}
#endif

#include "../common/testsuite.h"


LM's avatar
LM committed
27
static void mavlink_test_nav_filter_bias(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
lm's avatar
lm committed
28 29 30 31
{
	mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
LM's avatar
LM committed
32
	mavlink_nav_filter_bias_t packet_in = {
lm's avatar
lm committed
33 34 35 36 37 38 39 40
		93372036854775807ULL,
	73.0,
	101.0,
	129.0,
	157.0,
	185.0,
	213.0,
	};
LM's avatar
LM committed
41 42 43 44 45 46 47 48 49 50 51 52 53
	mavlink_nav_filter_bias_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        	packet1.usec = packet_in.usec;
        	packet1.accel_0 = packet_in.accel_0;
        	packet1.accel_1 = packet_in.accel_1;
        	packet1.accel_2 = packet_in.accel_2;
        	packet1.gyro_0 = packet_in.gyro_0;
        	packet1.gyro_1 = packet_in.gyro_1;
        	packet1.gyro_2 = packet_in.gyro_2;
        
        

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
54 55 56
	mavlink_msg_nav_filter_bias_encode(system_id, component_id, &msg, &packet1);
	mavlink_msg_nav_filter_bias_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
LM's avatar
LM committed
57 58

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
59
	mavlink_msg_nav_filter_bias_pack(system_id, component_id, &msg , packet1.usec , packet1.accel_0 , packet1.accel_1 , packet1.accel_2 , packet1.gyro_0 , packet1.gyro_1 , packet1.gyro_2 );
LM's avatar
LM committed
60 61 62 63
	mavlink_msg_nav_filter_bias_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
64
	mavlink_msg_nav_filter_bias_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.usec , packet1.accel_0 , packet1.accel_1 , packet1.accel_2 , packet1.gyro_0 , packet1.gyro_1 , packet1.gyro_2 );
LM's avatar
LM committed
65 66 67 68
	mavlink_msg_nav_filter_bias_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
69 70 71 72
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
        	comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
LM's avatar
LM committed
73 74 75 76
	mavlink_msg_nav_filter_bias_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
LM's avatar
LM committed
77
	mavlink_msg_nav_filter_bias_send(MAVLINK_COMM_1 , packet1.usec , packet1.accel_0 , packet1.accel_1 , packet1.accel_2 , packet1.gyro_0 , packet1.gyro_1 , packet1.gyro_2 );
LM's avatar
LM committed
78 79
	mavlink_msg_nav_filter_bias_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
lm's avatar
lm committed
80 81
}

LM's avatar
LM committed
82
static void mavlink_test_radio_calibration(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
lm's avatar
lm committed
83 84 85 86
{
	mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
LM's avatar
LM committed
87
	mavlink_radio_calibration_t packet_in = {
lm's avatar
lm committed
88 89 90 91 92 93 94
		{ 17235, 17236, 17237 },
	{ 17547, 17548, 17549 },
	{ 17859, 17860, 17861 },
	{ 18171, 18172 },
	{ 18379, 18380, 18381, 18382, 18383 },
	{ 18899, 18900, 18901, 18902, 18903 },
	};
LM's avatar
LM committed
95 96 97 98 99 100 101 102 103 104 105 106
	mavlink_radio_calibration_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        
        	memcpy(packet1.aileron, packet_in.aileron, sizeof(uint16_t)*3);
        	memcpy(packet1.elevator, packet_in.elevator, sizeof(uint16_t)*3);
        	memcpy(packet1.rudder, packet_in.rudder, sizeof(uint16_t)*3);
        	memcpy(packet1.gyro, packet_in.gyro, sizeof(uint16_t)*2);
        	memcpy(packet1.pitch, packet_in.pitch, sizeof(uint16_t)*5);
        	memcpy(packet1.throttle, packet_in.throttle, sizeof(uint16_t)*5);
        

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
107 108 109
	mavlink_msg_radio_calibration_encode(system_id, component_id, &msg, &packet1);
	mavlink_msg_radio_calibration_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
LM's avatar
LM committed
110 111

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
112
	mavlink_msg_radio_calibration_pack(system_id, component_id, &msg , packet1.aileron , packet1.elevator , packet1.rudder , packet1.gyro , packet1.pitch , packet1.throttle );
LM's avatar
LM committed
113 114 115 116
	mavlink_msg_radio_calibration_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
117
	mavlink_msg_radio_calibration_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.aileron , packet1.elevator , packet1.rudder , packet1.gyro , packet1.pitch , packet1.throttle );
LM's avatar
LM committed
118 119 120 121
	mavlink_msg_radio_calibration_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
122 123 124 125
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
        	comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
LM's avatar
LM committed
126 127 128 129
	mavlink_msg_radio_calibration_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
LM's avatar
LM committed
130
	mavlink_msg_radio_calibration_send(MAVLINK_COMM_1 , packet1.aileron , packet1.elevator , packet1.rudder , packet1.gyro , packet1.pitch , packet1.throttle );
LM's avatar
LM committed
131 132
	mavlink_msg_radio_calibration_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
lm's avatar
lm committed
133 134
}

LM's avatar
LM committed
135
static void mavlink_test_ualberta_sys_status(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
lm's avatar
lm committed
136 137 138 139
{
	mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
LM's avatar
LM committed
140
	mavlink_ualberta_sys_status_t packet_in = {
lm's avatar
lm committed
141 142 143 144
		5,
	72,
	139,
	};
LM's avatar
LM committed
145 146 147 148 149 150 151 152 153
	mavlink_ualberta_sys_status_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        	packet1.mode = packet_in.mode;
        	packet1.nav_mode = packet_in.nav_mode;
        	packet1.pilot = packet_in.pilot;
        
        

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
154 155 156
	mavlink_msg_ualberta_sys_status_encode(system_id, component_id, &msg, &packet1);
	mavlink_msg_ualberta_sys_status_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
LM's avatar
LM committed
157 158

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
159
	mavlink_msg_ualberta_sys_status_pack(system_id, component_id, &msg , packet1.mode , packet1.nav_mode , packet1.pilot );
LM's avatar
LM committed
160 161 162 163
	mavlink_msg_ualberta_sys_status_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
164
	mavlink_msg_ualberta_sys_status_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.mode , packet1.nav_mode , packet1.pilot );
LM's avatar
LM committed
165 166 167 168
	mavlink_msg_ualberta_sys_status_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
lm's avatar
lm committed
169 170 171 172
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
        	comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
LM's avatar
LM committed
173 174 175 176
	mavlink_msg_ualberta_sys_status_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
LM's avatar
LM committed
177
	mavlink_msg_ualberta_sys_status_send(MAVLINK_COMM_1 , packet1.mode , packet1.nav_mode , packet1.pilot );
LM's avatar
LM committed
178 179
	mavlink_msg_ualberta_sys_status_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
lm's avatar
lm committed
180 181
}

LM's avatar
LM committed
182
static void mavlink_test_ualberta(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
lm's avatar
lm committed
183
{
LM's avatar
LM committed
184 185 186
	mavlink_test_nav_filter_bias(system_id, component_id, last_msg);
	mavlink_test_radio_calibration(system_id, component_id, last_msg);
	mavlink_test_ualberta_sys_status(system_id, component_id, last_msg);
lm's avatar
lm committed
187 188 189 190 191 192
}

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // UALBERTA_TESTSUITE_H