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.

173 lines
8.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #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_autoquad(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_autoquad(system_id, component_id, last_msg);
  19. }
  20. #endif
  21. #include "../common/testsuite.h"
  22. static void mavlink_test_aq_telemetry_f(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_AQ_TELEMETRY_F >= 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_aq_telemetry_f_t packet_in = {
  34. 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
  35. };
  36. mavlink_aq_telemetry_f_t packet1, packet2;
  37. memset(&packet1, 0, sizeof(packet1));
  38. packet1.value1 = packet_in.value1;
  39. packet1.value2 = packet_in.value2;
  40. packet1.value3 = packet_in.value3;
  41. packet1.value4 = packet_in.value4;
  42. packet1.value5 = packet_in.value5;
  43. packet1.value6 = packet_in.value6;
  44. packet1.value7 = packet_in.value7;
  45. packet1.value8 = packet_in.value8;
  46. packet1.value9 = packet_in.value9;
  47. packet1.value10 = packet_in.value10;
  48. packet1.value11 = packet_in.value11;
  49. packet1.value12 = packet_in.value12;
  50. packet1.value13 = packet_in.value13;
  51. packet1.value14 = packet_in.value14;
  52. packet1.value15 = packet_in.value15;
  53. packet1.value16 = packet_in.value16;
  54. packet1.value17 = packet_in.value17;
  55. packet1.value18 = packet_in.value18;
  56. packet1.value19 = packet_in.value19;
  57. packet1.value20 = packet_in.value20;
  58. packet1.Index = packet_in.Index;
  59. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  60. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  61. // cope with extensions
  62. memset(MAVLINK_MSG_ID_AQ_TELEMETRY_F_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_AQ_TELEMETRY_F_MIN_LEN);
  63. }
  64. #endif
  65. memset(&packet2, 0, sizeof(packet2));
  66. mavlink_msg_aq_telemetry_f_encode(system_id, component_id, &msg, &packet1);
  67. mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
  68. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  69. memset(&packet2, 0, sizeof(packet2));
  70. 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 );
  71. mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
  72. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  73. memset(&packet2, 0, sizeof(packet2));
  74. 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 );
  75. mavlink_msg_aq_telemetry_f_decode(&msg, &packet2);
  76. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  77. memset(&packet2, 0, sizeof(packet2));
  78. mavlink_msg_to_send_buffer(buffer, &msg);
  79. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  80. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  81. }
  82. mavlink_msg_aq_telemetry_f_decode(last_msg, &packet2);
  83. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  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. static void mavlink_test_aq_esc_telemetry(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  90. {
  91. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  92. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  93. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_AQ_ESC_TELEMETRY >= 256) {
  94. return;
  95. }
  96. #endif
  97. mavlink_message_t msg;
  98. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  99. uint16_t i;
  100. mavlink_aq_esc_telemetry_t packet_in = {
  101. 963497464,{ 963497672, 963497673, 963497674, 963497675 },{ 963498504, 963498505, 963498506, 963498507 },{ 19107, 19108, 19109, 19110 },137,204,15,{ 82, 83, 84, 85 },{ 94, 95, 96, 97 }
  102. };
  103. mavlink_aq_esc_telemetry_t packet1, packet2;
  104. memset(&packet1, 0, sizeof(packet1));
  105. packet1.time_boot_ms = packet_in.time_boot_ms;
  106. packet1.seq = packet_in.seq;
  107. packet1.num_motors = packet_in.num_motors;
  108. packet1.num_in_seq = packet_in.num_in_seq;
  109. mav_array_memcpy(packet1.data0, packet_in.data0, sizeof(uint32_t)*4);
  110. mav_array_memcpy(packet1.data1, packet_in.data1, sizeof(uint32_t)*4);
  111. mav_array_memcpy(packet1.status_age, packet_in.status_age, sizeof(uint16_t)*4);
  112. mav_array_memcpy(packet1.escid, packet_in.escid, sizeof(uint8_t)*4);
  113. mav_array_memcpy(packet1.data_version, packet_in.data_version, sizeof(uint8_t)*4);
  114. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  115. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  116. // cope with extensions
  117. memset(MAVLINK_MSG_ID_AQ_ESC_TELEMETRY_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_AQ_ESC_TELEMETRY_MIN_LEN);
  118. }
  119. #endif
  120. memset(&packet2, 0, sizeof(packet2));
  121. mavlink_msg_aq_esc_telemetry_encode(system_id, component_id, &msg, &packet1);
  122. mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
  123. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  124. memset(&packet2, 0, sizeof(packet2));
  125. 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 );
  126. mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
  127. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  128. memset(&packet2, 0, sizeof(packet2));
  129. 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 );
  130. mavlink_msg_aq_esc_telemetry_decode(&msg, &packet2);
  131. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  132. memset(&packet2, 0, sizeof(packet2));
  133. mavlink_msg_to_send_buffer(buffer, &msg);
  134. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  135. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  136. }
  137. mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
  138. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  139. memset(&packet2, 0, sizeof(packet2));
  140. 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 );
  141. mavlink_msg_aq_esc_telemetry_decode(last_msg, &packet2);
  142. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  143. }
  144. static void mavlink_test_autoquad(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  145. {
  146. mavlink_test_aq_telemetry_f(system_id, component_id, last_msg);
  147. mavlink_test_aq_esc_telemetry(system_id, component_id, last_msg);
  148. }
  149. #ifdef __cplusplus
  150. }
  151. #endif // __cplusplus
  152. #endif // AUTOQUAD_TESTSUITE_H