GCS_MAVLink: move AP_KDECAN to a first-class library

This commit is contained in:
Tom Pittenger 2023-03-24 10:34:45 +11:00 committed by Andrew Tridgell
parent 2fcae3c520
commit 5ef4c8dd09

View File

@ -56,6 +56,7 @@
#include <AP_Frsky_Telem/AP_Frsky_Telem.h>
#include <RC_Channel/RC_Channel.h>
#include <AP_VisualOdom/AP_VisualOdom.h>
#include <AP_KDECAN/AP_KDECAN.h>
#include "MissionItemProtocol_Waypoints.h"
#include "MissionItemProtocol_Rally.h"
@ -77,10 +78,6 @@
#include <AP_CANManager/AP_CANTester.h>
#include <AP_Common/AP_Common.h>
// To be replaced with macro saying if KDECAN library is included
#if APM_BUILD_COPTER_OR_HELI || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)
#include <AP_KDECAN/AP_KDECAN.h>
#endif
#include <AP_PiccoloCAN/AP_PiccoloCAN.h>
#include <AP_DroneCAN/AP_DroneCAN.h>
#endif
@ -4355,29 +4352,14 @@ MAV_RESULT GCS_MAVLINK::handle_command_preflight_can(const mavlink_command_long_
return MAV_RESULT_TEMPORARILY_REJECTED;
}
bool start_stop = is_equal(packet.param1,1.0f);
bool result = true;
bool can_exists = false;
uint8_t num_drivers = AP::can().get_num_drivers();
for (uint8_t i = 0; i < num_drivers; i++) {
switch (AP::can().get_driver_type(i)) {
case AP_CANManager::Driver_Type_KDECAN: {
// To be replaced with macro saying if KDECAN library is included
#if APM_BUILD_COPTER_OR_HELI || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)
AP_KDECAN *ap_kdecan = AP_KDECAN::get_kdecan(i);
if (ap_kdecan != nullptr) {
can_exists = true;
result = ap_kdecan->run_enumeration(start_stop) && result;
}
#else
UNUSED_RESULT(start_stop); // prevent unused variable error
#endif
break;
}
case AP_CANManager::Driver_Type_CANTester: {
// To be replaced with macro saying if KDECAN library is included
#if (APM_BUILD_COPTER_OR_HELI || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)) && (HAL_MAX_CAN_PROTOCOL_DRIVERS > 1 && !HAL_MINIMIZE_FEATURES && HAL_ENABLE_CANTESTER)
CANTester *cantester = CANTester::get_cantester(i);
@ -4386,7 +4368,7 @@ MAV_RESULT GCS_MAVLINK::handle_command_preflight_can(const mavlink_command_long_
result = cantester->run_kdecan_enumeration(start_stop) && result;
}
#else
UNUSED_RESULT(start_stop); // prevent unused variable error
(void)can_exists;
#endif
break;
}