diff --git a/libraries/AP_CANManager/AP_CANDriver.cpp b/libraries/AP_CANManager/AP_CANDriver.cpp index 150c66f3c7..9f36f16f5b 100644 --- a/libraries/AP_CANManager/AP_CANDriver.cpp +++ b/libraries/AP_CANManager/AP_CANDriver.cpp @@ -42,12 +42,8 @@ const AP_Param::GroupInfo AP_CANManager::CANDriver_Params::var_info[] = { AP_SUBGROUPPTR(_uavcan, "UC_", 2, AP_CANManager::CANDriver_Params, AP_DroneCAN), #endif -#if (APM_BUILD_COPTER_OR_HELI || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)) - // @Group: KDE_ - // @Path: ../AP_KDECAN/AP_KDECAN.cpp - AP_SUBGROUPPTR(_kdecan, "KDE_", 3, AP_CANManager::CANDriver_Params, AP_KDECAN), -#endif - + // index 3 was KDECAN + #if HAL_NUM_CAN_IFACES > 1 && !HAL_MINIMIZE_FEATURES && HAL_ENABLE_CANTESTER // @Group: TST_ // @Path: ../AP_CANManager/AP_CANTester.cpp diff --git a/libraries/AP_CANManager/AP_CANManager.cpp b/libraries/AP_CANManager/AP_CANManager.cpp index 00aeaa4da8..b896de0e2f 100644 --- a/libraries/AP_CANManager/AP_CANManager.cpp +++ b/libraries/AP_CANManager/AP_CANManager.cpp @@ -216,16 +216,10 @@ void AP_CANManager::init() } else #endif if (drv_type[drv_num] == Driver_Type_KDECAN) { -#if (APM_BUILD_COPTER_OR_HELI || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)) - // To be replaced with macro saying if KDECAN library is included - _drivers[drv_num] = _drv_param[drv_num]._kdecan = new AP_KDECAN; - - if (_drivers[drv_num] == nullptr) { - AP_BoardConfig::allocation_error("KDECAN %d", drv_num + 1); - continue; - } - - AP_Param::load_object_from_eeprom((AP_KDECAN*)_drivers[drv_num], AP_KDECAN::var_info); +#if AP_KDECAN_ENABLED + // cache the driver type so we can detect that it is in the params via get_driver_type(). + // Normally it is cached after init but this driver's init is handled by CANSensor later on + _driver_type_cache[drv_num] = drv_type[drv_num]; #endif } else if (drv_type[drv_num] == Driver_Type_PiccoloCAN) { #if HAL_PICCOLO_CAN_ENABLE diff --git a/libraries/AP_CANManager/AP_CANManager.h b/libraries/AP_CANManager/AP_CANManager.h index 8c35026141..38e5056878 100644 --- a/libraries/AP_CANManager/AP_CANManager.h +++ b/libraries/AP_CANManager/AP_CANManager.h @@ -157,7 +157,6 @@ private: AP_Int8 _driver_type; AP_CANDriver* _testcan; AP_CANDriver* _uavcan; - AP_CANDriver* _kdecan; AP_CANDriver* _piccolocan; };