Browse Source

AP_Baro: move to using CANManager library

zr-v5.1
Siddharth Purohit 5 years ago committed by Andrew Tridgell
parent
commit
dc02322017
  1. 6
      libraries/AP_Baro/AP_Baro.cpp
  2. 28
      libraries/AP_Baro/AP_Baro_UAVCAN.cpp

6
libraries/AP_Baro/AP_Baro.cpp

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.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_Baro_SITL.h"
@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
#include "AP_Baro_DPS280.h"
#include "AP_Baro_BMP388.h"
#include "AP_Baro_Dummy.h"
#if HAL_WITH_UAVCAN
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
#include "AP_Baro_UAVCAN.h"
#endif
@ -510,7 +510,7 @@ void AP_Baro::init(void) @@ -510,7 +510,7 @@ void AP_Baro::init(void)
return;
}
#if HAL_WITH_UAVCAN
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
// Detect UAVCAN Modules, try as many times as there are driver slots
for (uint8_t i = 0; i < BARO_MAX_DRIVERS; i++) {
ADD_BACKEND(AP_Baro_UAVCAN::probe(*this));

28
libraries/AP_Baro/AP_Baro_UAVCAN.cpp

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#include <AP_HAL/AP_HAL.h>
#if HAL_WITH_UAVCAN
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
#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 <uavcan/equipment/air_data/StaticPressure.hpp>
@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
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
UC_REGISTRY_BINDER(PressureCb, uavcan::equipment::air_data::StaticPressure);
@ -64,11 +64,11 @@ AP_Baro_Backend* AP_Baro_UAVCAN::probe(AP_Baro &baro) @@ -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) {
backend = new AP_Baro_UAVCAN(baro);
if (backend == nullptr) {
debug_baro_uavcan(2,
_detected_modules[i].ap_uavcan->get_driver_index(),
"Failed register UAVCAN Baro Node %d on Bus %d\n",
_detected_modules[i].node_id,
_detected_modules[i].ap_uavcan->get_driver_index());
AP::can().log_text(AP_CANManager::LOG_ERROR,
LOG_TAG,
"Failed register UAVCAN Baro Node %d on Bus %d\n",
_detected_modules[i].node_id,
_detected_modules[i].ap_uavcan->get_driver_index());
} else {
_detected_modules[i].driver = backend;
backend->_pressure = 0;
@ -81,11 +81,11 @@ AP_Baro_Backend* AP_Baro_UAVCAN::probe(AP_Baro &baro) @@ -81,11 +81,11 @@ AP_Baro_Backend* AP_Baro_UAVCAN::probe(AP_Baro &baro)
_detected_modules[i].ap_uavcan->get_driver_index(),
backend->_node_id, 0));
debug_baro_uavcan(2,
_detected_modules[i].ap_uavcan->get_driver_index(),
"Registered UAVCAN Baro Node %d on Bus %d\n",
_detected_modules[i].node_id,
_detected_modules[i].ap_uavcan->get_driver_index());
AP::can().log_text(AP_CANManager::LOG_INFO,
LOG_TAG,
"Registered UAVCAN Baro Node %d on Bus %d\n",
_detected_modules[i].node_id,
_detected_modules[i].ap_uavcan->get_driver_index());
}
break;
}
@ -194,5 +194,5 @@ void AP_Baro_UAVCAN::update(void) @@ -194,5 +194,5 @@ void AP_Baro_UAVCAN::update(void)
}
}
#endif // HAL_WITH_UAVCAN
#endif // HAL_ENABLE_LIBUAVCAN_DRIVERS

Loading…
Cancel
Save