Skip to content

Commit

Permalink
add severity level check to logger and add system module to cyphal build
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Sep 28, 2024
1 parent 9161f42 commit 44bae6d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions Src/applications/cyphal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cmake_path(GET APPLICATIONS_DIR PARENT_PATH SRC_DIR)
add_definitions(-DCONFIG_USE_CYPHAL=1)

include(${SRC_DIR}/modules/cyphal/core/CMakeLists.txt)
include(${SRC_DIR}/modules/system/CMakeLists.txt)
include(${SRC_DIR}/modules/circuit_status/cyphal/CMakeLists.txt)
include(${SRC_DIR}/modules/cyphal/feedback/CMakeLists.txt)
include(${SRC_DIR}/modules/cyphal/setpoint/CMakeLists.txt)
7 changes: 6 additions & 1 deletion Src/common/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "common/logging.hpp"
#include "common/module.hpp"
#include "params.hpp"

#ifndef CONFIG_USE_DRONECAN
#define CONFIG_USE_DRONECAN 0
Expand All @@ -23,7 +24,11 @@
Logging::Logging(const char* source_) : source(source_) {
}

void Logging::log([[maybe_unused]] uint8_t severity, [[maybe_unused]] const char* text) const {
void Logging::log(uint8_t severity, [[maybe_unused]] const char* text) const {
if (severity < paramsGetIntegerValue(PARAM_LOG_LEVEL)) {
return;
}

#if CONFIG_USE_DRONECAN == 1
if (ModuleManager::get_active_protocol() == Module::Protocol::DRONECAN) {
DronecanLogger::log_global(severity, source, text);
Expand Down
5 changes: 5 additions & 0 deletions Src/modules/system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright (C) 2023 Dmitry Ponomarev <[email protected]>
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.

# Include guard
if(SYSTEM_MODULE_DIR)
return()
endif()
set(SYSTEM_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR})

list(APPEND APPLICATION_HEADERS
${CMAKE_CURRENT_LIST_DIR}
Expand Down
2 changes: 0 additions & 2 deletions Src/modules/system/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/

#include "modules/system/main.hpp"
#include <storage.h>
#include "can_driver.h"
#include "common/algorithms.hpp"
#include "common/logging.hpp"
#include "params.hpp"
Expand Down
2 changes: 1 addition & 1 deletion Src/modules/system/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {

class SystemModule : public Module {
public:
SystemModule() : Module(2, Protocol::DRONECAN) {}
SystemModule() : Module(2, Protocol::CYPHAL_AND_DRONECAN) {}
void init() override;

protected:
Expand Down

0 comments on commit 44bae6d

Please sign in to comment.