You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1217 lines
57 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** @file
  2. * @brief MAVLink comm protocol testsuite generated from slugs.xml
  3. * @see http://qgroundcontrol.org/mavlink/
  4. */
  5. #pragma once
  6. #ifndef SLUGS_TESTSUITE_H
  7. #define SLUGS_TESTSUITE_H
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #ifndef MAVLINK_TEST_ALL
  12. #define MAVLINK_TEST_ALL
  13. static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg);
  14. static void mavlink_test_slugs(uint8_t, uint8_t, mavlink_message_t *last_msg);
  15. static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  16. {
  17. mavlink_test_common(system_id, component_id, last_msg);
  18. mavlink_test_slugs(system_id, component_id, last_msg);
  19. }
  20. #endif
  21. #include "../common/testsuite.h"
  22. static void mavlink_test_cpu_load(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  23. {
  24. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  25. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  26. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_CPU_LOAD >= 256) {
  27. return;
  28. }
  29. #endif
  30. mavlink_message_t msg;
  31. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  32. uint16_t i;
  33. mavlink_cpu_load_t packet_in = {
  34. 17235,139,206
  35. };
  36. mavlink_cpu_load_t packet1, packet2;
  37. memset(&packet1, 0, sizeof(packet1));
  38. packet1.batVolt = packet_in.batVolt;
  39. packet1.sensLoad = packet_in.sensLoad;
  40. packet1.ctrlLoad = packet_in.ctrlLoad;
  41. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  42. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  43. // cope with extensions
  44. memset(MAVLINK_MSG_ID_CPU_LOAD_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_CPU_LOAD_MIN_LEN);
  45. }
  46. #endif
  47. memset(&packet2, 0, sizeof(packet2));
  48. mavlink_msg_cpu_load_encode(system_id, component_id, &msg, &packet1);
  49. mavlink_msg_cpu_load_decode(&msg, &packet2);
  50. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  51. memset(&packet2, 0, sizeof(packet2));
  52. mavlink_msg_cpu_load_pack(system_id, component_id, &msg , packet1.sensLoad , packet1.ctrlLoad , packet1.batVolt );
  53. mavlink_msg_cpu_load_decode(&msg, &packet2);
  54. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  55. memset(&packet2, 0, sizeof(packet2));
  56. mavlink_msg_cpu_load_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.sensLoad , packet1.ctrlLoad , packet1.batVolt );
  57. mavlink_msg_cpu_load_decode(&msg, &packet2);
  58. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  59. memset(&packet2, 0, sizeof(packet2));
  60. mavlink_msg_to_send_buffer(buffer, &msg);
  61. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  62. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  63. }
  64. mavlink_msg_cpu_load_decode(last_msg, &packet2);
  65. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  66. memset(&packet2, 0, sizeof(packet2));
  67. mavlink_msg_cpu_load_send(MAVLINK_COMM_1 , packet1.sensLoad , packet1.ctrlLoad , packet1.batVolt );
  68. mavlink_msg_cpu_load_decode(last_msg, &packet2);
  69. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  70. }
  71. static void mavlink_test_sensor_bias(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  72. {
  73. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  74. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  75. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SENSOR_BIAS >= 256) {
  76. return;
  77. }
  78. #endif
  79. mavlink_message_t msg;
  80. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  81. uint16_t i;
  82. mavlink_sensor_bias_t packet_in = {
  83. 17.0,45.0,73.0,101.0,129.0,157.0
  84. };
  85. mavlink_sensor_bias_t packet1, packet2;
  86. memset(&packet1, 0, sizeof(packet1));
  87. packet1.axBias = packet_in.axBias;
  88. packet1.ayBias = packet_in.ayBias;
  89. packet1.azBias = packet_in.azBias;
  90. packet1.gxBias = packet_in.gxBias;
  91. packet1.gyBias = packet_in.gyBias;
  92. packet1.gzBias = packet_in.gzBias;
  93. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  94. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  95. // cope with extensions
  96. memset(MAVLINK_MSG_ID_SENSOR_BIAS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SENSOR_BIAS_MIN_LEN);
  97. }
  98. #endif
  99. memset(&packet2, 0, sizeof(packet2));
  100. mavlink_msg_sensor_bias_encode(system_id, component_id, &msg, &packet1);
  101. mavlink_msg_sensor_bias_decode(&msg, &packet2);
  102. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  103. memset(&packet2, 0, sizeof(packet2));
  104. mavlink_msg_sensor_bias_pack(system_id, component_id, &msg , packet1.axBias , packet1.ayBias , packet1.azBias , packet1.gxBias , packet1.gyBias , packet1.gzBias );
  105. mavlink_msg_sensor_bias_decode(&msg, &packet2);
  106. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  107. memset(&packet2, 0, sizeof(packet2));
  108. mavlink_msg_sensor_bias_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.axBias , packet1.ayBias , packet1.azBias , packet1.gxBias , packet1.gyBias , packet1.gzBias );
  109. mavlink_msg_sensor_bias_decode(&msg, &packet2);
  110. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  111. memset(&packet2, 0, sizeof(packet2));
  112. mavlink_msg_to_send_buffer(buffer, &msg);
  113. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  114. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  115. }
  116. mavlink_msg_sensor_bias_decode(last_msg, &packet2);
  117. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  118. memset(&packet2, 0, sizeof(packet2));
  119. mavlink_msg_sensor_bias_send(MAVLINK_COMM_1 , packet1.axBias , packet1.ayBias , packet1.azBias , packet1.gxBias , packet1.gyBias , packet1.gzBias );
  120. mavlink_msg_sensor_bias_decode(last_msg, &packet2);
  121. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  122. }
  123. static void mavlink_test_diagnostic(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  124. {
  125. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  126. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  127. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_DIAGNOSTIC >= 256) {
  128. return;
  129. }
  130. #endif
  131. mavlink_message_t msg;
  132. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  133. uint16_t i;
  134. mavlink_diagnostic_t packet_in = {
  135. 17.0,45.0,73.0,17859,17963,18067
  136. };
  137. mavlink_diagnostic_t packet1, packet2;
  138. memset(&packet1, 0, sizeof(packet1));
  139. packet1.diagFl1 = packet_in.diagFl1;
  140. packet1.diagFl2 = packet_in.diagFl2;
  141. packet1.diagFl3 = packet_in.diagFl3;
  142. packet1.diagSh1 = packet_in.diagSh1;
  143. packet1.diagSh2 = packet_in.diagSh2;
  144. packet1.diagSh3 = packet_in.diagSh3;
  145. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  146. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  147. // cope with extensions
  148. memset(MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_DIAGNOSTIC_MIN_LEN);
  149. }
  150. #endif
  151. memset(&packet2, 0, sizeof(packet2));
  152. mavlink_msg_diagnostic_encode(system_id, component_id, &msg, &packet1);
  153. mavlink_msg_diagnostic_decode(&msg, &packet2);
  154. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  155. memset(&packet2, 0, sizeof(packet2));
  156. mavlink_msg_diagnostic_pack(system_id, component_id, &msg , packet1.diagFl1 , packet1.diagFl2 , packet1.diagFl3 , packet1.diagSh1 , packet1.diagSh2 , packet1.diagSh3 );
  157. mavlink_msg_diagnostic_decode(&msg, &packet2);
  158. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  159. memset(&packet2, 0, sizeof(packet2));
  160. mavlink_msg_diagnostic_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.diagFl1 , packet1.diagFl2 , packet1.diagFl3 , packet1.diagSh1 , packet1.diagSh2 , packet1.diagSh3 );
  161. mavlink_msg_diagnostic_decode(&msg, &packet2);
  162. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  163. memset(&packet2, 0, sizeof(packet2));
  164. mavlink_msg_to_send_buffer(buffer, &msg);
  165. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  166. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  167. }
  168. mavlink_msg_diagnostic_decode(last_msg, &packet2);
  169. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  170. memset(&packet2, 0, sizeof(packet2));
  171. mavlink_msg_diagnostic_send(MAVLINK_COMM_1 , packet1.diagFl1 , packet1.diagFl2 , packet1.diagFl3 , packet1.diagSh1 , packet1.diagSh2 , packet1.diagSh3 );
  172. mavlink_msg_diagnostic_decode(last_msg, &packet2);
  173. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  174. }
  175. static void mavlink_test_slugs_navigation(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  176. {
  177. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  178. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  179. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SLUGS_NAVIGATION >= 256) {
  180. return;
  181. }
  182. #endif
  183. mavlink_message_t msg;
  184. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  185. uint16_t i;
  186. mavlink_slugs_navigation_t packet_in = {
  187. 17.0,45.0,73.0,101.0,129.0,157.0,185.0,18691,223,34
  188. };
  189. mavlink_slugs_navigation_t packet1, packet2;
  190. memset(&packet1, 0, sizeof(packet1));
  191. packet1.u_m = packet_in.u_m;
  192. packet1.phi_c = packet_in.phi_c;
  193. packet1.theta_c = packet_in.theta_c;
  194. packet1.psiDot_c = packet_in.psiDot_c;
  195. packet1.ay_body = packet_in.ay_body;
  196. packet1.totalDist = packet_in.totalDist;
  197. packet1.dist2Go = packet_in.dist2Go;
  198. packet1.h_c = packet_in.h_c;
  199. packet1.fromWP = packet_in.fromWP;
  200. packet1.toWP = packet_in.toWP;
  201. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  202. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  203. // cope with extensions
  204. memset(MAVLINK_MSG_ID_SLUGS_NAVIGATION_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SLUGS_NAVIGATION_MIN_LEN);
  205. }
  206. #endif
  207. memset(&packet2, 0, sizeof(packet2));
  208. mavlink_msg_slugs_navigation_encode(system_id, component_id, &msg, &packet1);
  209. mavlink_msg_slugs_navigation_decode(&msg, &packet2);
  210. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  211. memset(&packet2, 0, sizeof(packet2));
  212. mavlink_msg_slugs_navigation_pack(system_id, component_id, &msg , packet1.u_m , packet1.phi_c , packet1.theta_c , packet1.psiDot_c , packet1.ay_body , packet1.totalDist , packet1.dist2Go , packet1.fromWP , packet1.toWP , packet1.h_c );
  213. mavlink_msg_slugs_navigation_decode(&msg, &packet2);
  214. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  215. memset(&packet2, 0, sizeof(packet2));
  216. mavlink_msg_slugs_navigation_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.u_m , packet1.phi_c , packet1.theta_c , packet1.psiDot_c , packet1.ay_body , packet1.totalDist , packet1.dist2Go , packet1.fromWP , packet1.toWP , packet1.h_c );
  217. mavlink_msg_slugs_navigation_decode(&msg, &packet2);
  218. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  219. memset(&packet2, 0, sizeof(packet2));
  220. mavlink_msg_to_send_buffer(buffer, &msg);
  221. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  222. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  223. }
  224. mavlink_msg_slugs_navigation_decode(last_msg, &packet2);
  225. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  226. memset(&packet2, 0, sizeof(packet2));
  227. mavlink_msg_slugs_navigation_send(MAVLINK_COMM_1 , packet1.u_m , packet1.phi_c , packet1.theta_c , packet1.psiDot_c , packet1.ay_body , packet1.totalDist , packet1.dist2Go , packet1.fromWP , packet1.toWP , packet1.h_c );
  228. mavlink_msg_slugs_navigation_decode(last_msg, &packet2);
  229. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  230. }
  231. static void mavlink_test_data_log(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  232. {
  233. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  234. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  235. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_DATA_LOG >= 256) {
  236. return;
  237. }
  238. #endif
  239. mavlink_message_t msg;
  240. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  241. uint16_t i;
  242. mavlink_data_log_t packet_in = {
  243. 17.0,45.0,73.0,101.0,129.0,157.0
  244. };
  245. mavlink_data_log_t packet1, packet2;
  246. memset(&packet1, 0, sizeof(packet1));
  247. packet1.fl_1 = packet_in.fl_1;
  248. packet1.fl_2 = packet_in.fl_2;
  249. packet1.fl_3 = packet_in.fl_3;
  250. packet1.fl_4 = packet_in.fl_4;
  251. packet1.fl_5 = packet_in.fl_5;
  252. packet1.fl_6 = packet_in.fl_6;
  253. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  254. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  255. // cope with extensions
  256. memset(MAVLINK_MSG_ID_DATA_LOG_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_DATA_LOG_MIN_LEN);
  257. }
  258. #endif
  259. memset(&packet2, 0, sizeof(packet2));
  260. mavlink_msg_data_log_encode(system_id, component_id, &msg, &packet1);
  261. mavlink_msg_data_log_decode(&msg, &packet2);
  262. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  263. memset(&packet2, 0, sizeof(packet2));
  264. mavlink_msg_data_log_pack(system_id, component_id, &msg , packet1.fl_1 , packet1.fl_2 , packet1.fl_3 , packet1.fl_4 , packet1.fl_5 , packet1.fl_6 );
  265. mavlink_msg_data_log_decode(&msg, &packet2);
  266. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  267. memset(&packet2, 0, sizeof(packet2));
  268. mavlink_msg_data_log_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.fl_1 , packet1.fl_2 , packet1.fl_3 , packet1.fl_4 , packet1.fl_5 , packet1.fl_6 );
  269. mavlink_msg_data_log_decode(&msg, &packet2);
  270. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  271. memset(&packet2, 0, sizeof(packet2));
  272. mavlink_msg_to_send_buffer(buffer, &msg);
  273. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  274. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  275. }
  276. mavlink_msg_data_log_decode(last_msg, &packet2);
  277. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  278. memset(&packet2, 0, sizeof(packet2));
  279. mavlink_msg_data_log_send(MAVLINK_COMM_1 , packet1.fl_1 , packet1.fl_2 , packet1.fl_3 , packet1.fl_4 , packet1.fl_5 , packet1.fl_6 );
  280. mavlink_msg_data_log_decode(last_msg, &packet2);
  281. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  282. }
  283. static void mavlink_test_gps_date_time(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  284. {
  285. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  286. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  287. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_GPS_DATE_TIME >= 256) {
  288. return;
  289. }
  290. #endif
  291. mavlink_message_t msg;
  292. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  293. uint16_t i;
  294. mavlink_gps_date_time_t packet_in = {
  295. 5,72,139,206,17,84,151,218,29,96,163,230
  296. };
  297. mavlink_gps_date_time_t packet1, packet2;
  298. memset(&packet1, 0, sizeof(packet1));
  299. packet1.year = packet_in.year;
  300. packet1.month = packet_in.month;
  301. packet1.day = packet_in.day;
  302. packet1.hour = packet_in.hour;
  303. packet1.min = packet_in.min;
  304. packet1.sec = packet_in.sec;
  305. packet1.clockStat = packet_in.clockStat;
  306. packet1.visSat = packet_in.visSat;
  307. packet1.useSat = packet_in.useSat;
  308. packet1.GppGl = packet_in.GppGl;
  309. packet1.sigUsedMask = packet_in.sigUsedMask;
  310. packet1.percentUsed = packet_in.percentUsed;
  311. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  312. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  313. // cope with extensions
  314. memset(MAVLINK_MSG_ID_GPS_DATE_TIME_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_GPS_DATE_TIME_MIN_LEN);
  315. }
  316. #endif
  317. memset(&packet2, 0, sizeof(packet2));
  318. mavlink_msg_gps_date_time_encode(system_id, component_id, &msg, &packet1);
  319. mavlink_msg_gps_date_time_decode(&msg, &packet2);
  320. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  321. memset(&packet2, 0, sizeof(packet2));
  322. mavlink_msg_gps_date_time_pack(system_id, component_id, &msg , packet1.year , packet1.month , packet1.day , packet1.hour , packet1.min , packet1.sec , packet1.clockStat , packet1.visSat , packet1.useSat , packet1.GppGl , packet1.sigUsedMask , packet1.percentUsed );
  323. mavlink_msg_gps_date_time_decode(&msg, &packet2);
  324. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  325. memset(&packet2, 0, sizeof(packet2));
  326. mavlink_msg_gps_date_time_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.year , packet1.month , packet1.day , packet1.hour , packet1.min , packet1.sec , packet1.clockStat , packet1.visSat , packet1.useSat , packet1.GppGl , packet1.sigUsedMask , packet1.percentUsed );
  327. mavlink_msg_gps_date_time_decode(&msg, &packet2);
  328. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  329. memset(&packet2, 0, sizeof(packet2));
  330. mavlink_msg_to_send_buffer(buffer, &msg);
  331. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  332. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  333. }
  334. mavlink_msg_gps_date_time_decode(last_msg, &packet2);
  335. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  336. memset(&packet2, 0, sizeof(packet2));
  337. mavlink_msg_gps_date_time_send(MAVLINK_COMM_1 , packet1.year , packet1.month , packet1.day , packet1.hour , packet1.min , packet1.sec , packet1.clockStat , packet1.visSat , packet1.useSat , packet1.GppGl , packet1.sigUsedMask , packet1.percentUsed );
  338. mavlink_msg_gps_date_time_decode(last_msg, &packet2);
  339. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  340. }
  341. static void mavlink_test_mid_lvl_cmds(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  342. {
  343. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  344. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  345. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_MID_LVL_CMDS >= 256) {
  346. return;
  347. }
  348. #endif
  349. mavlink_message_t msg;
  350. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  351. uint16_t i;
  352. mavlink_mid_lvl_cmds_t packet_in = {
  353. 17.0,45.0,73.0,41
  354. };
  355. mavlink_mid_lvl_cmds_t packet1, packet2;
  356. memset(&packet1, 0, sizeof(packet1));
  357. packet1.hCommand = packet_in.hCommand;
  358. packet1.uCommand = packet_in.uCommand;
  359. packet1.rCommand = packet_in.rCommand;
  360. packet1.target = packet_in.target;
  361. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  362. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  363. // cope with extensions
  364. memset(MAVLINK_MSG_ID_MID_LVL_CMDS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_MID_LVL_CMDS_MIN_LEN);
  365. }
  366. #endif
  367. memset(&packet2, 0, sizeof(packet2));
  368. mavlink_msg_mid_lvl_cmds_encode(system_id, component_id, &msg, &packet1);
  369. mavlink_msg_mid_lvl_cmds_decode(&msg, &packet2);
  370. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  371. memset(&packet2, 0, sizeof(packet2));
  372. mavlink_msg_mid_lvl_cmds_pack(system_id, component_id, &msg , packet1.target , packet1.hCommand , packet1.uCommand , packet1.rCommand );
  373. mavlink_msg_mid_lvl_cmds_decode(&msg, &packet2);
  374. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  375. memset(&packet2, 0, sizeof(packet2));
  376. mavlink_msg_mid_lvl_cmds_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.hCommand , packet1.uCommand , packet1.rCommand );
  377. mavlink_msg_mid_lvl_cmds_decode(&msg, &packet2);
  378. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  379. memset(&packet2, 0, sizeof(packet2));
  380. mavlink_msg_to_send_buffer(buffer, &msg);
  381. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  382. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  383. }
  384. mavlink_msg_mid_lvl_cmds_decode(last_msg, &packet2);
  385. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  386. memset(&packet2, 0, sizeof(packet2));
  387. mavlink_msg_mid_lvl_cmds_send(MAVLINK_COMM_1 , packet1.target , packet1.hCommand , packet1.uCommand , packet1.rCommand );
  388. mavlink_msg_mid_lvl_cmds_decode(last_msg, &packet2);
  389. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  390. }
  391. static void mavlink_test_ctrl_srfc_pt(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  392. {
  393. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  394. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  395. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_CTRL_SRFC_PT >= 256) {
  396. return;
  397. }
  398. #endif
  399. mavlink_message_t msg;
  400. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  401. uint16_t i;
  402. mavlink_ctrl_srfc_pt_t packet_in = {
  403. 17235,139
  404. };
  405. mavlink_ctrl_srfc_pt_t packet1, packet2;
  406. memset(&packet1, 0, sizeof(packet1));
  407. packet1.bitfieldPt = packet_in.bitfieldPt;
  408. packet1.target = packet_in.target;
  409. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  410. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  411. // cope with extensions
  412. memset(MAVLINK_MSG_ID_CTRL_SRFC_PT_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_CTRL_SRFC_PT_MIN_LEN);
  413. }
  414. #endif
  415. memset(&packet2, 0, sizeof(packet2));
  416. mavlink_msg_ctrl_srfc_pt_encode(system_id, component_id, &msg, &packet1);
  417. mavlink_msg_ctrl_srfc_pt_decode(&msg, &packet2);
  418. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  419. memset(&packet2, 0, sizeof(packet2));
  420. mavlink_msg_ctrl_srfc_pt_pack(system_id, component_id, &msg , packet1.target , packet1.bitfieldPt );
  421. mavlink_msg_ctrl_srfc_pt_decode(&msg, &packet2);
  422. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  423. memset(&packet2, 0, sizeof(packet2));
  424. mavlink_msg_ctrl_srfc_pt_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.bitfieldPt );
  425. mavlink_msg_ctrl_srfc_pt_decode(&msg, &packet2);
  426. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  427. memset(&packet2, 0, sizeof(packet2));
  428. mavlink_msg_to_send_buffer(buffer, &msg);
  429. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  430. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  431. }
  432. mavlink_msg_ctrl_srfc_pt_decode(last_msg, &packet2);
  433. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  434. memset(&packet2, 0, sizeof(packet2));
  435. mavlink_msg_ctrl_srfc_pt_send(MAVLINK_COMM_1 , packet1.target , packet1.bitfieldPt );
  436. mavlink_msg_ctrl_srfc_pt_decode(last_msg, &packet2);
  437. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  438. }
  439. static void mavlink_test_slugs_camera_order(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  440. {
  441. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  442. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  443. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SLUGS_CAMERA_ORDER >= 256) {
  444. return;
  445. }
  446. #endif
  447. mavlink_message_t msg;
  448. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  449. uint16_t i;
  450. mavlink_slugs_camera_order_t packet_in = {
  451. 5,72,139,206,17
  452. };
  453. mavlink_slugs_camera_order_t packet1, packet2;
  454. memset(&packet1, 0, sizeof(packet1));
  455. packet1.target = packet_in.target;
  456. packet1.pan = packet_in.pan;
  457. packet1.tilt = packet_in.tilt;
  458. packet1.zoom = packet_in.zoom;
  459. packet1.moveHome = packet_in.moveHome;
  460. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  461. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  462. // cope with extensions
  463. memset(MAVLINK_MSG_ID_SLUGS_CAMERA_ORDER_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SLUGS_CAMERA_ORDER_MIN_LEN);
  464. }
  465. #endif
  466. memset(&packet2, 0, sizeof(packet2));
  467. mavlink_msg_slugs_camera_order_encode(system_id, component_id, &msg, &packet1);
  468. mavlink_msg_slugs_camera_order_decode(&msg, &packet2);
  469. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  470. memset(&packet2, 0, sizeof(packet2));
  471. mavlink_msg_slugs_camera_order_pack(system_id, component_id, &msg , packet1.target , packet1.pan , packet1.tilt , packet1.zoom , packet1.moveHome );
  472. mavlink_msg_slugs_camera_order_decode(&msg, &packet2);
  473. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  474. memset(&packet2, 0, sizeof(packet2));
  475. mavlink_msg_slugs_camera_order_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.pan , packet1.tilt , packet1.zoom , packet1.moveHome );
  476. mavlink_msg_slugs_camera_order_decode(&msg, &packet2);
  477. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  478. memset(&packet2, 0, sizeof(packet2));
  479. mavlink_msg_to_send_buffer(buffer, &msg);
  480. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  481. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  482. }
  483. mavlink_msg_slugs_camera_order_decode(last_msg, &packet2);
  484. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  485. memset(&packet2, 0, sizeof(packet2));
  486. mavlink_msg_slugs_camera_order_send(MAVLINK_COMM_1 , packet1.target , packet1.pan , packet1.tilt , packet1.zoom , packet1.moveHome );
  487. mavlink_msg_slugs_camera_order_decode(last_msg, &packet2);
  488. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  489. }
  490. static void mavlink_test_control_surface(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  491. {
  492. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  493. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  494. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_CONTROL_SURFACE >= 256) {
  495. return;
  496. }
  497. #endif
  498. mavlink_message_t msg;
  499. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  500. uint16_t i;
  501. mavlink_control_surface_t packet_in = {
  502. 17.0,45.0,29,96
  503. };
  504. mavlink_control_surface_t packet1, packet2;
  505. memset(&packet1, 0, sizeof(packet1));
  506. packet1.mControl = packet_in.mControl;
  507. packet1.bControl = packet_in.bControl;
  508. packet1.target = packet_in.target;
  509. packet1.idSurface = packet_in.idSurface;
  510. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  511. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  512. // cope with extensions
  513. memset(MAVLINK_MSG_ID_CONTROL_SURFACE_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_CONTROL_SURFACE_MIN_LEN);
  514. }
  515. #endif
  516. memset(&packet2, 0, sizeof(packet2));
  517. mavlink_msg_control_surface_encode(system_id, component_id, &msg, &packet1);
  518. mavlink_msg_control_surface_decode(&msg, &packet2);
  519. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  520. memset(&packet2, 0, sizeof(packet2));
  521. mavlink_msg_control_surface_pack(system_id, component_id, &msg , packet1.target , packet1.idSurface , packet1.mControl , packet1.bControl );
  522. mavlink_msg_control_surface_decode(&msg, &packet2);
  523. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  524. memset(&packet2, 0, sizeof(packet2));
  525. mavlink_msg_control_surface_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.idSurface , packet1.mControl , packet1.bControl );
  526. mavlink_msg_control_surface_decode(&msg, &packet2);
  527. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  528. memset(&packet2, 0, sizeof(packet2));
  529. mavlink_msg_to_send_buffer(buffer, &msg);
  530. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  531. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  532. }
  533. mavlink_msg_control_surface_decode(last_msg, &packet2);
  534. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  535. memset(&packet2, 0, sizeof(packet2));
  536. mavlink_msg_control_surface_send(MAVLINK_COMM_1 , packet1.target , packet1.idSurface , packet1.mControl , packet1.bControl );
  537. mavlink_msg_control_surface_decode(last_msg, &packet2);
  538. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  539. }
  540. static void mavlink_test_slugs_mobile_location(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  541. {
  542. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  543. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  544. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SLUGS_MOBILE_LOCATION >= 256) {
  545. return;
  546. }
  547. #endif
  548. mavlink_message_t msg;
  549. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  550. uint16_t i;
  551. mavlink_slugs_mobile_location_t packet_in = {
  552. 17.0,45.0,29
  553. };
  554. mavlink_slugs_mobile_location_t packet1, packet2;
  555. memset(&packet1, 0, sizeof(packet1));
  556. packet1.latitude = packet_in.latitude;
  557. packet1.longitude = packet_in.longitude;
  558. packet1.target = packet_in.target;
  559. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  560. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  561. // cope with extensions
  562. memset(MAVLINK_MSG_ID_SLUGS_MOBILE_LOCATION_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SLUGS_MOBILE_LOCATION_MIN_LEN);
  563. }
  564. #endif
  565. memset(&packet2, 0, sizeof(packet2));
  566. mavlink_msg_slugs_mobile_location_encode(system_id, component_id, &msg, &packet1);
  567. mavlink_msg_slugs_mobile_location_decode(&msg, &packet2);
  568. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  569. memset(&packet2, 0, sizeof(packet2));
  570. mavlink_msg_slugs_mobile_location_pack(system_id, component_id, &msg , packet1.target , packet1.latitude , packet1.longitude );
  571. mavlink_msg_slugs_mobile_location_decode(&msg, &packet2);
  572. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  573. memset(&packet2, 0, sizeof(packet2));
  574. mavlink_msg_slugs_mobile_location_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.latitude , packet1.longitude );
  575. mavlink_msg_slugs_mobile_location_decode(&msg, &packet2);
  576. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  577. memset(&packet2, 0, sizeof(packet2));
  578. mavlink_msg_to_send_buffer(buffer, &msg);
  579. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  580. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  581. }
  582. mavlink_msg_slugs_mobile_location_decode(last_msg, &packet2);
  583. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  584. memset(&packet2, 0, sizeof(packet2));
  585. mavlink_msg_slugs_mobile_location_send(MAVLINK_COMM_1 , packet1.target , packet1.latitude , packet1.longitude );
  586. mavlink_msg_slugs_mobile_location_decode(last_msg, &packet2);
  587. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  588. }
  589. static void mavlink_test_slugs_configuration_camera(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  590. {
  591. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  592. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  593. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SLUGS_CONFIGURATION_CAMERA >= 256) {
  594. return;
  595. }
  596. #endif
  597. mavlink_message_t msg;
  598. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  599. uint16_t i;
  600. mavlink_slugs_configuration_camera_t packet_in = {
  601. 5,72,139
  602. };
  603. mavlink_slugs_configuration_camera_t packet1, packet2;
  604. memset(&packet1, 0, sizeof(packet1));
  605. packet1.target = packet_in.target;
  606. packet1.idOrder = packet_in.idOrder;
  607. packet1.order = packet_in.order;
  608. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  609. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  610. // cope with extensions
  611. memset(MAVLINK_MSG_ID_SLUGS_CONFIGURATION_CAMERA_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SLUGS_CONFIGURATION_CAMERA_MIN_LEN);
  612. }
  613. #endif
  614. memset(&packet2, 0, sizeof(packet2));
  615. mavlink_msg_slugs_configuration_camera_encode(system_id, component_id, &msg, &packet1);
  616. mavlink_msg_slugs_configuration_camera_decode(&msg, &packet2);
  617. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  618. memset(&packet2, 0, sizeof(packet2));
  619. mavlink_msg_slugs_configuration_camera_pack(system_id, component_id, &msg , packet1.target , packet1.idOrder , packet1.order );
  620. mavlink_msg_slugs_configuration_camera_decode(&msg, &packet2);
  621. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  622. memset(&packet2, 0, sizeof(packet2));
  623. mavlink_msg_slugs_configuration_camera_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.idOrder , packet1.order );
  624. mavlink_msg_slugs_configuration_camera_decode(&msg, &packet2);
  625. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  626. memset(&packet2, 0, sizeof(packet2));
  627. mavlink_msg_to_send_buffer(buffer, &msg);
  628. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  629. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  630. }
  631. mavlink_msg_slugs_configuration_camera_decode(last_msg, &packet2);
  632. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  633. memset(&packet2, 0, sizeof(packet2));
  634. mavlink_msg_slugs_configuration_camera_send(MAVLINK_COMM_1 , packet1.target , packet1.idOrder , packet1.order );
  635. mavlink_msg_slugs_configuration_camera_decode(last_msg, &packet2);
  636. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  637. }
  638. static void mavlink_test_isr_location(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  639. {
  640. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  641. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  642. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_ISR_LOCATION >= 256) {
  643. return;
  644. }
  645. #endif
  646. mavlink_message_t msg;
  647. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  648. uint16_t i;
  649. mavlink_isr_location_t packet_in = {
  650. 17.0,45.0,73.0,41,108,175,242
  651. };
  652. mavlink_isr_location_t packet1, packet2;
  653. memset(&packet1, 0, sizeof(packet1));
  654. packet1.latitude = packet_in.latitude;
  655. packet1.longitude = packet_in.longitude;
  656. packet1.height = packet_in.height;
  657. packet1.target = packet_in.target;
  658. packet1.option1 = packet_in.option1;
  659. packet1.option2 = packet_in.option2;
  660. packet1.option3 = packet_in.option3;
  661. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  662. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  663. // cope with extensions
  664. memset(MAVLINK_MSG_ID_ISR_LOCATION_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_ISR_LOCATION_MIN_LEN);
  665. }
  666. #endif
  667. memset(&packet2, 0, sizeof(packet2));
  668. mavlink_msg_isr_location_encode(system_id, component_id, &msg, &packet1);
  669. mavlink_msg_isr_location_decode(&msg, &packet2);
  670. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  671. memset(&packet2, 0, sizeof(packet2));
  672. mavlink_msg_isr_location_pack(system_id, component_id, &msg , packet1.target , packet1.latitude , packet1.longitude , packet1.height , packet1.option1 , packet1.option2 , packet1.option3 );
  673. mavlink_msg_isr_location_decode(&msg, &packet2);
  674. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  675. memset(&packet2, 0, sizeof(packet2));
  676. mavlink_msg_isr_location_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.latitude , packet1.longitude , packet1.height , packet1.option1 , packet1.option2 , packet1.option3 );
  677. mavlink_msg_isr_location_decode(&msg, &packet2);
  678. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  679. memset(&packet2, 0, sizeof(packet2));
  680. mavlink_msg_to_send_buffer(buffer, &msg);
  681. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  682. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  683. }
  684. mavlink_msg_isr_location_decode(last_msg, &packet2);
  685. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  686. memset(&packet2, 0, sizeof(packet2));
  687. mavlink_msg_isr_location_send(MAVLINK_COMM_1 , packet1.target , packet1.latitude , packet1.longitude , packet1.height , packet1.option1 , packet1.option2 , packet1.option3 );
  688. mavlink_msg_isr_location_decode(last_msg, &packet2);
  689. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  690. }
  691. static void mavlink_test_volt_sensor(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  692. {
  693. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  694. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  695. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_VOLT_SENSOR >= 256) {
  696. return;
  697. }
  698. #endif
  699. mavlink_message_t msg;
  700. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  701. uint16_t i;
  702. mavlink_volt_sensor_t packet_in = {
  703. 17235,17339,17
  704. };
  705. mavlink_volt_sensor_t packet1, packet2;
  706. memset(&packet1, 0, sizeof(packet1));
  707. packet1.voltage = packet_in.voltage;
  708. packet1.reading2 = packet_in.reading2;
  709. packet1.r2Type = packet_in.r2Type;
  710. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  711. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  712. // cope with extensions
  713. memset(MAVLINK_MSG_ID_VOLT_SENSOR_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_VOLT_SENSOR_MIN_LEN);
  714. }
  715. #endif
  716. memset(&packet2, 0, sizeof(packet2));
  717. mavlink_msg_volt_sensor_encode(system_id, component_id, &msg, &packet1);
  718. mavlink_msg_volt_sensor_decode(&msg, &packet2);
  719. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  720. memset(&packet2, 0, sizeof(packet2));
  721. mavlink_msg_volt_sensor_pack(system_id, component_id, &msg , packet1.r2Type , packet1.voltage , packet1.reading2 );
  722. mavlink_msg_volt_sensor_decode(&msg, &packet2);
  723. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  724. memset(&packet2, 0, sizeof(packet2));
  725. mavlink_msg_volt_sensor_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.r2Type , packet1.voltage , packet1.reading2 );
  726. mavlink_msg_volt_sensor_decode(&msg, &packet2);
  727. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  728. memset(&packet2, 0, sizeof(packet2));
  729. mavlink_msg_to_send_buffer(buffer, &msg);
  730. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  731. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  732. }
  733. mavlink_msg_volt_sensor_decode(last_msg, &packet2);
  734. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  735. memset(&packet2, 0, sizeof(packet2));
  736. mavlink_msg_volt_sensor_send(MAVLINK_COMM_1 , packet1.r2Type , packet1.voltage , packet1.reading2 );
  737. mavlink_msg_volt_sensor_decode(last_msg, &packet2);
  738. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  739. }
  740. static void mavlink_test_ptz_status(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  741. {
  742. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  743. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  744. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_PTZ_STATUS >= 256) {
  745. return;
  746. }
  747. #endif
  748. mavlink_message_t msg;
  749. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  750. uint16_t i;
  751. mavlink_ptz_status_t packet_in = {
  752. 17235,17339,17
  753. };
  754. mavlink_ptz_status_t packet1, packet2;
  755. memset(&packet1, 0, sizeof(packet1));
  756. packet1.pan = packet_in.pan;
  757. packet1.tilt = packet_in.tilt;
  758. packet1.zoom = packet_in.zoom;
  759. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  760. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  761. // cope with extensions
  762. memset(MAVLINK_MSG_ID_PTZ_STATUS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_PTZ_STATUS_MIN_LEN);
  763. }
  764. #endif
  765. memset(&packet2, 0, sizeof(packet2));
  766. mavlink_msg_ptz_status_encode(system_id, component_id, &msg, &packet1);
  767. mavlink_msg_ptz_status_decode(&msg, &packet2);
  768. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  769. memset(&packet2, 0, sizeof(packet2));
  770. mavlink_msg_ptz_status_pack(system_id, component_id, &msg , packet1.zoom , packet1.pan , packet1.tilt );
  771. mavlink_msg_ptz_status_decode(&msg, &packet2);
  772. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  773. memset(&packet2, 0, sizeof(packet2));
  774. mavlink_msg_ptz_status_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.zoom , packet1.pan , packet1.tilt );
  775. mavlink_msg_ptz_status_decode(&msg, &packet2);
  776. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  777. memset(&packet2, 0, sizeof(packet2));
  778. mavlink_msg_to_send_buffer(buffer, &msg);
  779. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  780. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  781. }
  782. mavlink_msg_ptz_status_decode(last_msg, &packet2);
  783. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  784. memset(&packet2, 0, sizeof(packet2));
  785. mavlink_msg_ptz_status_send(MAVLINK_COMM_1 , packet1.zoom , packet1.pan , packet1.tilt );
  786. mavlink_msg_ptz_status_decode(last_msg, &packet2);
  787. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  788. }
  789. static void mavlink_test_uav_status(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  790. {
  791. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  792. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  793. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_UAV_STATUS >= 256) {
  794. return;
  795. }
  796. #endif
  797. mavlink_message_t msg;
  798. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  799. uint16_t i;
  800. mavlink_uav_status_t packet_in = {
  801. 17.0,45.0,73.0,101.0,129.0,65
  802. };
  803. mavlink_uav_status_t packet1, packet2;
  804. memset(&packet1, 0, sizeof(packet1));
  805. packet1.latitude = packet_in.latitude;
  806. packet1.longitude = packet_in.longitude;
  807. packet1.altitude = packet_in.altitude;
  808. packet1.speed = packet_in.speed;
  809. packet1.course = packet_in.course;
  810. packet1.target = packet_in.target;
  811. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  812. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  813. // cope with extensions
  814. memset(MAVLINK_MSG_ID_UAV_STATUS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_UAV_STATUS_MIN_LEN);
  815. }
  816. #endif
  817. memset(&packet2, 0, sizeof(packet2));
  818. mavlink_msg_uav_status_encode(system_id, component_id, &msg, &packet1);
  819. mavlink_msg_uav_status_decode(&msg, &packet2);
  820. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  821. memset(&packet2, 0, sizeof(packet2));
  822. mavlink_msg_uav_status_pack(system_id, component_id, &msg , packet1.target , packet1.latitude , packet1.longitude , packet1.altitude , packet1.speed , packet1.course );
  823. mavlink_msg_uav_status_decode(&msg, &packet2);
  824. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  825. memset(&packet2, 0, sizeof(packet2));
  826. mavlink_msg_uav_status_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target , packet1.latitude , packet1.longitude , packet1.altitude , packet1.speed , packet1.course );
  827. mavlink_msg_uav_status_decode(&msg, &packet2);
  828. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  829. memset(&packet2, 0, sizeof(packet2));
  830. mavlink_msg_to_send_buffer(buffer, &msg);
  831. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  832. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  833. }
  834. mavlink_msg_uav_status_decode(last_msg, &packet2);
  835. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  836. memset(&packet2, 0, sizeof(packet2));
  837. mavlink_msg_uav_status_send(MAVLINK_COMM_1 , packet1.target , packet1.latitude , packet1.longitude , packet1.altitude , packet1.speed , packet1.course );
  838. mavlink_msg_uav_status_decode(last_msg, &packet2);
  839. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  840. }
  841. static void mavlink_test_status_gps(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  842. {
  843. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  844. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  845. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_STATUS_GPS >= 256) {
  846. return;
  847. }
  848. #endif
  849. mavlink_message_t msg;
  850. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  851. uint16_t i;
  852. mavlink_status_gps_t packet_in = {
  853. 17.0,17443,151,218,29,96,163
  854. };
  855. mavlink_status_gps_t packet1, packet2;
  856. memset(&packet1, 0, sizeof(packet1));
  857. packet1.magVar = packet_in.magVar;
  858. packet1.csFails = packet_in.csFails;
  859. packet1.gpsQuality = packet_in.gpsQuality;
  860. packet1.msgsType = packet_in.msgsType;
  861. packet1.posStatus = packet_in.posStatus;
  862. packet1.magDir = packet_in.magDir;
  863. packet1.modeInd = packet_in.modeInd;
  864. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  865. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  866. // cope with extensions
  867. memset(MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN);
  868. }
  869. #endif
  870. memset(&packet2, 0, sizeof(packet2));
  871. mavlink_msg_status_gps_encode(system_id, component_id, &msg, &packet1);
  872. mavlink_msg_status_gps_decode(&msg, &packet2);
  873. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  874. memset(&packet2, 0, sizeof(packet2));
  875. mavlink_msg_status_gps_pack(system_id, component_id, &msg , packet1.csFails , packet1.gpsQuality , packet1.msgsType , packet1.posStatus , packet1.magVar , packet1.magDir , packet1.modeInd );
  876. mavlink_msg_status_gps_decode(&msg, &packet2);
  877. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  878. memset(&packet2, 0, sizeof(packet2));
  879. mavlink_msg_status_gps_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.csFails , packet1.gpsQuality , packet1.msgsType , packet1.posStatus , packet1.magVar , packet1.magDir , packet1.modeInd );
  880. mavlink_msg_status_gps_decode(&msg, &packet2);
  881. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  882. memset(&packet2, 0, sizeof(packet2));
  883. mavlink_msg_to_send_buffer(buffer, &msg);
  884. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  885. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  886. }
  887. mavlink_msg_status_gps_decode(last_msg, &packet2);
  888. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  889. memset(&packet2, 0, sizeof(packet2));
  890. mavlink_msg_status_gps_send(MAVLINK_COMM_1 , packet1.csFails , packet1.gpsQuality , packet1.msgsType , packet1.posStatus , packet1.magVar , packet1.magDir , packet1.modeInd );
  891. mavlink_msg_status_gps_decode(last_msg, &packet2);
  892. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  893. }
  894. static void mavlink_test_novatel_diag(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  895. {
  896. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  897. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  898. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_NOVATEL_DIAG >= 256) {
  899. return;
  900. }
  901. #endif
  902. mavlink_message_t msg;
  903. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  904. uint16_t i;
  905. mavlink_novatel_diag_t packet_in = {
  906. 963497464,45.0,17651,163,230,41,108
  907. };
  908. mavlink_novatel_diag_t packet1, packet2;
  909. memset(&packet1, 0, sizeof(packet1));
  910. packet1.receiverStatus = packet_in.receiverStatus;
  911. packet1.posSolAge = packet_in.posSolAge;
  912. packet1.csFails = packet_in.csFails;
  913. packet1.timeStatus = packet_in.timeStatus;
  914. packet1.solStatus = packet_in.solStatus;
  915. packet1.posType = packet_in.posType;
  916. packet1.velType = packet_in.velType;
  917. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  918. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  919. // cope with extensions
  920. memset(MAVLINK_MSG_ID_NOVATEL_DIAG_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_NOVATEL_DIAG_MIN_LEN);
  921. }
  922. #endif
  923. memset(&packet2, 0, sizeof(packet2));
  924. mavlink_msg_novatel_diag_encode(system_id, component_id, &msg, &packet1);
  925. mavlink_msg_novatel_diag_decode(&msg, &packet2);
  926. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  927. memset(&packet2, 0, sizeof(packet2));
  928. mavlink_msg_novatel_diag_pack(system_id, component_id, &msg , packet1.timeStatus , packet1.receiverStatus , packet1.solStatus , packet1.posType , packet1.velType , packet1.posSolAge , packet1.csFails );
  929. mavlink_msg_novatel_diag_decode(&msg, &packet2);
  930. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  931. memset(&packet2, 0, sizeof(packet2));
  932. mavlink_msg_novatel_diag_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.timeStatus , packet1.receiverStatus , packet1.solStatus , packet1.posType , packet1.velType , packet1.posSolAge , packet1.csFails );
  933. mavlink_msg_novatel_diag_decode(&msg, &packet2);
  934. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  935. memset(&packet2, 0, sizeof(packet2));
  936. mavlink_msg_to_send_buffer(buffer, &msg);
  937. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  938. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  939. }
  940. mavlink_msg_novatel_diag_decode(last_msg, &packet2);
  941. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  942. memset(&packet2, 0, sizeof(packet2));
  943. mavlink_msg_novatel_diag_send(MAVLINK_COMM_1 , packet1.timeStatus , packet1.receiverStatus , packet1.solStatus , packet1.posType , packet1.velType , packet1.posSolAge , packet1.csFails );
  944. mavlink_msg_novatel_diag_decode(last_msg, &packet2);
  945. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  946. }
  947. static void mavlink_test_sensor_diag(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  948. {
  949. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  950. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  951. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_SENSOR_DIAG >= 256) {
  952. return;
  953. }
  954. #endif
  955. mavlink_message_t msg;
  956. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  957. uint16_t i;
  958. mavlink_sensor_diag_t packet_in = {
  959. 17.0,45.0,17651,163
  960. };
  961. mavlink_sensor_diag_t packet1, packet2;
  962. memset(&packet1, 0, sizeof(packet1));
  963. packet1.float1 = packet_in.float1;
  964. packet1.float2 = packet_in.float2;
  965. packet1.int1 = packet_in.int1;
  966. packet1.char1 = packet_in.char1;
  967. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  968. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  969. // cope with extensions
  970. memset(MAVLINK_MSG_ID_SENSOR_DIAG_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_SENSOR_DIAG_MIN_LEN);
  971. }
  972. #endif
  973. memset(&packet2, 0, sizeof(packet2));
  974. mavlink_msg_sensor_diag_encode(system_id, component_id, &msg, &packet1);
  975. mavlink_msg_sensor_diag_decode(&msg, &packet2);
  976. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  977. memset(&packet2, 0, sizeof(packet2));
  978. mavlink_msg_sensor_diag_pack(system_id, component_id, &msg , packet1.float1 , packet1.float2 , packet1.int1 , packet1.char1 );
  979. mavlink_msg_sensor_diag_decode(&msg, &packet2);
  980. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  981. memset(&packet2, 0, sizeof(packet2));
  982. mavlink_msg_sensor_diag_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.float1 , packet1.float2 , packet1.int1 , packet1.char1 );
  983. mavlink_msg_sensor_diag_decode(&msg, &packet2);
  984. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  985. memset(&packet2, 0, sizeof(packet2));
  986. mavlink_msg_to_send_buffer(buffer, &msg);
  987. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  988. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  989. }
  990. mavlink_msg_sensor_diag_decode(last_msg, &packet2);
  991. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  992. memset(&packet2, 0, sizeof(packet2));
  993. mavlink_msg_sensor_diag_send(MAVLINK_COMM_1 , packet1.float1 , packet1.float2 , packet1.int1 , packet1.char1 );
  994. mavlink_msg_sensor_diag_decode(last_msg, &packet2);
  995. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  996. }
  997. static void mavlink_test_boot(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  998. {
  999. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  1000. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  1001. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_BOOT >= 256) {
  1002. return;
  1003. }
  1004. #endif
  1005. mavlink_message_t msg;
  1006. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  1007. uint16_t i;
  1008. mavlink_boot_t packet_in = {
  1009. 963497464
  1010. };
  1011. mavlink_boot_t packet1, packet2;
  1012. memset(&packet1, 0, sizeof(packet1));
  1013. packet1.version = packet_in.version;
  1014. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  1015. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  1016. // cope with extensions
  1017. memset(MAVLINK_MSG_ID_BOOT_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_BOOT_MIN_LEN);
  1018. }
  1019. #endif
  1020. memset(&packet2, 0, sizeof(packet2));
  1021. mavlink_msg_boot_encode(system_id, component_id, &msg, &packet1);
  1022. mavlink_msg_boot_decode(&msg, &packet2);
  1023. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  1024. memset(&packet2, 0, sizeof(packet2));
  1025. mavlink_msg_boot_pack(system_id, component_id, &msg , packet1.version );
  1026. mavlink_msg_boot_decode(&msg, &packet2);
  1027. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  1028. memset(&packet2, 0, sizeof(packet2));
  1029. mavlink_msg_boot_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.version );
  1030. mavlink_msg_boot_decode(&msg, &packet2);
  1031. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  1032. memset(&packet2, 0, sizeof(packet2));
  1033. mavlink_msg_to_send_buffer(buffer, &msg);
  1034. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  1035. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  1036. }
  1037. mavlink_msg_boot_decode(last_msg, &packet2);
  1038. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  1039. memset(&packet2, 0, sizeof(packet2));
  1040. mavlink_msg_boot_send(MAVLINK_COMM_1 , packet1.version );
  1041. mavlink_msg_boot_decode(last_msg, &packet2);
  1042. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  1043. }
  1044. static void mavlink_test_slugs(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  1045. {
  1046. mavlink_test_cpu_load(system_id, component_id, last_msg);
  1047. mavlink_test_sensor_bias(system_id, component_id, last_msg);
  1048. mavlink_test_diagnostic(system_id, component_id, last_msg);
  1049. mavlink_test_slugs_navigation(system_id, component_id, last_msg);
  1050. mavlink_test_data_log(system_id, component_id, last_msg);
  1051. mavlink_test_gps_date_time(system_id, component_id, last_msg);
  1052. mavlink_test_mid_lvl_cmds(system_id, component_id, last_msg);
  1053. mavlink_test_ctrl_srfc_pt(system_id, component_id, last_msg);
  1054. mavlink_test_slugs_camera_order(system_id, component_id, last_msg);
  1055. mavlink_test_control_surface(system_id, component_id, last_msg);
  1056. mavlink_test_slugs_mobile_location(system_id, component_id, last_msg);
  1057. mavlink_test_slugs_configuration_camera(system_id, component_id, last_msg);
  1058. mavlink_test_isr_location(system_id, component_id, last_msg);
  1059. mavlink_test_volt_sensor(system_id, component_id, last_msg);
  1060. mavlink_test_ptz_status(system_id, component_id, last_msg);
  1061. mavlink_test_uav_status(system_id, component_id, last_msg);
  1062. mavlink_test_status_gps(system_id, component_id, last_msg);
  1063. mavlink_test_novatel_diag(system_id, component_id, last_msg);
  1064. mavlink_test_sensor_diag(system_id, component_id, last_msg);
  1065. mavlink_test_boot(system_id, component_id, last_msg);
  1066. }
  1067. #ifdef __cplusplus
  1068. }
  1069. #endif // __cplusplus
  1070. #endif // SLUGS_TESTSUITE_H