mavlink library
Dependents: mavlink F429ZI_LCD_demo
Fork of mavlink_bridge by
mavlink/v10/uwb/testsuite.h
- Committer:
- bhepp
- Date:
- 2016-01-23
- Revision:
- 2:0f4dfdec5fd1
File content as of revision 2:0f4dfdec5fd1:
/** @file * @brief MAVLink comm protocol testsuite generated from uwb.xml * @see http://qgroundcontrol.org/mavlink/ */ #ifndef UWB_TESTSUITE_H #define UWB_TESTSUITE_H #ifdef __cplusplus extern "C" { #endif #ifndef MAVLINK_TEST_ALL #define MAVLINK_TEST_ALL static void mavlink_test_common(uint8_t, uint8_t, mavlink_message_t *last_msg); static void mavlink_test_uwb(uint8_t, uint8_t, mavlink_message_t *last_msg); static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_test_common(system_id, component_id, last_msg); mavlink_test_uwb(system_id, component_id, last_msg); } #endif #include "../common/testsuite.h" static void mavlink_test_uwb_range(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_t packet_in = { 963497464,45.0,73.0,41,108 }; mavlink_uwb_range_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.stamp_us = packet_in.stamp_us; packet1.round_trip_time = packet_in.round_trip_time; packet1.range = packet_in.range; packet1.address = packet_in.address; packet1.remote_address = packet_in.remote_address; memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_pack(system_id, component_id, &msg , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range ); mavlink_msg_uwb_range_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); 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 ); mavlink_msg_uwb_range_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_send(MAVLINK_COMM_1 , packet1.address , packet1.remote_address , packet1.stamp_us , packet1.round_trip_time , packet1.range ); mavlink_msg_uwb_range_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb_range_stats(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_stats_t packet_in = { 963497464,45.0,73.0,17859,17963,18067,18171,18275,18379,18483,18587,18691,18795,18899,19003,19107,19211,19315,19419,137,204 }; mavlink_uwb_range_stats_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.stamp_us = packet_in.stamp_us; packet1.round_trip_time = packet_in.round_trip_time; packet1.range = packet_in.range; packet1.std_noise_1 = packet_in.std_noise_1; packet1.std_noise_2 = packet_in.std_noise_2; packet1.preamble_acc_count_1 = packet_in.preamble_acc_count_1; packet1.preamble_acc_count_2 = packet_in.preamble_acc_count_2; packet1.first_path_index_1 = packet_in.first_path_index_1; packet1.first_path_index_2 = packet_in.first_path_index_2; packet1.first_path_amp_1_1 = packet_in.first_path_amp_1_1; packet1.first_path_amp_1_2 = packet_in.first_path_amp_1_2; packet1.first_path_amp_2_1 = packet_in.first_path_amp_2_1; packet1.first_path_amp_2_2 = packet_in.first_path_amp_2_2; packet1.first_path_amp_3_1 = packet_in.first_path_amp_3_1; packet1.first_path_amp_3_2 = packet_in.first_path_amp_3_2; packet1.channel_impulse_response_power_1 = packet_in.channel_impulse_response_power_1; packet1.channel_impulse_response_power_2 = packet_in.channel_impulse_response_power_2; packet1.prf_1 = packet_in.prf_1; packet1.prf_2 = packet_in.prf_2; packet1.address = packet_in.address; packet1.remote_address = packet_in.remote_address; memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_stats_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_stats_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); 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.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.prf_1 , packet1.prf_2 ); mavlink_msg_uwb_range_stats_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); 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.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.prf_1 , packet1.prf_2 ); mavlink_msg_uwb_range_stats_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_stats_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); 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.preamble_acc_count_1 , packet1.preamble_acc_count_2 , packet1.first_path_index_1 , packet1.first_path_index_2 , packet1.first_path_amp_1_1 , packet1.first_path_amp_1_2 , packet1.first_path_amp_2_1 , packet1.first_path_amp_2_2 , packet1.first_path_amp_3_1 , packet1.first_path_amp_3_2 , packet1.channel_impulse_response_power_1 , packet1.channel_impulse_response_power_2 , packet1.prf_1 , packet1.prf_2 ); mavlink_msg_uwb_range_stats_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb_range_batch_2(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_batch_2_t packet_in = { { 17.0, 18.0 },{ 29, 30 },163 }; mavlink_uwb_range_batch_2_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.remote_address = packet_in.remote_address; mav_array_memcpy(packet1.range, packet_in.range, sizeof(float)*2); mav_array_memcpy(packet1.addresses, packet_in.addresses, sizeof(uint8_t)*2); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_2_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_batch_2_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_2_pack(system_id, component_id, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_2_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_2_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_2_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_batch_2_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_2_send(MAVLINK_COMM_1 , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_2_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb_range_batch_3(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_batch_3_t packet_in = { { 17.0, 18.0, 19.0 },{ 41, 42, 43 },242 }; mavlink_uwb_range_batch_3_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.remote_address = packet_in.remote_address; mav_array_memcpy(packet1.range, packet_in.range, sizeof(float)*3); mav_array_memcpy(packet1.addresses, packet_in.addresses, sizeof(uint8_t)*3); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_3_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_batch_3_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_3_pack(system_id, component_id, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_3_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_3_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_3_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_batch_3_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_3_send(MAVLINK_COMM_1 , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_3_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb_range_batch_4(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_batch_4_t packet_in = { { 17.0, 18.0, 19.0, 20.0 },{ 53, 54, 55, 56 },65 }; mavlink_uwb_range_batch_4_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.remote_address = packet_in.remote_address; mav_array_memcpy(packet1.range, packet_in.range, sizeof(float)*4); mav_array_memcpy(packet1.addresses, packet_in.addresses, sizeof(uint8_t)*4); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_4_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_batch_4_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_4_pack(system_id, component_id, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_4_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_4_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_4_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_batch_4_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_4_send(MAVLINK_COMM_1 , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_4_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb_range_batch_5(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_message_t msg; uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; uint16_t i; mavlink_uwb_range_batch_5_t packet_in = { { 17.0, 18.0, 19.0, 20.0, 21.0 },{ 65, 66, 67, 68, 69 },144 }; mavlink_uwb_range_batch_5_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); packet1.remote_address = packet_in.remote_address; mav_array_memcpy(packet1.range, packet_in.range, sizeof(float)*5); mav_array_memcpy(packet1.addresses, packet_in.addresses, sizeof(uint8_t)*5); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_5_encode(system_id, component_id, &msg, &packet1); mavlink_msg_uwb_range_batch_5_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_5_pack(system_id, component_id, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_5_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_5_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_5_decode(&msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) { comm_send_ch(MAVLINK_COMM_0, buffer[i]); } mavlink_msg_uwb_range_batch_5_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); memset(&packet2, 0, sizeof(packet2)); mavlink_msg_uwb_range_batch_5_send(MAVLINK_COMM_1 , packet1.addresses , packet1.remote_address , packet1.range ); mavlink_msg_uwb_range_batch_5_decode(last_msg, &packet2); MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } static void mavlink_test_uwb(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) { mavlink_test_uwb_range(system_id, component_id, last_msg); mavlink_test_uwb_range_stats(system_id, component_id, last_msg); mavlink_test_uwb_range_batch_2(system_id, component_id, last_msg); mavlink_test_uwb_range_batch_3(system_id, component_id, last_msg); mavlink_test_uwb_range_batch_4(system_id, component_id, last_msg); mavlink_test_uwb_range_batch_5(system_id, component_id, last_msg); } #ifdef __cplusplus } #endif // __cplusplus #endif // UWB_TESTSUITE_H