RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
testsuite.h
浏览该文件的文档.
1/** @file
2 * @brief MAVLink comm protocol testsuite generated from autoquad.xml
3 * @see http://qgroundcontrol.org/mavlink/
4 */
5#pragma once
6#ifndef AUTOQUAD_TESTSUITE_H
7#define AUTOQUAD_TESTSUITE_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#ifndef MAVLINK_TEST_ALL
14#define MAVLINK_TEST_ALL
15static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg);
16static void mavlink_test_autoquad(uint8_t, uint8_t, mavlink_message_t *last_msg);
17
18static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
19{
20 mavlink_test_common(system_id, component_id, last_msg);
21 mavlink_test_autoquad(system_id, component_id, last_msg);
22}
23#endif
24
25#include "../common/testsuite.h"
26
27
28static void mavlink_test_aq_telemetry_f(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
29{
30#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
31 mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
32 if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_AQ_TELEMETRY_F >= 256) {
33 return;
34 }
35#endif
36 mavlink_message_t msg;
37 uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
38 uint16_t i;
39 mavlink_aq_telemetry_f_t packet_in = {
40 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
41 };
42 mavlink_aq_telemetry_f_t packet1, packet2;
43 memset(&packet1, 0, sizeof(packet1));
44 packet1.value1 = packet_in.value1;
45 packet1.value2 = packet_in.value2;
46 packet1.value3 = packet_in.value3;
47 packet1.value4 = packet_in.value4;
48 packet1.value5 = packet_in.value5;
49 packet1.value6 = packet_in.value6;
50 packet1.value7 = packet_in.value7;
51 packet1.value8 = packet_in.value8;
52 packet1.value9 = packet_in.value9;
53 packet1.value10 = packet_in.value10;
54 packet1.value11 = packet_in.value11;
55 packet1.value12 = packet_in.value12;
56 packet1.value13 = packet_in.value13;
57 packet1.value14 = packet_in.value14;
58 packet1.value15 = packet_in.value15;
59 packet1.value16 = packet_in.value16;
60 packet1.value17 = packet_in.value17;
61 packet1.value18 = packet_in.value18;
62 packet1.value19 = packet_in.value19;
63 packet1.value20 = packet_in.value20;
64 packet1.Index = packet_in.Index;
65
66
67#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
68 if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
69 // cope with extensions
70 memset(MAVLINK_MSG_ID_AQ_TELEMETRY_F_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_AQ_TELEMETRY_F_MIN_LEN);
71 }
72#endif
73 memset(&packet2, 0, sizeof(packet2));
74 mavlink_msg_aq_telemetry_f_encode(system_id, component_id, &msg, &packet1);
75 mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
76 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
77
78 memset(&packet2, 0, sizeof(packet2));
79 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 );
80 mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
81 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
82
83 memset(&packet2, 0, sizeof(packet2));
84 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 );
85 mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
86 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
87
88 memset(&packet2, 0, sizeof(packet2));
89 mavlink_msg_to_send_buffer(buffer, &msg);
90 for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
91 comm_send_ch(MAVLINK_COMM_0, buffer[i]);
92 }
93 mavlink_msg_aq_telemetry_f_decode(last_msg, &packet2);
94 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
95
96 memset(&packet2, 0, sizeof(packet2));
97 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 );
98 mavlink_msg_aq_telemetry_f_decode(last_msg, &packet2);
99 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
100}
101
102static void mavlink_test_aq_esc_telemetry(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
103{
104#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
105 mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
106 if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_AQ_ESC_TELEMETRY >= 256) {
107 return;
108 }
109#endif
110 mavlink_message_t msg;
111 uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
112 uint16_t i;
113 mavlink_aq_esc_telemetry_t packet_in = {
114 963497464,{ 963497672, 963497673, 963497674, 963497675 },{ 963498504, 963498505, 963498506, 963498507 },{ 19107, 19108, 19109, 19110 },137,204,15,{ 82, 83, 84, 85 },{ 94, 95, 96, 97 }
115 };
116 mavlink_aq_esc_telemetry_t packet1, packet2;
117 memset(&packet1, 0, sizeof(packet1));
118 packet1.time_boot_ms = packet_in.time_boot_ms;
119 packet1.seq = packet_in.seq;
120 packet1.num_motors = packet_in.num_motors;
121 packet1.num_in_seq = packet_in.num_in_seq;
122
123 mav_array_memcpy(packet1.data0, packet_in.data0, sizeof(uint32_t)*4);
124 mav_array_memcpy(packet1.data1, packet_in.data1, sizeof(uint32_t)*4);
125 mav_array_memcpy(packet1.status_age, packet_in.status_age, sizeof(uint16_t)*4);
126 mav_array_memcpy(packet1.escid, packet_in.escid, sizeof(uint8_t)*4);
127 mav_array_memcpy(packet1.data_version, packet_in.data_version, sizeof(uint8_t)*4);
128
129#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
130 if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
131 // cope with extensions
132 memset(MAVLINK_MSG_ID_AQ_ESC_TELEMETRY_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_AQ_ESC_TELEMETRY_MIN_LEN);
133 }
134#endif
135 memset(&packet2, 0, sizeof(packet2));
136 mavlink_msg_aq_esc_telemetry_encode(system_id, component_id, &msg, &packet1);
137 mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
138 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
139
140 memset(&packet2, 0, sizeof(packet2));
141 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 );
142 mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
143 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
144
145 memset(&packet2, 0, sizeof(packet2));
146 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 );
147 mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
148 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
149
150 memset(&packet2, 0, sizeof(packet2));
151 mavlink_msg_to_send_buffer(buffer, &msg);
152 for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
153 comm_send_ch(MAVLINK_COMM_0, buffer[i]);
154 }
155 mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
156 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
157
158 memset(&packet2, 0, sizeof(packet2));
159 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 );
160 mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
161 MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
162}
163
164static void mavlink_test_autoquad(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
165{
166 mavlink_test_aq_telemetry_f(system_id, component_id, last_msg);
167 mavlink_test_aq_esc_telemetry(system_id, component_id, last_msg);
168}
169
170#ifdef __cplusplus
171}
172#endif // __cplusplus
173#endif // AUTOQUAD_TESTSUITE_H
MAVLink comm protocol testsuite generated from common.xml