e7cf44504c
## 架构升级:Service Registry + Bridge 模式 - 新增 PluginSDK/IPluginServices.h:10 个纯虚服务接口(IDataProvider/ILinkProvider/...) - 新增 MavLinkServiceBridge:单 QObject 实现全部服务,隔离 MavLinkNode 依赖 - 升级 PluginManifest:支持 plugin.json 的 provides/consumes 声明式依赖 - 实现 ExtensionHost::autoWire():元对象自省自动连接信号槽 - 集成到 AppController:initModules() 中创建桥接器并注册到 ServiceRegistry - CockpitPlugin 演示服务发现:initialize() 中通过 PluginContext 查找服务 ## 代码清理 - Plugins/opmap:~280 行死代码(waypointsetting 100行注释块/tilematrix 54行/等27个文件) - Plugins/MavLinkNode:~200 行 GBK 乱码注释翻译为 UTF-8 + 12 行注释死代码 - Plugins/ToolsUI:~222 行死代码(ECU.cpp 82行/INS.cpp 113行/Parse/ToolsUI 等) - StatusUI/Setting/MissionUI:~65 行注释死代码 - Cockpit/leftladder.cpp:10 处 GBK 乱码翻译为中文 - 清理头文件注释掉的 #include(19 处)、空 if-else 分支、注释变量声明 ## 编译验证 - [100%] Built target GCS 零错误 - 运行时 timeout 3s 正常退出,无崩溃
155 lines
6.7 KiB
C
155 lines
6.7 KiB
C
/** @file
|
|
* @brief MAVLink comm protocol testsuite generated from minimal.xml
|
|
* @see http://qgroundcontrol.org/mavlink/
|
|
*/
|
|
#pragma once
|
|
#ifndef MINIMAL_TESTSUITE_H
|
|
#define MINIMAL_TESTSUITE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef MAVLINK_TEST_ALL
|
|
#define MAVLINK_TEST_ALL
|
|
|
|
static void mavlink_test_minimal(uint8_t, uint8_t, mavlink_message_t *last_msg);
|
|
|
|
static void mavlink_test_all(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
|
|
{
|
|
|
|
mavlink_test_minimal(system_id, component_id, last_msg);
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void mavlink_test_heartbeat(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
|
|
{
|
|
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
|
|
mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
|
|
if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_HEARTBEAT >= 256) {
|
|
return;
|
|
}
|
|
#endif
|
|
mavlink_message_t msg;
|
|
uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
|
|
uint16_t i;
|
|
mavlink_heartbeat_t packet_in = {
|
|
963497464,17,84,151,218,3
|
|
};
|
|
mavlink_heartbeat_t packet1, packet2;
|
|
memset(&packet1, 0, sizeof(packet1));
|
|
packet1.custom_mode = packet_in.custom_mode;
|
|
packet1.type = packet_in.type;
|
|
packet1.autopilot = packet_in.autopilot;
|
|
packet1.base_mode = packet_in.base_mode;
|
|
packet1.system_status = packet_in.system_status;
|
|
packet1.mavlink_version = packet_in.mavlink_version;
|
|
|
|
|
|
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
|
|
if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
|
|
// cope with extensions
|
|
memset(MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_HEARTBEAT_MIN_LEN);
|
|
}
|
|
#endif
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_heartbeat_encode(system_id, component_id, &msg, &packet1);
|
|
mavlink_msg_heartbeat_decode(&msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_heartbeat_pack(system_id, component_id, &msg , packet1.type , packet1.autopilot , packet1.base_mode , packet1.custom_mode , packet1.system_status );
|
|
mavlink_msg_heartbeat_decode(&msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_heartbeat_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.type , packet1.autopilot , packet1.base_mode , packet1.custom_mode , packet1.system_status );
|
|
mavlink_msg_heartbeat_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_heartbeat_decode(last_msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_heartbeat_send(MAVLINK_COMM_1 , packet1.type , packet1.autopilot , packet1.base_mode , packet1.custom_mode , packet1.system_status );
|
|
mavlink_msg_heartbeat_decode(last_msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
}
|
|
|
|
static void mavlink_test_protocol_version(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
|
|
{
|
|
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
|
|
mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
|
|
if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_PROTOCOL_VERSION >= 256) {
|
|
return;
|
|
}
|
|
#endif
|
|
mavlink_message_t msg;
|
|
uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
|
|
uint16_t i;
|
|
mavlink_protocol_version_t packet_in = {
|
|
17235,17339,17443,{ 151, 152, 153, 154, 155, 156, 157, 158 },{ 175, 176, 177, 178, 179, 180, 181, 182 }
|
|
};
|
|
mavlink_protocol_version_t packet1, packet2;
|
|
memset(&packet1, 0, sizeof(packet1));
|
|
packet1.version = packet_in.version;
|
|
packet1.min_version = packet_in.min_version;
|
|
packet1.max_version = packet_in.max_version;
|
|
|
|
mav_array_memcpy(packet1.spec_version_hash, packet_in.spec_version_hash, sizeof(uint8_t)*8);
|
|
mav_array_memcpy(packet1.library_version_hash, packet_in.library_version_hash, sizeof(uint8_t)*8);
|
|
|
|
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
|
|
if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
|
|
// cope with extensions
|
|
memset(MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN);
|
|
}
|
|
#endif
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_protocol_version_encode(system_id, component_id, &msg, &packet1);
|
|
mavlink_msg_protocol_version_decode(&msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_protocol_version_pack(system_id, component_id, &msg , packet1.version , packet1.min_version , packet1.max_version , packet1.spec_version_hash , packet1.library_version_hash );
|
|
mavlink_msg_protocol_version_decode(&msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_protocol_version_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.version , packet1.min_version , packet1.max_version , packet1.spec_version_hash , packet1.library_version_hash );
|
|
mavlink_msg_protocol_version_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_protocol_version_decode(last_msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
|
|
memset(&packet2, 0, sizeof(packet2));
|
|
mavlink_msg_protocol_version_send(MAVLINK_COMM_1 , packet1.version , packet1.min_version , packet1.max_version , packet1.spec_version_hash , packet1.library_version_hash );
|
|
mavlink_msg_protocol_version_decode(last_msg, &packet2);
|
|
MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
|
|
}
|
|
|
|
static void mavlink_test_minimal(uint16_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
|
|
{
|
|
mavlink_test_heartbeat(system_id, component_id, last_msg);
|
|
mavlink_test_protocol_version(system_id, component_id, last_msg);
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif // __cplusplus
|
|
#endif // MINIMAL_TESTSUITE_H
|