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.

160 lines
7.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** @file
  2. * @brief MAVLink comm protocol testsuite generated from icarous.xml
  3. * @see http://qgroundcontrol.org/mavlink/
  4. */
  5. #pragma once
  6. #ifndef ICAROUS_TESTSUITE_H
  7. #define ICAROUS_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_icarous(uint8_t, uint8_t, mavlink_message_t *last_msg);
  14. static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  15. {
  16. mavlink_test_icarous(system_id, component_id, last_msg);
  17. }
  18. #endif
  19. static void mavlink_test_icarous_heartbeat(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  20. {
  21. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  22. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  23. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_ICAROUS_HEARTBEAT >= 256) {
  24. return;
  25. }
  26. #endif
  27. mavlink_message_t msg;
  28. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  29. uint16_t i;
  30. mavlink_icarous_heartbeat_t packet_in = {
  31. 5
  32. };
  33. mavlink_icarous_heartbeat_t packet1, packet2;
  34. memset(&packet1, 0, sizeof(packet1));
  35. packet1.status = packet_in.status;
  36. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  37. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  38. // cope with extensions
  39. memset(MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_ICAROUS_HEARTBEAT_MIN_LEN);
  40. }
  41. #endif
  42. memset(&packet2, 0, sizeof(packet2));
  43. mavlink_msg_icarous_heartbeat_encode(system_id, component_id, &msg, &packet1);
  44. mavlink_msg_icarous_heartbeat_decode(&msg, &packet2);
  45. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  46. memset(&packet2, 0, sizeof(packet2));
  47. mavlink_msg_icarous_heartbeat_pack(system_id, component_id, &msg , packet1.status );
  48. mavlink_msg_icarous_heartbeat_decode(&msg, &packet2);
  49. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  50. memset(&packet2, 0, sizeof(packet2));
  51. mavlink_msg_icarous_heartbeat_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.status );
  52. mavlink_msg_icarous_heartbeat_decode(&msg, &packet2);
  53. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  54. memset(&packet2, 0, sizeof(packet2));
  55. mavlink_msg_to_send_buffer(buffer, &msg);
  56. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  57. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  58. }
  59. mavlink_msg_icarous_heartbeat_decode(last_msg, &packet2);
  60. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  61. memset(&packet2, 0, sizeof(packet2));
  62. mavlink_msg_icarous_heartbeat_send(MAVLINK_COMM_1 , packet1.status );
  63. mavlink_msg_icarous_heartbeat_decode(last_msg, &packet2);
  64. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  65. }
  66. static void mavlink_test_icarous_kinematic_bands(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  67. {
  68. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  69. mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
  70. if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS >= 256) {
  71. return;
  72. }
  73. #endif
  74. mavlink_message_t msg;
  75. uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
  76. uint16_t i;
  77. mavlink_icarous_kinematic_bands_t packet_in = {
  78. 17.0,45.0,73.0,101.0,129.0,157.0,185.0,213.0,241.0,269.0,125,192,3,70,137,204
  79. };
  80. mavlink_icarous_kinematic_bands_t packet1, packet2;
  81. memset(&packet1, 0, sizeof(packet1));
  82. packet1.min1 = packet_in.min1;
  83. packet1.max1 = packet_in.max1;
  84. packet1.min2 = packet_in.min2;
  85. packet1.max2 = packet_in.max2;
  86. packet1.min3 = packet_in.min3;
  87. packet1.max3 = packet_in.max3;
  88. packet1.min4 = packet_in.min4;
  89. packet1.max4 = packet_in.max4;
  90. packet1.min5 = packet_in.min5;
  91. packet1.max5 = packet_in.max5;
  92. packet1.numBands = packet_in.numBands;
  93. packet1.type1 = packet_in.type1;
  94. packet1.type2 = packet_in.type2;
  95. packet1.type3 = packet_in.type3;
  96. packet1.type4 = packet_in.type4;
  97. packet1.type5 = packet_in.type5;
  98. #ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
  99. if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
  100. // cope with extensions
  101. memset(MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_ICAROUS_KINEMATIC_BANDS_MIN_LEN);
  102. }
  103. #endif
  104. memset(&packet2, 0, sizeof(packet2));
  105. mavlink_msg_icarous_kinematic_bands_encode(system_id, component_id, &msg, &packet1);
  106. mavlink_msg_icarous_kinematic_bands_decode(&msg, &packet2);
  107. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  108. memset(&packet2, 0, sizeof(packet2));
  109. mavlink_msg_icarous_kinematic_bands_pack(system_id, component_id, &msg , packet1.numBands , packet1.type1 , packet1.min1 , packet1.max1 , packet1.type2 , packet1.min2 , packet1.max2 , packet1.type3 , packet1.min3 , packet1.max3 , packet1.type4 , packet1.min4 , packet1.max4 , packet1.type5 , packet1.min5 , packet1.max5 );
  110. mavlink_msg_icarous_kinematic_bands_decode(&msg, &packet2);
  111. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  112. memset(&packet2, 0, sizeof(packet2));
  113. mavlink_msg_icarous_kinematic_bands_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.numBands , packet1.type1 , packet1.min1 , packet1.max1 , packet1.type2 , packet1.min2 , packet1.max2 , packet1.type3 , packet1.min3 , packet1.max3 , packet1.type4 , packet1.min4 , packet1.max4 , packet1.type5 , packet1.min5 , packet1.max5 );
  114. mavlink_msg_icarous_kinematic_bands_decode(&msg, &packet2);
  115. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  116. memset(&packet2, 0, sizeof(packet2));
  117. mavlink_msg_to_send_buffer(buffer, &msg);
  118. for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
  119. comm_send_ch(MAVLINK_COMM_0, buffer[i]);
  120. }
  121. mavlink_msg_icarous_kinematic_bands_decode(last_msg, &packet2);
  122. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  123. memset(&packet2, 0, sizeof(packet2));
  124. mavlink_msg_icarous_kinematic_bands_send(MAVLINK_COMM_1 , packet1.numBands , packet1.type1 , packet1.min1 , packet1.max1 , packet1.type2 , packet1.min2 , packet1.max2 , packet1.type3 , packet1.min3 , packet1.max3 , packet1.type4 , packet1.min4 , packet1.max4 , packet1.type5 , packet1.min5 , packet1.max5 );
  125. mavlink_msg_icarous_kinematic_bands_decode(last_msg, &packet2);
  126. MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
  127. }
  128. static void mavlink_test_icarous(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
  129. {
  130. mavlink_test_icarous_heartbeat(system_id, component_id, last_msg);
  131. mavlink_test_icarous_kinematic_bands(system_id, component_id, last_msg);
  132. }
  133. #ifdef __cplusplus
  134. }
  135. #endif // __cplusplus
  136. #endif // ICAROUS_TESTSUITE_H