Tools: add support for AP_Logger into AP_Periph

This commit is contained in:
Peter Barker 2021-05-20 12:34:15 +10:00 committed by Andrew Tridgell
parent ef2e273ee6
commit 31c345fc4b
6 changed files with 57 additions and 0 deletions

View File

@ -64,6 +64,18 @@ const struct app_descriptor app_descriptor __attribute__((section(".app_descript
const struct app_descriptor app_descriptor;
#endif
AP_Periph_FW::AP_Periph_FW()
#if HAL_LOGGING_ENABLED
: logger(g.log_bitmask)
#endif
{}
#if HAL_LOGGING_ENABLED
const struct LogStructure AP_Periph_FW::log_structure[] = {
LOG_COMMON_STRUCTURES,
};
#endif
void AP_Periph_FW::init()
{
@ -94,6 +106,10 @@ void AP_Periph_FW::init()
AFIO->MAPR = mapr | AFIO_MAPR_CAN_REMAP_REMAP2 | AFIO_MAPR_SPI3_REMAP;
#endif
#if HAL_LOGGING_ENABLED
logger.Init(log_structure, ARRAY_SIZE(log_structure));
#endif
printf("Booting %08x:%08x %u/%u len=%u 0x%08x\n",
app_descriptor.image_crc1,
app_descriptor.image_crc2,
@ -108,6 +124,10 @@ void AP_Periph_FW::init()
#ifdef HAL_PERIPH_ENABLE_GPS
if (gps.get_type(0) != AP_GPS::GPS_Type::GPS_TYPE_NONE && g.gps_port >= 0) {
serial_manager.set_protocol_and_baud(g.gps_port, AP_SerialManager::SerialProtocol_GPS, AP_SERIALMANAGER_GPS_BAUD);
#if HAL_LOGGING_ENABLED
#define MASK_LOG_GPS (1<<2)
gps.set_log_gps_bit(MASK_LOG_GPS);
#endif
gps.init(serial_manager);
}
#endif
@ -343,6 +363,10 @@ void AP_Periph_FW::update()
}
#endif
#if HAL_LOGGING_ENABLED
logger.periodic_tasks();
#endif
can_update();
hal.scheduler->delay(1);
#if (defined(HAL_PERIPH_NEOPIXEL_COUNT_WITHOUT_NOTIFY) && HAL_PERIPH_NEOPIXEL_COUNT_WITHOUT_NOTIFY == 8) || defined(HAL_PERIPH_ENABLE_NOTIFY)

View File

@ -7,6 +7,7 @@
#include <AP_Baro/AP_Baro.h>
#include "SRV_Channel/SRV_Channel.h"
#include <AP_Notify/AP_Notify.h>
#include <AP_Logger/AP_Logger.h>
#include <AP_BattMonitor/AP_BattMonitor.h>
#include <AP_Airspeed/AP_Airspeed.h>
#include <AP_RangeFinder/AP_RangeFinder.h>
@ -48,6 +49,8 @@ extern const struct app_descriptor app_descriptor;
class AP_Periph_FW {
public:
AP_Periph_FW();
void init();
void update();
@ -169,6 +172,11 @@ public:
AP_Notify notify;
#endif
#if HAL_LOGGING_ENABLED
static const struct LogStructure log_structure[];
AP_Logger logger;
#endif
// setup the var_info table
AP_Param param_loader{var_info};

View File

@ -260,6 +260,19 @@ const AP_Param::Info AP_Periph_FW::var_info[] = {
GOBJECT(notify, "NTF_", AP_Notify),
#endif
#if HAL_LOGGING_ENABLED
// @Group: LOG
// @Path: ../libraries/AP_Logger/AP_Logger.cpp
GOBJECT(logger, "LOG", AP_Logger),
// @Param: LOG_BITMASK
// @DisplayName: Log bitmask
// @Description: 4 byte bitmap of log types to enable
// @Bitmask: 2:GPS
// @User: Standard
GSCALAR(log_bitmask, "LOG_BITMASK", 4),
#endif
AP_VAREND
};

View File

@ -38,6 +38,8 @@ public:
k_param_msp_port,
k_param_notify,
k_param_esc_pwm_type,
k_param_logger,
k_param_log_bitmask,
};
AP_Int16 format_version;
@ -91,6 +93,10 @@ public:
AP_Int32 serial_number;
#if HAL_LOGGING_ENABLED
AP_Int32 log_bitmask;
#endif
Parameters() {}
};

View File

@ -40,6 +40,8 @@ def build(bld):
'SRV_Channel',
'AP_Notify',
'AP_SerialLED',
'AP_Logger',
'AP_Filesystem',
],
exclude_src=[
'libraries/AP_HAL_ChibiOS/Storage.cpp'

View File

@ -558,6 +558,10 @@ class sitl_periph_gps(sitl):
APJ_BOARD_ID = 100,
HAL_NO_GCS = 1,
HAL_LOGGING_ENABLED = 0,
HAL_LOGGING_MAVLINK_ENABLED = 0,
HAL_MISSION_ENABLED = 0,
HAL_RALLY_ENABLED = 0,
HAL_SCHEDULER_ENABLED = 0,
)
# libcanard is written for 32bit platforms
env.CXXFLAGS += [