Skip to content

Commit

Permalink
AP_CANManager: promote KDECAN to a first-class library
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub authored and tridge committed Apr 17, 2023
1 parent c585b02 commit eed3cf3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
8 changes: 2 additions & 6 deletions libraries/AP_CANManager/AP_CANDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions libraries/AP_CANManager/AP_CANManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion libraries/AP_CANManager/AP_CANManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class AP_CANManager
AP_Int8 _driver_type;
AP_CANDriver* _testcan;
AP_CANDriver* _uavcan;
AP_CANDriver* _kdecan;
AP_CANDriver* _piccolocan;
};

Expand Down

0 comments on commit eed3cf3

Please sign in to comment.