mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-27 10:13:57 -04:00
AP_Baro: move to using CANManager library
This commit is contained in:
parent
0fa6e2bbcc
commit
dc02322017
@ -27,7 +27,7 @@
|
|||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
#include <AP_Math/AP_Math.h>
|
#include <AP_Math/AP_Math.h>
|
||||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||||
#include <AP_BoardConfig/AP_BoardConfig_CAN.h>
|
#include <AP_CANManager/AP_CANManager.h>
|
||||||
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
||||||
|
|
||||||
#include "AP_Baro_SITL.h"
|
#include "AP_Baro_SITL.h"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
#include "AP_Baro_DPS280.h"
|
#include "AP_Baro_DPS280.h"
|
||||||
#include "AP_Baro_BMP388.h"
|
#include "AP_Baro_BMP388.h"
|
||||||
#include "AP_Baro_Dummy.h"
|
#include "AP_Baro_Dummy.h"
|
||||||
#if HAL_WITH_UAVCAN
|
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
|
||||||
#include "AP_Baro_UAVCAN.h"
|
#include "AP_Baro_UAVCAN.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ void AP_Baro::init(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAL_WITH_UAVCAN
|
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
|
||||||
// Detect UAVCAN Modules, try as many times as there are driver slots
|
// Detect UAVCAN Modules, try as many times as there are driver slots
|
||||||
for (uint8_t i = 0; i < BARO_MAX_DRIVERS; i++) {
|
for (uint8_t i = 0; i < BARO_MAX_DRIVERS; i++) {
|
||||||
ADD_BACKEND(AP_Baro_UAVCAN::probe(*this));
|
ADD_BACKEND(AP_Baro_UAVCAN::probe(*this));
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include <AP_HAL/AP_HAL.h>
|
#include <AP_HAL/AP_HAL.h>
|
||||||
|
|
||||||
#if HAL_WITH_UAVCAN
|
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
|
||||||
|
|
||||||
#include "AP_Baro_UAVCAN.h"
|
#include "AP_Baro_UAVCAN.h"
|
||||||
|
|
||||||
#include <AP_BoardConfig/AP_BoardConfig_CAN.h>
|
#include <AP_CANManager/AP_CANManager.h>
|
||||||
#include <AP_UAVCAN/AP_UAVCAN.h>
|
#include <AP_UAVCAN/AP_UAVCAN.h>
|
||||||
|
|
||||||
#include <uavcan/equipment/air_data/StaticPressure.hpp>
|
#include <uavcan/equipment/air_data/StaticPressure.hpp>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
#define debug_baro_uavcan(level_debug, can_driver, fmt, args...) do { if ((level_debug) <= AP::can().get_debug_level_driver(can_driver)) { printf(fmt, ##args); }} while (0)
|
#define LOG_TAG "Baro"
|
||||||
|
|
||||||
//UAVCAN Frontend Registry Binder
|
//UAVCAN Frontend Registry Binder
|
||||||
UC_REGISTRY_BINDER(PressureCb, uavcan::equipment::air_data::StaticPressure);
|
UC_REGISTRY_BINDER(PressureCb, uavcan::equipment::air_data::StaticPressure);
|
||||||
@ -64,11 +64,11 @@ AP_Baro_Backend* AP_Baro_UAVCAN::probe(AP_Baro &baro)
|
|||||||
if (_detected_modules[i].driver == nullptr && _detected_modules[i].ap_uavcan != nullptr) {
|
if (_detected_modules[i].driver == nullptr && _detected_modules[i].ap_uavcan != nullptr) {
|
||||||
backend = new AP_Baro_UAVCAN(baro);
|
backend = new AP_Baro_UAVCAN(baro);
|
||||||
if (backend == nullptr) {
|
if (backend == nullptr) {
|
||||||
debug_baro_uavcan(2,
|
AP::can().log_text(AP_CANManager::LOG_ERROR,
|
||||||
_detected_modules[i].ap_uavcan->get_driver_index(),
|
LOG_TAG,
|
||||||
"Failed register UAVCAN Baro Node %d on Bus %d\n",
|
"Failed register UAVCAN Baro Node %d on Bus %d\n",
|
||||||
_detected_modules[i].node_id,
|
_detected_modules[i].node_id,
|
||||||
_detected_modules[i].ap_uavcan->get_driver_index());
|
_detected_modules[i].ap_uavcan->get_driver_index());
|
||||||
} else {
|
} else {
|
||||||
_detected_modules[i].driver = backend;
|
_detected_modules[i].driver = backend;
|
||||||
backend->_pressure = 0;
|
backend->_pressure = 0;
|
||||||
@ -81,11 +81,11 @@ AP_Baro_Backend* AP_Baro_UAVCAN::probe(AP_Baro &baro)
|
|||||||
_detected_modules[i].ap_uavcan->get_driver_index(),
|
_detected_modules[i].ap_uavcan->get_driver_index(),
|
||||||
backend->_node_id, 0));
|
backend->_node_id, 0));
|
||||||
|
|
||||||
debug_baro_uavcan(2,
|
AP::can().log_text(AP_CANManager::LOG_INFO,
|
||||||
_detected_modules[i].ap_uavcan->get_driver_index(),
|
LOG_TAG,
|
||||||
"Registered UAVCAN Baro Node %d on Bus %d\n",
|
"Registered UAVCAN Baro Node %d on Bus %d\n",
|
||||||
_detected_modules[i].node_id,
|
_detected_modules[i].node_id,
|
||||||
_detected_modules[i].ap_uavcan->get_driver_index());
|
_detected_modules[i].ap_uavcan->get_driver_index());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -194,5 +194,5 @@ void AP_Baro_UAVCAN::update(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAL_WITH_UAVCAN
|
#endif // HAL_ENABLE_LIBUAVCAN_DRIVERS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user