mavlink library
Dependents: mavlink F429ZI_LCD_demo
Fork of mavlink_bridge by
mavlink/v10/uwb/testsuite.h@0:28183cc7963f, 2015-11-24 (annotated)
- Committer:
- bhepp
- Date:
- Tue Nov 24 16:41:11 2015 +0000
- Revision:
- 0:28183cc7963f
Mavlink bridge for Mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhepp | 0:28183cc7963f | 1 | /** @file |
bhepp | 0:28183cc7963f | 2 | * @brief MAVLink comm protocol testsuite generated from uwb.xml |
bhepp | 0:28183cc7963f | 3 | * @see http://qgroundcontrol.org/mavlink/ |
bhepp | 0:28183cc7963f | 4 | */ |
bhepp | 0:28183cc7963f | 5 | #ifndef UWB_TESTSUITE_H |
bhepp | 0:28183cc7963f | 6 | #define UWB_TESTSUITE_H |
bhepp | 0:28183cc7963f | 7 | |
bhepp | 0:28183cc7963f | 8 | #ifdef __cplusplus |
bhepp | 0:28183cc7963f | 9 | extern "C" { |
bhepp | 0:28183cc7963f | 10 | #endif |
bhepp | 0:28183cc7963f | 11 | |
bhepp | 0:28183cc7963f | 12 | #ifndef MAVLINK_TEST_ALL |
bhepp | 0:28183cc7963f | 13 | #define MAVLINK_TEST_ALL |
bhepp | 0:28183cc7963f | 14 | static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg); |
bhepp | 0:28183cc7963f | 15 | static void mavlink_test_uwb(uint8_t, uint8_t, mavlink_message_t *last_msg); |
bhepp | 0:28183cc7963f | 16 | |
bhepp | 0:28183cc7963f | 17 | static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) |
bhepp | 0:28183cc7963f | 18 | { |
bhepp | 0:28183cc7963f | 19 | mavlink_test_common(system_id, component_id, last_msg); |
bhepp | 0:28183cc7963f | 20 | mavlink_test_uwb(system_id, component_id, last_msg); |
bhepp | 0:28183cc7963f | 21 | } |
bhepp | 0:28183cc7963f | 22 | #endif |
bhepp | 0:28183cc7963f | 23 | |
bhepp | 0:28183cc7963f | 24 | #include "../common/testsuite.h" |
bhepp | 0:28183cc7963f | 25 | |
bhepp | 0:28183cc7963f | 26 | |
bhepp | 0:28183cc7963f | 27 | static void mavlink_test_uwb_range(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) |
bhepp | 0:28183cc7963f | 28 | { |
bhepp | 0:28183cc7963f | 29 | mavlink_message_t msg; |
bhepp | 0:28183cc7963f | 30 | uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; |
bhepp | 0:28183cc7963f | 31 | uint16_t i; |
bhepp | 0:28183cc7963f | 32 | mavlink_uwb_range_t packet_in = { |
bhepp | 0:28183cc7963f | 33 | 963497464,45.0,73.0,41,108 |
bhepp | 0:28183cc7963f | 34 | }; |
bhepp | 0:28183cc7963f | 35 | mavlink_uwb_range_t packet1, packet2; |
bhepp | 0:28183cc7963f | 36 | memset(&packet1, 0, sizeof(packet1)); |
bhepp | 0:28183cc7963f | 37 | packet1.stamp_us = packet_in.stamp_us; |
bhepp | 0:28183cc7963f | 38 | packet1.round_trip_time = packet_in.round_trip_time; |
bhepp | 0:28183cc7963f | 39 | packet1.range = packet_in.range; |
bhepp | 0:28183cc7963f | 40 | packet1.address = packet_in.address; |
bhepp | 0:28183cc7963f | 41 | packet1.remote_address = packet_in.remote_address; |
bhepp | 0:28183cc7963f | 42 | |
bhepp | 0:28183cc7963f | 43 | |
bhepp | 0:28183cc7963f | 44 | |
bhepp | 0:28183cc7963f | 45 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 46 | mavlink_msg_uwb_range_encode(system_id, component_id, &msg, &packet1); |
bhepp | 0:28183cc7963f | 47 | mavlink_msg_uwb_range_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 48 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 49 | |
bhepp | 0:28183cc7963f | 50 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 51 | mavlink_msg_uwb_range_pack(system_id, component_id, &msg , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range ); |
bhepp | 0:28183cc7963f | 52 | mavlink_msg_uwb_range_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 53 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 54 | |
bhepp | 0:28183cc7963f | 55 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 56 | mavlink_msg_uwb_range_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range ); |
bhepp | 0:28183cc7963f | 57 | mavlink_msg_uwb_range_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 58 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 59 | |
bhepp | 0:28183cc7963f | 60 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 61 | mavlink_msg_to_send_buffer(buffer, &msg); |
bhepp | 0:28183cc7963f | 62 | for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { |
bhepp | 0:28183cc7963f | 63 | comm_send_ch(MAVLINK_COMM_0, buffer[i]); |
bhepp | 0:28183cc7963f | 64 | } |
bhepp | 0:28183cc7963f | 65 | mavlink_msg_uwb_range_decode(last_msg, &packet2); |
bhepp | 0:28183cc7963f | 66 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 67 | |
bhepp | 0:28183cc7963f | 68 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 69 | mavlink_msg_uwb_range_send(MAVLINK_COMM_1 , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range ); |
bhepp | 0:28183cc7963f | 70 | mavlink_msg_uwb_range_decode(last_msg, &packet2); |
bhepp | 0:28183cc7963f | 71 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 72 | } |
bhepp | 0:28183cc7963f | 73 | |
bhepp | 0:28183cc7963f | 74 | static void mavlink_test_uwb_range_stats(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) |
bhepp | 0:28183cc7963f | 75 | { |
bhepp | 0:28183cc7963f | 76 | mavlink_message_t msg; |
bhepp | 0:28183cc7963f | 77 | uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; |
bhepp | 0:28183cc7963f | 78 | uint16_t i; |
bhepp | 0:28183cc7963f | 79 | mavlink_uwb_range_stats_t packet_in = { |
bhepp | 0:28183cc7963f | 80 | 963497464,45.0,73.0,17859,17963,18067,18171,18275,18379,18483,18587,18691,18795,18899,19003,19107,19211,19315,19419,19523,19627,19731,19835,19939,20043,20147,20251,185,252 |
bhepp | 0:28183cc7963f | 81 | }; |
bhepp | 0:28183cc7963f | 82 | mavlink_uwb_range_stats_t packet1, packet2; |
bhepp | 0:28183cc7963f | 83 | memset(&packet1, 0, sizeof(packet1)); |
bhepp | 0:28183cc7963f | 84 | packet1.stamp_us = packet_in.stamp_us; |
bhepp | 0:28183cc7963f | 85 | packet1.round_trip_time = packet_in.round_trip_time; |
bhepp | 0:28183cc7963f | 86 | packet1.range = packet_in.range; |
bhepp | 0:28183cc7963f | 87 | packet1.std_noise_1 = packet_in.std_noise_1; |
bhepp | 0:28183cc7963f | 88 | packet1.std_noise_2 = packet_in.std_noise_2; |
bhepp | 0:28183cc7963f | 89 | packet1.std_noise_3 = packet_in.std_noise_3; |
bhepp | 0:28183cc7963f | 90 | packet1.preamble_acc_count_1 = packet_in.preamble_acc_count_1; |
bhepp | 0:28183cc7963f | 91 | packet1.preamble_acc_count_2 = packet_in.preamble_acc_count_2; |
bhepp | 0:28183cc7963f | 92 | packet1.preamble_acc_count_3 = packet_in.preamble_acc_count_3; |
bhepp | 0:28183cc7963f | 93 | packet1.first_path_index_1 = packet_in.first_path_index_1; |
bhepp | 0:28183cc7963f | 94 | packet1.first_path_index_2 = packet_in.first_path_index_2; |
bhepp | 0:28183cc7963f | 95 | packet1.first_path_index_3 = packet_in.first_path_index_3; |
bhepp | 0:28183cc7963f | 96 | packet1.first_path_amp_1_1 = packet_in.first_path_amp_1_1; |
bhepp | 0:28183cc7963f | 97 | packet1.first_path_amp_1_2 = packet_in.first_path_amp_1_2; |
bhepp | 0:28183cc7963f | 98 | packet1.first_path_amp_1_3 = packet_in.first_path_amp_1_3; |
bhepp | 0:28183cc7963f | 99 | packet1.first_path_amp_2_1 = packet_in.first_path_amp_2_1; |
bhepp | 0:28183cc7963f | 100 | packet1.first_path_amp_2_2 = packet_in.first_path_amp_2_2; |
bhepp | 0:28183cc7963f | 101 | packet1.first_path_amp_2_3 = packet_in.first_path_amp_2_3; |
bhepp | 0:28183cc7963f | 102 | packet1.first_path_amp_3_1 = packet_in.first_path_amp_3_1; |
bhepp | 0:28183cc7963f | 103 | packet1.first_path_amp_3_2 = packet_in.first_path_amp_3_2; |
bhepp | 0:28183cc7963f | 104 | packet1.first_path_amp_3_3 = packet_in.first_path_amp_3_3; |
bhepp | 0:28183cc7963f | 105 | packet1.channel_impulse_response_power_1 = packet_in.channel_impulse_response_power_1; |
bhepp | 0:28183cc7963f | 106 | packet1.channel_impulse_response_power_2 = packet_in.channel_impulse_response_power_2; |
bhepp | 0:28183cc7963f | 107 | packet1.channel_impulse_response_power_3 = packet_in.channel_impulse_response_power_3; |
bhepp | 0:28183cc7963f | 108 | packet1.prf_1 = packet_in.prf_1; |
bhepp | 0:28183cc7963f | 109 | packet1.prf_2 = packet_in.prf_2; |
bhepp | 0:28183cc7963f | 110 | packet1.prf_3 = packet_in.prf_3; |
bhepp | 0:28183cc7963f | 111 | packet1.address = packet_in.address; |
bhepp | 0:28183cc7963f | 112 | packet1.remote_address = packet_in.remote_address; |
bhepp | 0:28183cc7963f | 113 | |
bhepp | 0:28183cc7963f | 114 | |
bhepp | 0:28183cc7963f | 115 | |
bhepp | 0:28183cc7963f | 116 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 117 | mavlink_msg_uwb_range_stats_encode(system_id, component_id, &msg, &packet1); |
bhepp | 0:28183cc7963f | 118 | mavlink_msg_uwb_range_stats_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 119 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 120 | |
bhepp | 0:28183cc7963f | 121 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 122 | mavlink_msg_uwb_range_stats_pack(system_id, component_id, &msg , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range , packet1.std_noise_1 , packet1.std_noise_2 , packet1.std_noise_3 , packet1.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.preamble_acc_count_3 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_index_3 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_1_3 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_2_3 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.first_path_amp_3_3 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.channel_impulse_response_power_3 , packet1.prf_1 , packet1.prf_2 , packet1.prf_3 ); |
bhepp | 0:28183cc7963f | 123 | mavlink_msg_uwb_range_stats_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 124 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 125 | |
bhepp | 0:28183cc7963f | 126 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 127 | mavlink_msg_uwb_range_stats_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range , packet1.std_noise_1 , packet1.std_noise_2 , packet1.std_noise_3 , packet1.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.preamble_acc_count_3 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_index_3 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_1_3 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_2_3 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.first_path_amp_3_3 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.channel_impulse_response_power_3 , packet1.prf_1 , packet1.prf_2 , packet1.prf_3 ); |
bhepp | 0:28183cc7963f | 128 | mavlink_msg_uwb_range_stats_decode(&msg, &packet2); |
bhepp | 0:28183cc7963f | 129 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 130 | |
bhepp | 0:28183cc7963f | 131 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 132 | mavlink_msg_to_send_buffer(buffer, &msg); |
bhepp | 0:28183cc7963f | 133 | for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { |
bhepp | 0:28183cc7963f | 134 | comm_send_ch(MAVLINK_COMM_0, buffer[i]); |
bhepp | 0:28183cc7963f | 135 | } |
bhepp | 0:28183cc7963f | 136 | mavlink_msg_uwb_range_stats_decode(last_msg, &packet2); |
bhepp | 0:28183cc7963f | 137 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 138 | |
bhepp | 0:28183cc7963f | 139 | memset(&packet2, 0, sizeof(packet2)); |
bhepp | 0:28183cc7963f | 140 | mavlink_msg_uwb_range_stats_send(MAVLINK_COMM_1 , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range , packet1.std_noise_1 , packet1.std_noise_2 , packet1.std_noise_3 , packet1.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.preamble_acc_count_3 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_index_3 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_1_3 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_2_3 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.first_path_amp_3_3 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.channel_impulse_response_power_3 , packet1.prf_1 , packet1.prf_2 , packet1.prf_3 ); |
bhepp | 0:28183cc7963f | 141 | mavlink_msg_uwb_range_stats_decode(last_msg, &packet2); |
bhepp | 0:28183cc7963f | 142 | MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); |
bhepp | 0:28183cc7963f | 143 | } |
bhepp | 0:28183cc7963f | 144 | |
bhepp | 0:28183cc7963f | 145 | static void mavlink_test_uwb(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) |
bhepp | 0:28183cc7963f | 146 | { |
bhepp | 0:28183cc7963f | 147 | mavlink_test_uwb_range(system_id, component_id, last_msg); |
bhepp | 0:28183cc7963f | 148 | mavlink_test_uwb_range_stats(system_id, component_id, last_msg); |
bhepp | 0:28183cc7963f | 149 | } |
bhepp | 0:28183cc7963f | 150 | |
bhepp | 0:28183cc7963f | 151 | #ifdef __cplusplus |
bhepp | 0:28183cc7963f | 152 | } |
bhepp | 0:28183cc7963f | 153 | #endif // __cplusplus |
bhepp | 0:28183cc7963f | 154 | #endif // UWB_TESTSUITE_H |
bhepp | 0:28183cc7963f | 155 |