NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
testsuite.h
Go to the documentation of this file.
1 
5 #ifndef AUTOQUAD_TESTSUITE_H
6 #define AUTOQUAD_TESTSUITE_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #ifndef MAVLINK_TEST_ALL
13 #define MAVLINK_TEST_ALL
14 static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg);
15 static void mavlink_test_autoquad(uint8_t, uint8_t, mavlink_message_t *last_msg);
16 
17 static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
18 {
19  mavlink_test_common(system_id, component_id, last_msg);
20  mavlink_test_autoquad(system_id, component_id, last_msg);
21 }
22 #endif
23 
24 #include "../common/testsuite.h"
25 
26 
27 static void mavlink_test_aq_telemetry_f(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
28 {
29  mavlink_message_t msg;
30  uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
31  uint16_t i;
32  mavlink_aq_telemetry_f_t packet_in = {
33  17.0,45.0,73.0,101.0,129.0,157.0,185.0,213.0,241.0,269.0,297.0,325.0,353.0,381.0,409.0,437.0,465.0,493.0,521.0,549.0,21395
34  };
35  mavlink_aq_telemetry_f_t packet1, packet2;
36  memset(&packet1, 0, sizeof(packet1));
37  packet1.value1 = packet_in.value1;
38  packet1.value2 = packet_in.value2;
39  packet1.value3 = packet_in.value3;
40  packet1.value4 = packet_in.value4;
41  packet1.value5 = packet_in.value5;
42  packet1.value6 = packet_in.value6;
43  packet1.value7 = packet_in.value7;
44  packet1.value8 = packet_in.value8;
45  packet1.value9 = packet_in.value9;
46  packet1.value10 = packet_in.value10;
47  packet1.value11 = packet_in.value11;
48  packet1.value12 = packet_in.value12;
49  packet1.value13 = packet_in.value13;
50  packet1.value14 = packet_in.value14;
51  packet1.value15 = packet_in.value15;
52  packet1.value16 = packet_in.value16;
53  packet1.value17 = packet_in.value17;
54  packet1.value18 = packet_in.value18;
55  packet1.value19 = packet_in.value19;
56  packet1.value20 = packet_in.value20;
57  packet1.Index = packet_in.Index;
58 
59 
60 
61  memset(&packet2, 0, sizeof(packet2));
62  mavlink_msg_aq_telemetry_f_encode(system_id, component_id, &msg, &packet1);
63  mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
64  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
65 
66  memset(&packet2, 0, sizeof(packet2));
67  mavlink_msg_aq_telemetry_f_pack(system_id, component_id, &msg , packet1.Index , packet1.value1 , packet1.value2 , packet1.value3 , packet1.value4 , packet1.value5 , packet1.value6 , packet1.value7 , packet1.value8 , packet1.value9 , packet1.value10 , packet1.value11 , packet1.value12 , packet1.value13 , packet1.value14 , packet1.value15 , packet1.value16 , packet1.value17 , packet1.value18 , packet1.value19 , packet1.value20 );
68  mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
69  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
70 
71  memset(&packet2, 0, sizeof(packet2));
72  mavlink_msg_aq_telemetry_f_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.Index , packet1.value1 , packet1.value2 , packet1.value3 , packet1.value4 , packet1.value5 , packet1.value6 , packet1.value7 , packet1.value8 , packet1.value9 , packet1.value10 , packet1.value11 , packet1.value12 , packet1.value13 , packet1.value14 , packet1.value15 , packet1.value16 , packet1.value17 , packet1.value18 , packet1.value19 , packet1.value20 );
73  mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
74  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
75 
76  memset(&packet2, 0, sizeof(packet2));
77  mavlink_msg_to_send_buffer(buffer, &msg);
78  for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
79  comm_send_ch(MAVLINK_COMM_0, buffer[i]);
80  }
81  mavlink_msg_aq_telemetry_f_decode(last_msg, &packet2);
82  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
83 
84  memset(&packet2, 0, sizeof(packet2));
85  mavlink_msg_aq_telemetry_f_send(MAVLINK_COMM_1 , packet1.Index , packet1.value1 , packet1.value2 , packet1.value3 , packet1.value4 , packet1.value5 , packet1.value6 , packet1.value7 , packet1.value8 , packet1.value9 , packet1.value10 , packet1.value11 , packet1.value12 , packet1.value13 , packet1.value14 , packet1.value15 , packet1.value16 , packet1.value17 , packet1.value18 , packet1.value19 , packet1.value20 );
86  mavlink_msg_aq_telemetry_f_decode(last_msg, &packet2);
87  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
88 }
89 
90 static void mavlink_test_aq_esc_telemetry(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
91 {
92  mavlink_message_t msg;
93  uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
94  uint16_t i;
95  mavlink_aq_esc_telemetry_t packet_in = {
96  963497464,{ 963497672, 963497673, 963497674, 963497675 },{ 963498504, 963498505, 963498506, 963498507 },{ 19107, 19108, 19109, 19110 },137,204,15,{ 82, 83, 84, 85 },{ 94, 95, 96, 97 }
97  };
98  mavlink_aq_esc_telemetry_t packet1, packet2;
99  memset(&packet1, 0, sizeof(packet1));
100  packet1.time_boot_ms = packet_in.time_boot_ms;
101  packet1.seq = packet_in.seq;
102  packet1.num_motors = packet_in.num_motors;
103  packet1.num_in_seq = packet_in.num_in_seq;
104 
105  mav_array_memcpy(packet1.data0, packet_in.data0, sizeof(uint32_t)*4);
106  mav_array_memcpy(packet1.data1, packet_in.data1, sizeof(uint32_t)*4);
107  mav_array_memcpy(packet1.status_age, packet_in.status_age, sizeof(uint16_t)*4);
108  mav_array_memcpy(packet1.escid, packet_in.escid, sizeof(uint8_t)*4);
109  mav_array_memcpy(packet1.data_version, packet_in.data_version, sizeof(uint8_t)*4);
110 
111 
112  memset(&packet2, 0, sizeof(packet2));
113  mavlink_msg_aq_esc_telemetry_encode(system_id, component_id, &msg, &packet1);
114  mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
115  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
116 
117  memset(&packet2, 0, sizeof(packet2));
118  mavlink_msg_aq_esc_telemetry_pack(system_id, component_id, &msg , packet1.time_boot_ms , packet1.seq , packet1.num_motors , packet1.num_in_seq , packet1.escid , packet1.status_age , packet1.data_version , packet1.data0 , packet1.data1 );
119  mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
120  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
121 
122  memset(&packet2, 0, sizeof(packet2));
123  mavlink_msg_aq_esc_telemetry_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.time_boot_ms , packet1.seq , packet1.num_motors , packet1.num_in_seq , packet1.escid , packet1.status_age , packet1.data_version , packet1.data0 , packet1.data1 );
124  mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
125  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
126 
127  memset(&packet2, 0, sizeof(packet2));
128  mavlink_msg_to_send_buffer(buffer, &msg);
129  for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
130  comm_send_ch(MAVLINK_COMM_0, buffer[i]);
131  }
132  mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
133  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
134 
135  memset(&packet2, 0, sizeof(packet2));
136  mavlink_msg_aq_esc_telemetry_send(MAVLINK_COMM_1 , packet1.time_boot_ms , packet1.seq , packet1.num_motors , packet1.num_in_seq , packet1.escid , packet1.status_age , packet1.data_version , packet1.data0 , packet1.data1 );
137  mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
138  MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
139 }
140 
141 static void mavlink_test_autoquad(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
142 {
143  mavlink_test_aq_telemetry_f(system_id, component_id, last_msg);
144  mavlink_test_aq_esc_telemetry(system_id, component_id, last_msg);
145 }
146 
147 #ifdef __cplusplus
148 }
149 #endif // __cplusplus
150 #endif // AUTOQUAD_TESTSUITE_H
#define MAVLINK_ASSERT(x)
Definition: protocol.h:26