mavlink library

Dependents:   mavlink F429ZI_LCD_demo

Fork of mavlink_bridge by Benjamin Hepp

mavlink/v10/uwb/testsuite.h

Committer:
bhepp
Date:
2015-11-24
Revision:
0:28183cc7963f

File content as of revision 0:28183cc7963f:

/** @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,19523,19627,19731,19835,19939,20043,20147,20251,185,252
    };
	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.std_noise_3 = packet_in.std_noise_3;
        	packet1.preamble_acc_count_1 = packet_in.preamble_acc_count_1;
        	packet1.preamble_acc_count_2 = packet_in.preamble_acc_count_2;
        	packet1.preamble_acc_count_3 = packet_in.preamble_acc_count_3;
        	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_index_3 = packet_in.first_path_index_3;
        	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_1_3 = packet_in.first_path_amp_1_3;
        	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_2_3 = packet_in.first_path_amp_2_3;
        	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.first_path_amp_3_3 = packet_in.first_path_amp_3_3;
        	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.channel_impulse_response_power_3 = packet_in.channel_impulse_response_power_3;
        	packet1.prf_1 = packet_in.prf_1;
        	packet1.prf_2 = packet_in.prf_2;
        	packet1.prf_3 = packet_in.prf_3;
        	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.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 );
	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.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 );
	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.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 );
	mavlink_msg_uwb_range_stats_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);
}

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // UWB_TESTSUITE_H