From 77055a15795e49492f4eeac58c4b487664d357d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 8 May 2022 18:19:44 +0200 Subject: [PATCH 01/16] first working version with fmt lib --- CMakeLists.txt | 547 ++++++++++++----------- src/fsfw/serviceinterface/CMakeLists.txt | 3 +- src/fsfw/serviceinterface/fmtWrapper.cpp | 24 + src/fsfw/serviceinterface/fmtWrapper.h | 164 +++++++ 4 files changed, 480 insertions(+), 258 deletions(-) create mode 100644 src/fsfw/serviceinterface/fmtWrapper.cpp create mode 100644 src/fsfw/serviceinterface/fmtWrapper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe3da841..75b81a292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,34 +7,40 @@ set(FSFW_REVISION 0) # Add the cmake folder so the FindSphinx module is found set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING - "ETL library major version requirement" -) -set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING - "ETL library exact version requirement" -) +set(FSFW_ETL_LIB_NAME etl) set(FSFW_ETL_LINK_TARGET etl::etl) +set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING + "ETL library major version requirement" + ) +set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING + "ETL library exact version requirement" + ) set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING - "Catch2 library major version requirement" -) + "Catch2 library major version requirement" + ) set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE STRING - "Catch2 library exact version requirement" -) + "Catch2 library exact version requirement" + ) -set(FSFW_ETL_LIB_NAME etl) +set(FSFW_FMT_LIB_NAME fmt) +set(FSFW_FMT_LINK_TARGET fmt::fmt) +set(FSFW_FMT_LIB_MAJOR_VERSION 8 CACHE STRING "{fmt} library major version requirement") +set(FSFW_FMT_LIB_VERSION v${FSFW_FMT_LIB_MAJOR_VERSION}.1.1 CACHE STRING + "{fmt} library exact version requirement" + ) option(FSFW_GENERATE_SECTIONS - "Generate function and data sections. Required to remove unused code" ON -) + "Generate function and data sections. Required to remove unused code" ON + ) if(FSFW_GENERATE_SECTIONS) - option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) + option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_UNITTESTS) - option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) + option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) endif() option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON) @@ -60,84 +66,105 @@ set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) project(${LIB_FSFW_NAME}) -add_library(${LIB_FSFW_NAME}) +add_library(${LIB_FSFW_NAME} src/fsfw/serviceinterface/fmtWrapper.h src/fsfw/serviceinterface/fmtWrapper.cpp) if(FSFW_BUILD_UNITTESTS) - message(STATUS "Building the FSFW unittests in addition to the static library") - # Check whether the user has already installed Catch2 first - find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) - # Not installed, so use FetchContent to download and provide Catch2 - if(NOT Catch2_FOUND) - message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") - include(FetchContent) + message(STATUS "Building the FSFW unittests in addition to the static library") + # Check whether the user has already installed Catch2 first + find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) + # Not installed, so use FetchContent to download and provide Catch2 + if(NOT Catch2_FOUND) + message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") + include(FetchContent) - FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG ${FSFW_CATCH2_LIB_VERSION} - ) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG ${FSFW_CATCH2_LIB_VERSION} + ) - list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) - endif() + list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) + endif() - set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) - configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) - configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) + set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) + configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) + configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) - project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT}) + project(${FSFW_TEST_TGT} CXX C) + add_executable(${FSFW_TEST_TGT}) - if(FSFW_TESTS_GEN_COV) - message(STATUS "Generating coverage data for the library") - message(STATUS "Targets linking against ${LIB_FSFW_NAME} " - "will be compiled with coverage data as well" - ) - include(FetchContent) - FetchContent_Declare( - cmake-modules - GIT_REPOSITORY https://github.com/bilke/cmake-modules.git - ) - FetchContent_MakeAvailable(cmake-modules) - set(CMAKE_BUILD_TYPE "Debug") - list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) - include(CodeCoverage) - endif() + if(FSFW_TESTS_GEN_COV) + message(STATUS "Generating coverage data for the library") + message(STATUS "Targets linking against ${LIB_FSFW_NAME} " + "will be compiled with coverage data as well" + ) + include(FetchContent) + FetchContent_Declare( + cmake-modules + GIT_REPOSITORY https://github.com/bilke/cmake-modules.git + ) + FetchContent_MakeAvailable(cmake-modules) + set(CMAKE_BUILD_TYPE "Debug") + list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) + include(CodeCoverage) + endif() endif() -message(STATUS "Finding and/or providing ETL library") +message(STATUS "Finding and/or providing etl (Embedded Template Library)") # Check whether the user has already installed ETL first find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) # Not installed, so use FetchContent to download and provide etl if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) - message(STATUS - "No ETL installation was found with find_package. Installing and providing " - "etl with FindPackage" + message(STATUS + "No ETL installation was found with find_package. Installing and providing " + "etl with FindPackage" ) - include(FetchContent) + include(FetchContent) - FetchContent_Declare( - ${FSFW_ETL_LIB_NAME} - GIT_REPOSITORY https://github.com/ETLCPP/etl - GIT_TAG ${FSFW_ETL_LIB_VERSION} + FetchContent_Declare( + ${FSFW_ETL_LIB_NAME} + GIT_REPOSITORY https://github.com/ETLCPP/etl + GIT_TAG ${FSFW_ETL_LIB_VERSION} + ) + + list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) +endif() + +message(STATUS "Finding and/or providing {fmt} formatting library") + +# Check whether the user has already installed ETL first +find_package(fmt ${FSFW_FMT_LIB_MAJOR_VERSION} QUIET) +# Not installed, so use FetchContent to download and provide etl +if(NOT ${FSFW_FMT_LIB_NAME}_FOUND) + message(STATUS + "No {fmt} installation was found with find_package. Installing and providing " + "{fmt} with FindPackage" ) + include(FetchContent) - list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) + FetchContent_Declare( + ${FSFW_FMT_LIB_NAME} + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG ${FSFW_FMT_LIB_VERSION} + ) + + list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_FMT_LIB_NAME}) endif() # The documentation for FetchContent recommends declaring all the dependencies # before making them available. We make all declared dependency available here # after their declaration if(FSFW_FETCH_CONTENT_TARGETS) - FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS}) - if(TARGET ${FSFW_ETL_LIB_NAME}) - add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) - endif() - if(TARGET Catch2) - # Fixes regression -preview4, to be confirmed in later releases - # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 - set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") - endif() + FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS}) + if(TARGET ${FSFW_ETL_LIB_NAME}) + add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) + endif() + if(TARGET Catch2) + # Fixes regression -preview4, to be confirmed in later releases + # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 + set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") + endif() endif() set(FSFW_CORE_INC_PATH "inc") @@ -146,64 +173,64 @@ set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) # For configure files target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} -) + ${CMAKE_CURRENT_BINARY_DIR} + ) target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} -) + ${CMAKE_CURRENT_BINARY_DIR} + ) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED True) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED True) elseif(${CMAKE_CXX_STANDARD} LESS 11) - message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support") + message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support") endif() # Backwards comptability if(OS_FSFW AND NOT FSFW_OSAL) - message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") - set(FSFW_OSAL OS_FSFW) + message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") + set(FSFW_OSAL OS_FSFW) endif() if(NOT FSFW_OSAL) - message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") - # Assume host OS and autodetermine from OS_FSFW - if(UNIX) - set(FSFW_OSAL "linux" - CACHE STRING - "OS abstraction layer used in the FSFW" - ) - elseif(WIN32) - set(FSFW_OSAL "host" - CACHE STRING "OS abstraction layer used in the FSFW" - ) - endif() + message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") + # Assume host OS and autodetermine from OS_FSFW + if(UNIX) + set(FSFW_OSAL "linux" + CACHE STRING + "OS abstraction layer used in the FSFW" + ) + elseif(WIN32) + set(FSFW_OSAL "host" + CACHE STRING "OS abstraction layer used in the FSFW" + ) + endif() endif() set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST) if(FSFW_OSAL MATCHES host) - set(FSFW_OS_NAME "Host") - set(FSFW_OSAL_HOST ON) + set(FSFW_OS_NAME "Host") + set(FSFW_OSAL_HOST ON) elseif(FSFW_OSAL MATCHES linux) - set(FSFW_OS_NAME "Linux") - set(FSFW_OSAL_LINUX ON) + set(FSFW_OS_NAME "Linux") + set(FSFW_OSAL_LINUX ON) elseif(FSFW_OSAL MATCHES freertos) - set(FSFW_OS_NAME "FreeRTOS") - set(FSFW_OSAL_FREERTOS ON) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_OS_NAME} + set(FSFW_OS_NAME "FreeRTOS") + set(FSFW_OSAL_FREERTOS ON) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE + ${LIB_OS_NAME} ) elseif(FSFW_OSAL STREQUAL rtems) - set(FSFW_OS_NAME "RTEMS") - set(FSFW_OSAL_RTEMS ON) + set(FSFW_OS_NAME "RTEMS") + set(FSFW_OSAL_RTEMS ON) else() - message(WARNING - "Invalid operating system for FSFW specified! Setting to host.." + message(WARNING + "Invalid operating system for FSFW specified! Setting to host.." ) - set(FSFW_OS_NAME "Host") - set(OS_FSFW "host") + set(FSFW_OS_NAME "Host") + set(OS_FSFW "host") endif() configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) @@ -214,206 +241,212 @@ message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.") add_subdirectory(src) add_subdirectory(tests) if(FSFW_ADD_HAL) - add_subdirectory(hal) + add_subdirectory(hal) endif() add_subdirectory(contrib) if(FSFW_BUILD_DOCS) - add_subdirectory(docs) + add_subdirectory(docs) endif() if(FSFW_BUILD_UNITTESTS) - if(FSFW_TESTS_GEN_COV) - if(CMAKE_COMPILER_IS_GNUCXX) - include(CodeCoverage) + if(FSFW_TESTS_GEN_COV) + if(CMAKE_COMPILER_IS_GNUCXX) + include(CodeCoverage) - # Remove quotes. - separate_arguments(COVERAGE_COMPILER_FLAGS - NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" - ) + # Remove quotes. + separate_arguments(COVERAGE_COMPILER_FLAGS + NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" + ) - # Add compile options manually, we don't want coverage for Catch2 - target_compile_options(${FSFW_TEST_TGT} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) - target_compile_options(${LIB_FSFW_NAME} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) + # Add compile options manually, we don't want coverage for Catch2 + target_compile_options(${FSFW_TEST_TGT} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) + target_compile_options(${LIB_FSFW_NAME} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) - # Exclude directories here - if(WIN32) - set(GCOVR_ADDITIONAL_ARGS - "--exclude-throw-branches" - "--exclude-unreachable-branches" - ) - set(COVERAGE_EXCLUDES - "/c/msys64/mingw64/*" "*/fsfw_hal/*" - ) - elseif(UNIX) - set(COVERAGE_EXCLUDES - "/usr/include/*" "/usr/bin/*" "Catch2/*" - "/usr/local/include/*" "*/fsfw_tests/*" - "*/catch2-src/*" "*/fsfw_hal/*" - ) - endif() + # Exclude directories here + if(WIN32) + set(GCOVR_ADDITIONAL_ARGS + "--exclude-throw-branches" + "--exclude-unreachable-branches" + ) + set(COVERAGE_EXCLUDES + "/c/msys64/mingw64/*" "*/fsfw_hal/*" + ) + elseif(UNIX) + set(COVERAGE_EXCLUDES + "/usr/include/*" "/usr/bin/*" "Catch2/*" + "/usr/local/include/*" "*/fsfw_tests/*" + "*/catch2-src/*" "*/fsfw_hal/*" + ) + endif() - target_link_options(${FSFW_TEST_TGT} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - target_link_options(${LIB_FSFW_NAME} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - # Need to specify this as an interface, otherwise there will the compile issues - target_link_options(${LIB_FSFW_NAME} INTERFACE - -fprofile-arcs - -ftest-coverage - ) + target_link_options(${FSFW_TEST_TGT} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + target_link_options(${LIB_FSFW_NAME} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + # Need to specify this as an interface, otherwise there will the compile issues + target_link_options(${LIB_FSFW_NAME} INTERFACE + -fprofile-arcs + -ftest-coverage + ) - if(WIN32) - setup_target_for_coverage_gcovr_html( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) - else() - setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) - endif() - endif() + if(WIN32) + setup_target_for_coverage_gcovr_html( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + else() + setup_target_for_coverage_lcov( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + endif() endif() - target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) + endif() + target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) endif() # The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. # If this is not given, we include the default configuration and emit a warning. if(NOT FSFW_CONFIG_PATH) - set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) - if(NOT FSFW_BUILD_DOCS) - message(WARNING "Flight Software Framework configuration path not set!") - message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..") - endif() - add_subdirectory(${DEF_CONF_PATH}) - set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) + set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) + if(NOT FSFW_BUILD_DOCS) + message(WARNING "Flight Software Framework configuration path not set!") + message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..") + endif() + add_subdirectory(${DEF_CONF_PATH}) + set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) endif() -# FSFW might be part of a possibly complicated folder structure, so we +# FSFW might be part of a possibly complicated folder structure, so we # extract the absolute path of the fsfwconfig folder. if(IS_ABSOLUTE ${FSFW_CONFIG_PATH}) - set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) + set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) else() - get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE - ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} - ) + get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE + ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} + ) endif() foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS}) - if(IS_ABSOLUTE ${INCLUDE_PATH}) - set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") - else() - get_filename_component(CURR_ABS_INC_PATH - ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) - endif() + if(IS_ABSOLUTE ${INCLUDE_PATH}) + set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") + else() + get_filename_component(CURR_ABS_INC_PATH + ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) + endif() - if(CMAKE_VERBOSE) - message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") - endif() + if(CMAKE_VERBOSE) + message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") + endif() - list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) + list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) endforeach() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(NOT DEFINED FSFW_WARNING_FLAGS) - set(FSFW_WARNING_FLAGS - -Wall - -Wextra - -Wimplicit-fallthrough=1 - -Wno-unused-parameter - -Wno-psabi - -Wduplicated-cond # check for duplicate conditions - -Wduplicated-branches # check for duplicate branches - -Wlogical-op # Search for bitwise operations instead of logical - -Wnull-dereference # Search for NULL dereference - -Wundef # Warn if undefind marcos are used - -Wformat=2 # Format string problem detection - -Wformat-overflow=2 # Formatting issues in printf - -Wformat-truncation=2 # Formatting issues in printf - -Wformat-security # Search for dangerous printf operations - -Wstrict-overflow=3 # Warn if integer overflows might happen - -Warray-bounds=2 # Some array bounds violations will be found - -Wshift-overflow=2 # Search for bit left shift overflows ( sif::PRINT_BUF = {}; +MutexIF* sif::PRINT_MUTEX = nullptr; + +const char* sif::PREFIX_ARR[4]= {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX}; + +ReturnValue_t sif::initialize() { + sif::PRINT_MUTEX = MutexFactory::instance()->createMutex(); + if(sif::PRINT_MUTEX == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +size_t sif::writeTypePrefix(LogLevel level) { + auto idx = static_cast(level); + const auto result = + fmt::format_to_n(PRINT_BUF.begin(), PRINT_BUF.size() - 1, + fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx]))); + return result.size; +} \ No newline at end of file diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h new file mode 100644 index 000000000..9b957512f --- /dev/null +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -0,0 +1,164 @@ +#pragma once + +#include +#include +#include +#include + +#include +#include + +#include "fsfw/ipc/MutexGuard.h" +#include "fsfw/ipc/MutexIF.h" +#include "fsfw/timemanager/Clock.h" + +// Takes from stackoverflow to display relative paths: +// https://stackoverflow.com/questions/8487986/file-macro-shows-full-path +#ifdef FSFW_SOURCE_PATH_SIZE +#define __FILENAME_REL__ (((const char*)__FILE__ + SOURCE_PATH_SIZE)) +#endif + +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +namespace sif { + +extern std::array PRINT_BUF; +extern MutexIF* PRINT_MUTEX; + +static const char INFO_PREFIX[] = "INFO"; +static const char DEBUG_PREFIX[] = "DEBUG"; +static const char WARNING_PREFIX[] = "WARNING"; +static const char ERROR_PREFIX[] = "ERROR"; + +enum class LogLevel : unsigned int { DEBUG = 0, INFO = 1, WARNING = 2, ERROR = 3 }; + +extern const char* PREFIX_ARR[4]; + +static const std::array LOG_COLOR_ARR = { + fmt::color::deep_sky_blue, fmt::color::forest_green, fmt::color::orange_red, fmt::color::red}; + +ReturnValue_t initialize(); + +size_t writeTypePrefix(LogLevel level); + +template +size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed, + fmt::format_string fmt, T&&... args) noexcept { + if(PRINT_MUTEX == nullptr) { + fmt::print("Please call sif::initialize at program startup\n"); + return 0; + } + try { + MutexGuard mg(PRINT_MUTEX); + size_t bufPos = writeTypePrefix(level); + auto currentIter = PRINT_BUF.begin() + bufPos; + if (timed) { + Clock::TimeOfDay_t logTime; + Clock::getDateAndTime(&logTime); + const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, + " | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file, line, + logTime.hour, logTime.minute, logTime.second, + logTime.usecond / 1000, fmt::format(fmt, args...)); + bufPos += result.size; + } else { + const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, + " | {}[l.{}] | {}", file, line, fmt::format(fmt, args...)); + bufPos += result.size; + } + PRINT_BUF[bufPos] = '\0'; + fmt::print(fmt::runtime(PRINT_BUF.data())); + return bufPos; + } catch (const fmt::v8::format_error& e) { + fmt::print("Printing failed with error: {}\n", e.what()); + return 0; + } +} + +template +size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args) noexcept { + if(PRINT_MUTEX == nullptr) { + fmt::print("Please call sif::initialize at program startup\n"); + return 0; + } + try { + MutexGuard mg(PRINT_MUTEX); + size_t bufPos = writeTypePrefix(level); + auto currentIter = PRINT_BUF.begin() + bufPos; + if (timed) { + Clock::TimeOfDay_t logTime; + Clock::getDateAndTime(&logTime); + const auto result = fmt::format_to_n( + currentIter, PRINT_BUF.size() - bufPos, " | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour, + logTime.minute, logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...)); + bufPos += result.size; + } else { + const auto result = fmt::format_to_n( + currentIter, PRINT_BUF.size() - bufPos, " | {}", fmt::format(fmt, args...)); + bufPos += result.size; + } + PRINT_BUF[bufPos] = '\0'; + fmt::print(fmt::runtime(PRINT_BUF.data())); + return bufPos; + } catch (const fmt::v8::format_error& e) { + fmt::print("Printing failed with error: {}\n", e.what()); + return 0; + } +} + +template +void fdebug(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) noexcept { + logTraced(LogLevel::DEBUG, file, line, false, fmt, args...); +} + +template +void fdebug_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) noexcept { + logTraced(LogLevel::DEBUG, file, line, true, fmt, args...); +} + +template +void finfo_t(fmt::format_string fmt, T&&... args) { + log(LogLevel::INFO, true, fmt, args...); +} + +template +void finfo(fmt::format_string fmt, T&&... args) { + log(LogLevel::INFO, false, fmt, args...); +} + +template +void fwarning(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { + logTraced(LogLevel::WARNING, file, line, false, fmt, args...); +} + +template +void fwarning_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { + logTraced(LogLevel::WARNING, file, line, true, fmt, args...); +} + +template +void ferror(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { + logTraced(LogLevel::ERROR, file, line, false, fmt, args...); +} + +template +void ferror_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { + logTraced(LogLevel::ERROR, file, line, true, fmt, args...); +} + +} // namespace sif + +#define FSFW_LOGI(format, ...) finfo(FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGD(format, ...) sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGDT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGW(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGWT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGET(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -- 2.34.1 From 1b34b90ae0e5e53df5af6db04b7d41f35300cef0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 8 May 2022 21:45:51 +0200 Subject: [PATCH 02/16] init changing all printout types --- CMakeLists.txt | 2 +- hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp | 100 +++------ hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 114 +++------- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 150 ++++--------- hal/src/fsfw_hal/linux/uart/UartComIF.h | 2 +- hal/src/fsfw_hal/linux/uart/UartCookie.h | 2 +- src/fsfw/action/ActionHelper.cpp | 25 +-- src/fsfw/cfdp/CFDPHandler.cpp | 9 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 14 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 8 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 14 +- src/fsfw/datapool/PoolDataSetBase.cpp | 30 +-- src/fsfw/datapool/PoolEntry.cpp | 10 +- src/fsfw/datapool/PoolReadGuard.h | 13 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 10 +- .../datapoollocal/LocalDataPoolManager.cpp | 6 +- .../datapoollocal/LocalPoolDataSetBase.cpp | 20 +- .../datapoollocal/LocalPoolObjectBase.cpp | 47 +---- src/fsfw/datapoollocal/LocalPoolVector.tpp | 16 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 54 ++--- src/fsfw/devicehandlers/DeviceHandlerBase.h | 3 +- .../DeviceHandlerFailureIsolation.cpp | 11 +- src/fsfw/events/EventManagerIF.h | 16 +- src/fsfw/fdir/FailureIsolationBase.cpp | 30 +-- src/fsfw/globalfunctions/arrayprinter.cpp | 199 ++++++++---------- src/fsfw/health/HealthHelper.cpp | 23 +- src/fsfw/health/HealthTable.cpp | 9 +- src/fsfw/ipc/MessageQueueMessage.cpp | 8 +- src/fsfw/ipc/MutexGuard.h | 34 +-- src/fsfw/memory/MemoryHelper.cpp | 6 +- .../monitoring/MonitoringMessageContent.h | 6 +- src/fsfw/objectmanager/ObjectManager.cpp | 62 ++---- src/fsfw/objectmanager/SystemObject.h | 3 +- src/fsfw/osal/common/UdpTcPollingTask.cpp | 2 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 4 +- src/fsfw/osal/common/UdpTmTcBridge.h | 4 +- src/fsfw/osal/linux/tcpipHelpers.cpp | 10 +- src/fsfw/parameters/ParameterHelper.cpp | 8 +- src/fsfw/parameters/ParameterWrapper.cpp | 34 +-- src/fsfw/serialize/SerialBufferAdapter.cpp | 14 +- src/fsfw/serviceinterface.h | 3 +- .../serviceinterface/ServiceInterfaceStream.h | 8 +- src/fsfw/serviceinterface/fmtWrapper.cpp | 4 +- src/fsfw/serviceinterface/fmtWrapper.h | 88 +++++--- .../storagemanager/ConstStorageAccessor.cpp | 10 +- src/fsfw/storagemanager/LocalPool.cpp | 25 +-- src/fsfw/storagemanager/StorageAccessor.cpp | 6 +- src/fsfw/tasks/FixedSlotSequence.cpp | 26 +-- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 14 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 7 +- src/fsfw/tcdistribution/TcDistributor.cpp | 10 +- src/fsfw/timemanager/Stopwatch.cpp | 20 +- src/fsfw/tmtcpacket/SpacePacketBase.cpp | 10 +- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 8 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 28 +-- 55 files changed, 434 insertions(+), 965 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75b81a292..61c145ded 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,7 +442,7 @@ string(CONCAT POST_BUILD_COMMENT # The additional / is important to remove the last character from the path. # Note that it does not matter if the OS uses / or \, because we are only # saving the path size. -string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE) +string(LENGTH "${CMAKE_SOURCE_DIR}/" FSFW_SOURCE_PATH_SIZE) target_compile_definitions(${LIB_FSFW_NAME} PRIVATE "-DFSFW_SOURCE_PATH_SIZE=${FSFW_SOURCE_PATH_SIZE}") add_custom_command( diff --git a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 4f53dc1f7..a509dad1e 100644 --- a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -26,19 +26,10 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; if (cookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::initializeInterface: Invalid cookie!" << std::endl; -#endif + FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n"); return NULLPOINTER; } - I2cCookie* i2cCookie = dynamic_cast(cookie); - if (i2cCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::initializeInterface: Invalid I2C cookie!" << std::endl; -#endif - return NULLPOINTER; - } - + auto* i2cCookie = dynamic_cast(cookie); i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); @@ -47,20 +38,14 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance); if (not statusPair.second) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::initializeInterface: Failed to insert device with address " - << i2cAddress << "to I2C device " - << "map" << std::endl; -#endif + FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress - << "already in use" << std::endl; -#endif + FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } @@ -70,9 +55,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s std::string deviceFile; if (sendData == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl; -#endif + FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -80,21 +63,16 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s return HasReturnvaluesIF::RETURN_OK; } - I2cCookie* i2cCookie = dynamic_cast(cookie); + auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::sendMessage: Invalid I2C Cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " - << "registered in i2cDeviceMap" << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -109,11 +87,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (write(fd, sendData, sendLen) != static_cast(sendLen)) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::sendMessage: Failed to send data to I2C " - "device with error code " - << errno << ". Error description: " << strerror(errno) << std::endl; -#endif + FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } @@ -135,11 +110,9 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe return HasReturnvaluesIF::RETURN_OK; } - I2cCookie* i2cCookie = dynamic_cast(cookie); + auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n"); i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } @@ -147,10 +120,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not " - << "registered in i2cDeviceMap" << std::endl; -#endif + FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap", + i2cAddress); i2cDeviceMapIter->second.replyLen = 0; return HasReturnvaluesIF::RETURN_FAILED; } @@ -168,20 +139,13 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data(); - int readLen = read(fd, replyBuffer, requestLen); + ssize_t readLen = read(fd, replyBuffer, requestLen); if (readLen != static_cast(requestLen)) { -#if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C " - << "device failed with error code " << errno << ". Description" - << " of error: " << strerror(errno) << std::endl; - sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen - << " bytes" << std::endl; -#endif + FSFW_LOGWT( + "requestReceiveMessage: Reading from I2C device failed with error code " + "{} | {}\nRead only {} from {} bytes\n", + errno, strerror(errno), readLen, requestLen); i2cDeviceMapIter->second.replyLen = 0; -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen - << " bytes" << std::endl; -#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -195,21 +159,17 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { - I2cCookie* i2cCookie = dynamic_cast(cookie); + auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::readReceivedMessage: Invalid I2C Cookie!" << std::endl; -#endif + FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " - << "found in i2cDeviceMap" << std::endl; -#endif + FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); @@ -221,16 +181,8 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, int* fileDescriptor) { if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "I2cComIF: Specifying target device failed with error code " << errno << "." - << std::endl; - sif::warning << "Error description " << strerror(errno) << std::endl; -#else - sif::printWarning("I2cComIF: Specifying target device failed with error code %d.\n"); - sif::printWarning("Error description: %s\n", strerror(errno)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index dcf92b5d9..e98b9de8b 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -11,6 +11,7 @@ #include #include "fsfw/FSFW.h" +#include "fsfw/serviceinterface.h" #include "fsfw_hal/linux/UnixFileGuard.h" #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/utility.h" @@ -18,13 +19,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SystemObject(objectId), gpioComIF(gpioComIF) { if (gpioComIF == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::SpiComIF: GPIO communication interface invalid!" << std::endl; -#else - sif::printError("SpiComIF::SpiComIF: GPIO communication interface invalid!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n"); } spiMutex = MutexFactory::instance()->createMutex(); @@ -32,7 +27,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF) ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { int retval = 0; - SpiCookie* spiCookie = dynamic_cast(cookie); + auto* spiCookie = dynamic_cast(cookie); if (spiCookie == nullptr) { return NULLPOINTER; } @@ -45,30 +40,17 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { SpiInstance spiInstance(bufferSize); auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance); if (not statusPair.second) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::initializeInterface: Failed to insert device with address " - << spiAddress << "to SPI device map" << std::endl; -#else - sif::printError( - "SpiComIF::initializeInterface: Failed to insert device with address " - "%lu to SPI device map\n", - static_cast(spiAddress)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT( + "SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device " + "map\n", + spiAddress); return HasReturnvaluesIF::RETURN_FAILED; } /* Now we emplaced the read buffer in the map, we still need to assign that location to the SPI driver transfer struct */ spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data()); } else { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::initializeInterface: SPI address already exists!" << std::endl; -#else - sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -133,7 +115,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { } ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { - SpiCookie* spiCookie = dynamic_cast(cookie); + auto* spiCookie = dynamic_cast(cookie); ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; if (spiCookie == nullptr) { @@ -141,19 +123,9 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (sendLen > spiCookie->getMaxBufferSize()) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpiComIF::sendMessage: Too much data sent, send length " << sendLen - << "larger than maximum buffer length " << spiCookie->getMaxBufferSize() - << std::endl; -#else - sif::printWarning( - "SpiComIF::sendMessage: Too much data sent, send length %lu larger " - "than maximum buffer length %lu!\n", - static_cast(sendLen), - static_cast(spiCookie->getMaxBufferSize())); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW( + "sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n", + spiCookie->getMaxBufferSize(), sendLen); return DeviceCommunicationIF::TOO_MUCH_DATA; } @@ -201,24 +173,12 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; -#else - sif::printError("SpiComIF::sendMessage: Failed to lock mutex\n"); -#endif -#endif + FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n"); return result; } - ReturnValue_t result = gpioComIF->pullLow(gpioId); + result = gpioComIF->pullLow(gpioId); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl; -#else - sif::printWarning("SpiComIF::sendMessage: Pulling low CS pin failed"); -#endif -#endif + FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n"); return result; } } @@ -237,13 +197,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const } else { /* We write with a blocking half-duplex transfer here */ if (write(fileDescriptor, sendData, sendLen) != static_cast(sendLen)) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpiComIF::sendMessage: Half-Duplex write operation failed!" << std::endl; -#else - sif::printWarning("SpiComIF::sendMessage: Half-Duplex write operation failed!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } } @@ -252,9 +206,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n"); return result; } } @@ -264,7 +216,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { - SpiCookie* spiCookie = dynamic_cast(cookie); + auto* spiCookie = dynamic_cast(cookie); if (spiCookie == nullptr) { return NULLPOINTER; } @@ -296,22 +248,14 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl; -#endif + FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n"); return result; } gpioComIF->pullLow(gpioId); } if (read(fileDescriptor, rxBuf, readSize) != static_cast(readSize)) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpiComIF::sendMessage: Half-Duplex read operation failed!" << std::endl; -#else - sif::printWarning("SpiComIF::sendMessage: Half-Duplex read operation failed!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } @@ -319,9 +263,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl; -#endif + FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n"); return result; } } @@ -330,7 +272,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { } ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { - SpiCookie* spiCookie = dynamic_cast(cookie); + auto* spiCookie = dynamic_cast(cookie); if (spiCookie == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } @@ -361,16 +303,10 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) { return; } size_t dataLen = spiCookie->getTransferStructHandle()->len; - uint8_t* dataPtr = reinterpret_cast(spiCookie->getTransferStructHandle()->tx_buf); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Sent SPI data: " << std::endl; + auto* dataPtr = reinterpret_cast(spiCookie->getTransferStructHandle()->tx_buf); + sif::info("Sent SPI data:\n"); arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false); - sif::info << "Received SPI data: " << std::endl; -#else - sif::printInfo("Sent SPI data: \n"); - arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false); - sif::printInfo("Received SPI data: \n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + sif::info("Received SPI data:\n"); dataPtr = reinterpret_cast(spiCookie->getTransferStructHandle()->rx_buf); arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false); } diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 72c79df65..6f042efaf 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -1,10 +1,10 @@ #include "UartComIF.h" -#include #include #include #include +#include #include #include "fsfw/FSFW.h" @@ -23,11 +23,9 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { return NULLPOINTER; } - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl; -#endif + FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -42,18 +40,12 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { size_t maxReplyLen = uartCookie->getMaxReplyLen(); UartElements uartElements = {fileDescriptor, std::vector(maxReplyLen), 0}; auto status = uartDeviceMap.emplace(deviceFile, uartElements); - if (status.second == false) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile - << "to UART device map" << std::endl; -#endif + if (!status.second) { + FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile); return RETURN_FAILED; } } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile - << " already in use" << std::endl; -#endif + FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile); return RETURN_FAILED; } @@ -73,19 +65,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { int fd = open(deviceFile.c_str(), flags); if (fd < 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile - << "with error code " << errno << strerror(errno) << std::endl; -#endif + FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile, + errno, strerror(errno)); return fd; } /* Read in existing settings */ if (tcgetattr(fd, &options) != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureUartPort: Error " << errno - << "from tcgetattr: " << strerror(errno) << std::endl; -#endif + FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno)); return fd; } @@ -106,10 +93,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { /* Save option settings */ if (tcsetattr(fd, TCSANOW, &options) != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureUartPort: Failed to set options with error " << errno - << ": " << strerror(errno); -#endif + FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno, + strerror(errno)); return fd; } return fd; @@ -161,9 +146,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook options->c_cflag |= CS8; break; default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::setDatasizeOptions: Invalid size specified" << std::endl; -#endif + FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n", + static_cast(uartCookie->getBitsPerWord())); break; } } @@ -314,11 +298,9 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki cfsetispeed(options, B4000000); cfsetospeed(options, B4000000); break; -#endif // ! __APPLE__ +#endif // ! __APPLE__ default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl; -#endif + FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n"); break; } } @@ -333,37 +315,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, } if (sendData == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: Send data is nullptr"); return RETURN_FAILED; } - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" - << std::endl; -#endif + FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } fd = uartDeviceMapIter->second.fileDescriptor; if (write(fd, sendData, sendLen) != static_cast(sendLen)) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno - << ": Error description: " << strerror(errno) << std::endl; -#endif + FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno)); return RETURN_FAILED; } @@ -376,11 +348,9 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL std::string deviceFile; UartDeviceMapIter uartDeviceMapIter; - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -393,10 +363,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } if (uartDeviceMapIter == uartDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile - << " not in uart map" << std::endl; -#endif + FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -414,7 +381,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t currentReadCycles = 0; - int bytesRead = 0; + ssize_t bytesRead = 0; size_t currentBytesRead = 0; size_t maxReplySize = uartCookie.getMaxReplyLen(); int fd = iter->second.fileDescriptor; @@ -425,16 +392,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (currentBytesRead >= maxReplySize) { // Overflow risk. Emit warning, trigger event and break. If this happens, // the reception buffer is not large enough or data is not polled often enough. -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!" - << std::endl; -#else - sif::printWarning( - "UartComIF::requestReceiveMessage: " - "Next read would cause overflow!"); -#endif -#endif + FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n"); result = UART_RX_BUFFER_TOO_SMALL; break; } else { @@ -445,15 +403,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (bytesRead < 0) { // EAGAIN: No data available in non-blocking mode if (errno != EAGAIN) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::handleCanonicalRead: read failed with code" << errno << ": " - << strerror(errno) << std::endl; -#else - sif::printWarning("UartComIF::handleCanonicalRead: read failed with code %d: %s\n", errno, - strerror(errno)); -#endif -#endif + FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno)); return RETURN_FAILED; } @@ -473,27 +423,16 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow if (requestLen > uartCookie.getMaxReplyLen()) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!" - << std::endl; -#else - sif::printWarning( - "UartComIF::requestReceiveMessage: " - "Next read would cause overflow!"); -#endif -#endif + FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n"); return UART_RX_BUFFER_TOO_SMALL; } - int bytesRead = read(fd, bufferPtr, requestLen); + ssize_t bytesRead = read(fd, bufferPtr, requestLen); if (bytesRead < 0) { return RETURN_FAILED; } else if (bytesRead != static_cast(requestLen)) { if (uartCookie.isReplySizeFixed()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of " - << requestLen << " bytes" << std::endl; -#endif + FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead, + requestLen); return RETURN_FAILED; } } @@ -505,21 +444,16 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, std::string deviceFile; UartDeviceMapIter uartDeviceMapIter; - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" - << std::endl; -#endif + FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -535,11 +469,9 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; UartDeviceMapIter uartDeviceMapIter; - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -555,11 +487,9 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; UartDeviceMapIter uartDeviceMapIter; - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -575,11 +505,9 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; UartDeviceMapIter uartDeviceMapIter; - UartCookie* uartCookie = dynamic_cast(cookie); + auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl; -#endif + FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.h b/hal/src/fsfw_hal/linux/uart/UartComIF.h index 224f1e774..e20fc19f9 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.h +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.h @@ -90,7 +90,7 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { * parity settings. * */ - void setParityOptions(struct termios* options, UartCookie* uartCookie); + static void setParityOptions(struct termios* options, UartCookie* uartCookie); void setStopBitOptions(struct termios* options, UartCookie* uartCookie); diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.h b/hal/src/fsfw_hal/linux/uart/UartCookie.h index 6840b3521..f1d7fa36d 100644 --- a/hal/src/fsfw_hal/linux/uart/UartCookie.h +++ b/hal/src/fsfw_hal/linux/uart/UartCookie.h @@ -12,7 +12,7 @@ enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS }; enum class UartModes { CANONICAL, NON_CANONICAL }; -enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 }; +enum class BitsPerWord : unsigned int { BITS_5 = 5, BITS_6 = 6, BITS_7 = 7, BITS_8 = 8 }; enum class UartBaudRate { RATE_50, diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index d41c78b4b..13cc6fdc4 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -1,7 +1,7 @@ #include "fsfw/action.h" #include "fsfw/ipc/MessageQueueSenderIF.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : owner(setOwner), queueToUse(useThisQueue) {} @@ -28,13 +28,7 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { } if (queueToUse == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ActionHelper::initialize: No queue set" << std::endl; -#else - sif::printWarning("ActionHelper::initialize: No queue set\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "initialize: No queue set\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -96,14 +90,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!" - << std::endl; -#else - sif::printWarning( - "ActionHelper::reportData: Getting free element from IPC " - "store failed!\n"); -#endif + FSFW_LOGWT("{}", "reportData: Getting free element from IPC store failed\n"); return result; } result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); @@ -138,11 +125,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl; -#else - sif::printWarning("ActionHelper::reportData: Adding data to IPC store failed!\n"); -#endif + FSFW_LOGWT("{}", "reportData: Adding data to IPC store failed\n"); return result; } diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp index 96baa98c7..7c23c1334 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CFDPHandler.cpp @@ -4,6 +4,7 @@ #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/storeAddress.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" @@ -28,13 +29,7 @@ ReturnValue_t CFDPHandler::initialize() { } ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPHandler::handleRequest" << std::endl; -#else - sif::printDebug("CFDPHandler::handleRequest\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif + FSFW_LOGDT("{}", "CFDPHandler::handleRequest\n"); // TODO read out packet from store using storeId diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index e1ab8dc98..3e77f2211 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -50,17 +50,9 @@ ReturnValue_t EofPduDeserializer::parseData() { if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { EntityIdTlv* tlvPtr = info.getFaultLoc(); if (tlvPtr == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "EofPduDeserializer::parseData: Ca not deserialize fault location," - " given TLV pointer invalid" - << std::endl; -#else - sif::printWarning( - "EofPduDeserializer::parseData: Ca not deserialize fault location," - " given TLV pointer invalid"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", + "parseData: Ca not deserialize fault location," + " given TLV pointer invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness); diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index b11c3b09b..24b04b4a9 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -7,13 +7,7 @@ cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_DISABLE_PRINTOUT == 0 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl; -#else - sif::printWarning("cfdp::VarLenField: Setting value failed\n"); -#endif -#endif + FSFW_LOGW("{}", "cfdp::VarLenField: Setting value failed\n"); } } diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 04012cda2..528c482b8 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -128,17 +128,7 @@ class FilestoreTlvBase : public TlvIF { } void secondFileNameMissing() const { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "FilestoreRequestTlv::deSerialize: Second file name required" - " but TLV pointer not set" - << std::endl; -#else - sif::printWarning( - "FilestoreRequestTlv::deSerialize: Second file name required" - " but TLV pointer not set\n"); -#endif -#endif + FSFW_LOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n"); } FilestoreActionCode getActionCode() const { return actionCode; } diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index b31f4725e..891a95e2c 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/datapool/ReadCommitIFAttorney.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount) @@ -17,27 +17,15 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { return HasReturnvaluesIF::RETURN_FAILED; } if (state != States::STATE_SET_UNINITIALISED) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl; -#else - sif::printError("DataSet::registerVariable: Call made in wrong position."); -#endif + FSFW_LOGW("{}", "registerVariable: Call made in wrong position\n"); return DataSetIF::DATA_SET_UNINITIALISED; } if (variable == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl; -#else - sif::printError("DataSet::registerVariable: Pool variable is nullptr.\n"); -#endif + FSFW_LOGW("{}", "registerVariable: Pool variable is nullptr\n"); return DataSetIF::POOL_VAR_NULL; } if (fillCount >= maxFillCount) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DataSet::registerVariable: DataSet is full." << std::endl; -#else - sif::printError("DataSet::registerVariable: DataSet is full.\n"); -#endif + FSFW_LOGW("{}", "registerVariable: DataSet is full\n"); return DataSetIF::DATA_SET_FULL; } registeredVariables[fillCount] = variable; @@ -59,15 +47,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l state = States::STATE_SET_WAS_READ; unlockDataPool(); } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PoolDataSetBase::read: Call made in wrong position. Don't forget to " - "commit member datasets!" - << std::endl; -#else - sif::printWarning( - "PoolDataSetBase::read: Call made in wrong position. Don't forget to " - "commit member datasets!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGWT("{}", "read: Call made in wrong position. commit call might be missing\n"); result = SET_WAS_ALREADY_READ; } diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp index fd110e6c7..c52f1a0fa 100644 --- a/src/fsfw/datapool/PoolEntry.cpp +++ b/src/fsfw/datapool/PoolEntry.cpp @@ -4,7 +4,7 @@ #include #include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" template PoolEntry::PoolEntry(std::initializer_list initValue, bool setValid) @@ -68,13 +68,7 @@ void PoolEntry::print() { } else { validString = "Invalid"; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PoolEntry information." << std::endl; - sif::info << "PoolEntry validity: " << validString << std::endl; -#else - sif::printInfo("PoolEntry information.\n"); - sif::printInfo("PoolEntry validity: %s\n", validString); -#endif + FSFW_LOGI("PoolEntry Info. Validity {}\n", validString); arrayprinter::print(reinterpret_cast(address), getByteSize()); } diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h index 24d989330..d9c42fa76 100644 --- a/src/fsfw/datapool/PoolReadGuard.h +++ b/src/fsfw/datapool/PoolReadGuard.h @@ -1,10 +1,9 @@ #ifndef FSFW_DATAPOOL_POOLREADHELPER_H_ #define FSFW_DATAPOOL_POOLREADHELPER_H_ -#include - -#include "../serviceinterface/ServiceInterface.h" #include "ReadCommitIF.h" +#include "fsfw/FSFW.h" +#include "fsfw/serviceinterface.h" /** * @brief Helper class to read data sets or pool variables @@ -18,13 +17,7 @@ class PoolReadGuard { if (readObject != nullptr) { readResult = readObject->read(timeoutType, mutexTimeout); if (readResult != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL == 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolReadHelper: Read failed!" << std::endl; -#else - sif::printError("PoolReadHelper: Read failed!\n"); -#endif /* FSFW_PRINT_VERBOSITY_LEVEL == 1 */ -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGW("{}", "ctor: Read failed\n"); } } } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index a2925a46e..8650c29e7 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -166,15 +166,7 @@ class HasLocalDataPoolIF { * @return */ virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. " - "Returning nullptr!" - << std::endl; -#else - sif::printWarning( - "HasLocalDataPoolIF::getPoolObjectHandle: " - "Not overriden. Returning nullptr!\n"); -#endif + FSFW_LOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n"); return nullptr; } }; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 781d8f71f..94da2ac98 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -695,11 +695,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true); if (result != HasReturnvaluesIF::RETURN_OK) { /* Configuration error */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." << std::endl; -#else - sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n"); -#endif + FSFW_LOGWT("{}", "performHkOperation: HK generation failed"); } } diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index 62fdb184f..cd533cd99 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -7,7 +7,7 @@ #include "fsfw/housekeeping/PeriodicHousekeepingHelper.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "internal/HasLocalDpIFUserAttorney.h" LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId, @@ -16,14 +16,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t : PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if (hkOwner == nullptr) { // Configuration error. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " - << "invalid!" << std::endl; -#else - sif::printError( - "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " - "invalid!\n\r"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n"); return; } AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -186,14 +179,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " - << "Serialization error!" << std::endl; -#else - sif::printWarning( - "LocalPoolDataSetBase::serializeLocalPoolIds: " - "Serialization error!\n\r"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGW("{}", "serializeLocalPoolIds: Serialization error\n"); return result; } } diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 82aefc18c..5d0a3068f 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -4,22 +4,17 @@ #include "fsfw/datapoollocal/HasLocalDataPoolIF.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface.h" #include "internal/HasLocalDpIFUserAttorney.h" LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " - << "which is the NO_PARAMETER value!" << std::endl; -#endif + FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } if (hkOwner == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPoolVar::LocalPoolVar: The supplied pool " - << "owner is a invalid!" << std::endl; -#endif + FSFW_LOGET("{}", "ctor: Supplied pool owner is a invalid\n"); return; } AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -34,28 +29,14 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " - "which is the NO_PARAMETER value!" - << std::endl; -#else - sif::printWarning( - "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " - "which is the NO_PARAMETER value!\n"); -#endif + FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } - HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get(poolOwner); + auto* hkOwner = ObjectManager::instance()->get(poolOwner); if (hkOwner == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner - << std::dec << " did not implement the correct interface " - << "HasLocalDataPoolIF" << std::endl; -#else - sif::printError( - "LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct " - "interface HasLocalDataPoolIF\n", + FSFW_LOGWT( + "ctor: The supplied pool owner {:#08x} did not implement the correct interface " + "HasLocalDataPoolIF\n", poolOwner); -#endif return; } @@ -89,7 +70,6 @@ void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) { void LocalPoolObjectBase::reportReadCommitError(const char* variableType, ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) { -#if FSFW_DISABLE_PRINTOUT == 0 const char* variablePrintout = variableType; if (variablePrintout == nullptr) { variablePrintout = "Unknown Type"; @@ -114,13 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return errMsg = "Unknown error code"; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << variablePrintout << ": " << type << " call | " << errMsg << " | Owner: 0x" - << std::hex << std::setw(8) << std::setfill('0') << objectId << std::dec - << " LPID: " << lpId << std::endl; -#else - sif::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n", variablePrintout, type, errMsg, - objectId, lpId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_DISABLE_PRINTOUT == 0 */ + FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, + objectId, lpId); } diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index 044b8fa72..8112f92ca 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -98,13 +98,7 @@ inline T& LocalPoolVector::operator [](size_t i) { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid index. Setting or returning" - " last value!" << std::endl; -#else - sif::printWarning("LocalPoolVector: Invalid index. Setting or returning" - " last value!\n"); -#endif + FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } @@ -115,13 +109,7 @@ inline const T& LocalPoolVector::operator [](size_t i) const { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid index. Setting or returning" - " last value!" << std::endl; -#else - sif::printWarning("LocalPoolVector: Invalid index. Setting or returning" - " last value!\n"); -#endif + FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index dd9bd5d7d..e51043d92 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -150,22 +150,15 @@ ReturnValue_t DeviceHandlerBase::initialize() { } if (rawDataReceiverId != objects::NO_OBJECT) { - AcceptsDeviceResponsesIF* rawReceiver = - ObjectManager::instance()->get(rawDataReceiverId); + auto* rawReceiver = ObjectManager::instance()->get(rawDataReceiverId); if (rawReceiver == nullptr) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Raw receiver object ID set but no valid object found."); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Make sure the raw receiver object is set up properly" - " and implements AcceptsDeviceResponsesIF" - << std::endl; -#else - sif::printError( - "Make sure the raw receiver object is set up " - "properly and implements AcceptsDeviceResponsesIF\n"); -#endif + FSFW_LOGE("{}", + "Make sure the raw receiver object is set up properly " + "and implements AcceptsDeviceResponsesIF"); return ObjectManagerIF::CHILD_INIT_FAILED; } defaultRawReceiver = rawReceiver->getDeviceQueue(); @@ -177,14 +170,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Make sure the power switcher object is set up " - << "properly and implements PowerSwitchIF" << std::endl; -#else - sif::printError( - "Make sure the power switcher object is set up " - "properly and implements PowerSwitchIF\n"); -#endif + FSFW_LOGE("{}", + "Make sure the power switcher object is set up " + "properly and implements PowerSwitchIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -767,11 +755,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD printWarningOrError(sif::OutputTypes::OUT_ERROR, "parseReply", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!" - " Packet parsing will be stuck." - << std::endl; -#endif + FSFW_LOGW("{}", + "DeviceHandlerBase::parseReply: foundLen is 0! " + "Packet parsing will be stuck\n"); } break; } @@ -1476,23 +1462,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch } if (errorType == sif::OutputTypes::OUT_WARNING) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "DeviceHandlerBase::" << functionName << ": Object ID 0x" << std::hex - << std::setw(8) << std::setfill('0') << this->getObjectId() << " | " << errorPrint - << std::dec << std::setfill(' ') << std::endl; -#else - sif::printWarning("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n", functionName, - this->getObjectId(), errorPrint); -#endif + FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } else if (errorType == sif::OutputTypes::OUT_ERROR) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DeviceHandlerBase::" << functionName << ": Object ID 0x" << std::hex - << std::setw(8) << std::setfill('0') << this->getObjectId() << " | " << errorPrint - << std::dec << std::setfill(' ') << std::endl; -#else - sif::printError("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n", functionName, - this->getObjectId(), errorPrint); -#endif + FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 5808b8e69..84dcb8dcc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1062,7 +1062,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * Same as triggerEvent, but for forwarding if object is used as proxy. */ - virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const override; + virtual void forwardEvent(Event event, uint32_t parameter1 = 0, + uint32_t parameter2 = 0) const override; /** * Checks if current mode is transitional mode. diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index 48783c200..185de217a 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -5,7 +5,7 @@ #include "fsfw/modes/HasModesIF.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/power/Fuse.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/serviceinterface.h" #include "fsfw/thermal/ThermalComponentIF.h" object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; @@ -163,15 +163,10 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" - " initialize FailureIsolationBase." - << std::endl; -#endif + FSFW_LOGE("{}", "initialize: Could not initialize FailureIsolationBase\n"); return result; } - ConfirmsFailuresIF* power = - ObjectManager::instance()->get(powerConfirmationId); + auto* power = ObjectManager::instance()->get(powerConfirmationId); if (power != nullptr) { powerConfirmation = power->getEventReceptionQueue(); } diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index 98051ba05..2ab9af411 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -4,9 +4,9 @@ #include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueSenderIF.h" #include "../objectmanager/ObjectManager.h" -#include "../serviceinterface/ServiceInterface.h" #include "EventMessage.h" #include "eventmatching/eventmatching.h" +#include "fsfw/serviceinterface.h" class EventManagerIF { public: @@ -39,19 +39,9 @@ class EventManagerIF { static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) { if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) { - EventManagerIF* eventmanager = - ObjectManager::instance()->get(objects::EVENT_MANAGER); + auto* eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (eventmanager == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "EventManagerIF::triggerEvent: EventManager invalid or not found!" - << std::endl; -#else - sif::printWarning( - "EventManagerIF::triggerEvent: " - "EventManager invalid or not found!"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n"); return; } eventmanagerQueue = eventmanager->getEventReportQueue(); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index fedef8696..39fbe0221 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -18,13 +18,9 @@ FailureIsolationBase::~FailureIsolationBase() { } ReturnValue_t FailureIsolationBase::initialize() { - EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FailureIsolationBase::initialize: Event Manager has not" - " been initialized!" - << std::endl; -#endif + FSFW_LOGE("{}", "initialize: Event Manager has not been initialized\n"); return RETURN_FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); @@ -38,27 +34,19 @@ ReturnValue_t FailureIsolationBase::initialize() { } owner = ObjectManager::instance()->get(ownerId); if (owner == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FailureIsolationBase::intialize: Owner object " - "invalid. Make sure it implements HasHealthIF" - << std::endl; -#endif + FSFW_LOGE( + "FailureIsolationBase::intialize: Owner object {:#08x} invalid. " + "Does it implement HasHealthIF?\n", + ownerId); return ObjectManagerIF::CHILD_INIT_FAILED; } } if (faultTreeParent != objects::NO_OBJECT) { - ConfirmsFailuresIF* parentIF = - ObjectManager::instance()->get(faultTreeParent); + auto* parentIF = ObjectManager::instance()->get(faultTreeParent); if (parentIF == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FailureIsolationBase::intialize: Parent object" - << "invalid." << std::endl; -#endif -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl; -#endif + FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", + faultTreeParent); return ObjectManagerIF::CHILD_INIT_FAILED; - return RETURN_FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); } diff --git a/src/fsfw/globalfunctions/arrayprinter.cpp b/src/fsfw/globalfunctions/arrayprinter.cpp index 40dc09f56..c8de86102 100644 --- a/src/fsfw/globalfunctions/arrayprinter.cpp +++ b/src/fsfw/globalfunctions/arrayprinter.cpp @@ -3,31 +3,16 @@ #include #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool printInfo, size_t maxCharPerLine) { if (size == 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Size is zero, nothing to print" << std::endl; -#else - sif::printInfo("Size is zero, nothing to print\n"); -#endif + FSFW_LOGI("{}", "Size is zero, nothing to print\n"); return; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - if (printInfo) { - sif::info << "Printing data with size " << size << ": " << std::endl; - } -#else -#if FSFW_NO_C99_IO == 1 - sif::printInfo("Printing data with size %lu: \n", static_cast(size)); -#else - sif::printInfo("Printing data with size %zu: \n", size); -#endif /* FSFW_NO_C99_IO == 1 */ -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - + FSFW_LOGI("Printing data with size {}:\n", size); if (type == OutputType::HEX) { arrayprinter::printHex(data, size, maxCharPerLine); } else if (type == OutputType::DEC) { @@ -38,99 +23,99 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool } void arrayprinter::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - if (sif::info.crAdditionEnabled()) { - std::cout << "\r" << std::endl; - } - - std::cout << "hex [" << std::setfill('0') << std::hex; - for (size_t i = 0; i < size; i++) { - std::cout << std::setw(2) << static_cast(data[i]); - if (i < size - 1) { - std::cout << ","; - if (i > 0 and (i + 1) % maxCharPerLine == 0) { - std::cout << std::endl; - } - } - } - std::cout << std::dec << std::setfill(' '); - std::cout << "]" << std::endl; -#else - // General format: 0x01, 0x02, 0x03 so it is number of chars times 6 - // plus line break plus small safety margin. - char printBuffer[(size + 1) * 7 + 1] = {}; - size_t currentPos = 0; - for (size_t i = 0; i < size; i++) { - // To avoid buffer overflows. - if (sizeof(printBuffer) - currentPos <= 7) { - break; - } - - currentPos += snprintf(printBuffer + currentPos, 6, "%02x", data[i]); - if (i < size - 1) { - currentPos += sprintf(printBuffer + currentPos, ","); - if ((i + 1) % maxCharPerLine == 0) { - currentPos += sprintf(printBuffer + currentPos, "\n"); - } - } - } -#if FSFW_DISABLE_PRINTOUT == 0 - printf("hex [%s]\n", printBuffer); -#endif /* FSFW_DISABLE_PRINTOUT == 0 */ -#endif + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // if (sif::info.crAdditionEnabled()) { + // std::cout << "\r" << std::endl; + // } + // + // std::cout << "hex [" << std::setfill('0') << std::hex; + // for (size_t i = 0; i < size; i++) { + // std::cout << std::setw(2) << static_cast(data[i]); + // if (i < size - 1) { + // std::cout << ","; + // if (i > 0 and (i + 1) % maxCharPerLine == 0) { + // std::cout << std::endl; + // } + // } + // } + // std::cout << std::dec << std::setfill(' '); + // std::cout << "]" << std::endl; + //#else + // // General format: 0x01, 0x02, 0x03 so it is number of chars times 6 + // // plus line break plus small safety margin. + // char printBuffer[(size + 1) * 7 + 1] = {}; + // size_t currentPos = 0; + // for (size_t i = 0; i < size; i++) { + // // To avoid buffer overflows. + // if (sizeof(printBuffer) - currentPos <= 7) { + // break; + // } + // + // currentPos += snprintf(printBuffer + currentPos, 6, "%02x", data[i]); + // if (i < size - 1) { + // currentPos += sprintf(printBuffer + currentPos, ","); + // if ((i + 1) % maxCharPerLine == 0) { + // currentPos += sprintf(printBuffer + currentPos, "\n"); + // } + // } + // } + //#if FSFW_DISABLE_PRINTOUT == 0 + // printf("hex [%s]\n", printBuffer); + //#endif /* FSFW_DISABLE_PRINTOUT == 0 */ + //#endif } void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - if (sif::info.crAdditionEnabled()) { - std::cout << "\r" << std::endl; - } - - std::cout << "dec [" << std::dec; - for (size_t i = 0; i < size; i++) { - std::cout << static_cast(data[i]); - if (i < size - 1) { - std::cout << ","; - if (i > 0 and (i + 1) % maxCharPerLine == 0) { - std::cout << std::endl; - } - } - } - std::cout << "]" << std::endl; -#else - // General format: 32,243,-12 so it is number of chars times 4 - // plus line break plus small safety margin. - uint16_t expectedLines = ceil((double)size / maxCharPerLine); - char printBuffer[size * 4 + 1 + expectedLines] = {}; - size_t currentPos = 0; - for (size_t i = 0; i < size; i++) { - // To avoid buffer overflows. - if (sizeof(printBuffer) - currentPos <= 4) { - break; - } - - currentPos += snprintf(printBuffer + currentPos, 4, "%d", data[i]); - if (i < size - 1) { - currentPos += sprintf(printBuffer + currentPos, ","); - if ((i + 1) % maxCharPerLine == 0) { - currentPos += sprintf(printBuffer + currentPos, "\n"); - } - } - } -#if FSFW_DISABLE_PRINTOUT == 0 - printf("dec [%s]\n", printBuffer); -#endif /* FSFW_DISABLE_PRINTOUT == 0 */ -#endif + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // if (sif::info.crAdditionEnabled()) { + // std::cout << "\r" << std::endl; + // } + // + // std::cout << "dec [" << std::dec; + // for (size_t i = 0; i < size; i++) { + // std::cout << static_cast(data[i]); + // if (i < size - 1) { + // std::cout << ","; + // if (i > 0 and (i + 1) % maxCharPerLine == 0) { + // std::cout << std::endl; + // } + // } + // } + // std::cout << "]" << std::endl; + //#else + // // General format: 32,243,-12 so it is number of chars times 4 + // // plus line break plus small safety margin. + // uint16_t expectedLines = ceil((double)size / maxCharPerLine); + // char printBuffer[size * 4 + 1 + expectedLines] = {}; + // size_t currentPos = 0; + // for (size_t i = 0; i < size; i++) { + // // To avoid buffer overflows. + // if (sizeof(printBuffer) - currentPos <= 4) { + // break; + // } + // + // currentPos += snprintf(printBuffer + currentPos, 4, "%d", data[i]); + // if (i < size - 1) { + // currentPos += sprintf(printBuffer + currentPos, ","); + // if ((i + 1) % maxCharPerLine == 0) { + // currentPos += sprintf(printBuffer + currentPos, "\n"); + // } + // } + // } + //#if FSFW_DISABLE_PRINTOUT == 0 + // printf("dec [%s]\n", printBuffer); + //#endif /* FSFW_DISABLE_PRINTOUT == 0 */ + //#endif } void arrayprinter::printBin(const uint8_t *data, size_t size) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - for (size_t i = 0; i < size; i++) { - sif::info << "Byte " << i + 1 << ": 0b" << std::bitset<8>(data[i]) << std::endl; - } -#else - for (size_t i = 0; i < size; i++) { - sif::printInfo("Byte %d: 0b" BYTE_TO_BINARY_PATTERN "\n", i + 1, BYTE_TO_BINARY(data[i])); - } -#endif + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // for (size_t i = 0; i < size; i++) { + // sif::info << "Byte " << i + 1 << ": 0b" << std::bitset<8>(data[i]) << std::endl; + // } + //#else + // for (size_t i = 0; i < size; i++) { + // sif::printInfo("Byte %d: 0b" BYTE_TO_BINARY_PATTERN "\n", i + 1, BYTE_TO_BINARY(data[i])); + // } + //#endif } diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 4bef128c1..954a1e19d 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -35,20 +35,12 @@ ReturnValue_t HealthHelper::initialize() { eventSender = ObjectManager::instance()->get(objectId); if (healthTable == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "HealthHelper::initialize: Health table object needs" - "to be created in factory." - << std::endl; -#endif + FSFW_LOGE("{}", "initialize: Health table object needs to be created in factory\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } if (eventSender == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "HealthHelper::initialize: Owner has to implement " - "ReportingProxyIF." - << std::endl; -#endif + FSFW_LOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -77,9 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl; -#endif + FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); } } @@ -96,10 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "HealthHelper::handleHealthCommand: sending health " - "reply failed." - << std::endl; -#endif + FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", + objectId); } } diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index ab4881f41..e9358bd7f 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -3,6 +3,7 @@ #include "fsfw/ipc/MutexFactory.h" #include "fsfw/ipc/MutexGuard.h" #include "fsfw/serialize/SerializeAdapter.h" +#include "fsfw/serviceinterface.h" HealthTable::HealthTable(object_id_t objectid) : SystemObject(objectid) { mutex = MutexFactory::instance()->createMutex(); @@ -68,13 +69,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { ReturnValue_t result = SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl; -#else - sif::printWarning("HealthTable::printAll: Serialization of health table failed\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "printAll: Serialization of health table failed\n"); return; } for (const auto& health : healthMap) { diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 6899915ac..bbaddda1a 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize()) { memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); @@ -15,11 +15,7 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) memcpy(this->getData(), data, size); this->messageSize = this->HEADER_SIZE + size; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "MessageQueueMessage: Passed size larger than maximum" - "allowed size! Setting content to 0" - << std::endl; -#endif + FSFW_LOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n"); memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); this->messageSize = this->HEADER_SIZE; } diff --git a/src/fsfw/ipc/MutexGuard.h b/src/fsfw/ipc/MutexGuard.h index f7b906633..e9c15c0e5 100644 --- a/src/fsfw/ipc/MutexGuard.h +++ b/src/fsfw/ipc/MutexGuard.h @@ -1,8 +1,10 @@ #ifndef FRAMEWORK_IPC_MUTEXGUARD_H_ #define FRAMEWORK_IPC_MUTEXGUARD_H_ -#include "../serviceinterface/ServiceInterface.h" -#include "MutexFactory.h" +#include + +#include "fsfw/ipc/MutexIF.h" +#include "fsfw/serviceinterface.h" class MutexGuard { public: @@ -10,35 +12,17 @@ class MutexGuard { uint32_t timeoutMs = 0) : internalMutex(mutex) { if (mutex == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl; -#else - sif::printError("MutexGuard: Passed mutex is invalid!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + // It's tricky to use the error functions defined in the service interface + // because those functions require the mutex guard themselves + fmt::print("ERROR | Passed mutex is invalid\n"); return; } result = mutex->lockMutex(timeoutType, timeoutMs); -#if FSFW_VERBOSE_LEVEL >= 1 if (result == MutexIF::MUTEX_TIMEOUT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MutexGuard: Lock of mutex failed with timeout of " << timeoutMs - << " milliseconds!" << std::endl; -#else - sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n", - timeoutMs); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - + fmt::print("ERROR | Lock of mutex failed with timeout of {} milliseconds\n", timeoutMs); } else if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl; -#else - sif::printError("MutexGuard: Lock of Mutex failed with code %d\n", result); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + fmt::print("ERROR | Lock of Mutex failed with code {}\n", result); } -#else -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ } ReturnValue_t getLockResult() const { return result; } diff --git a/src/fsfw/memory/MemoryHelper.cpp b/src/fsfw/memory/MemoryHelper.cpp index 462a818e9..34cd30171 100644 --- a/src/fsfw/memory/MemoryHelper.cpp +++ b/src/fsfw/memory/MemoryHelper.cpp @@ -4,7 +4,7 @@ #include "fsfw/memory/MemoryMessage.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serialize/EndianConverter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue) : workOnThis(workOnThis), @@ -17,9 +17,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { lastSender = message->getSender(); lastCommand = message->getCommand(); if (busy) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "MemHelper: Busy!" << std::endl; -#endif + FSFW_LOGW("{}", "MemoryHelper: Busy\n"); } switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index fb3ace3da..ebb473988 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -81,11 +81,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); if (timeStamper == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MonitoringReportContent::checkAndSetStamper: " - "Stamper not found!" - << std::endl; -#endif + FSFW_LOGET("{}", "checkAndSetStamper: Stamper not found\n"); return false; } } diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 2017938a1..86fe8d182 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -1,6 +1,6 @@ -#include "fsfw/objectmanager/ObjectManager.h" +#include "ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 #include @@ -38,15 +38,8 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { #endif return this->RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast(id) - << std::dec << " is already in use!" << std::endl; - sif::error << "Terminating program" << std::endl; -#else - sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n", - static_cast(id)); - sif::printError("Terminating program"); -#endif + FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", + static_cast(id)); // This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); } @@ -61,10 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { #endif return RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id - << std::dec << " not found." << std::endl; -#endif + FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id); return NOT_FOUND; } } @@ -79,64 +69,44 @@ SystemObjectIF* ObjectManager::getSystemObject(object_id_t id) { } void ObjectManager::initialize() { - if (objectFactoryFunction == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::initialize: Passed produceObjects " - "functions is nullptr!" - << std::endl; -#else - sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n"); -#endif - return; + if (objectFactoryFunction != nullptr) { + objectFactoryFunction(factoryArgs); } - objectFactoryFunction(factoryArgs); ReturnValue_t result = RETURN_FAILED; uint32_t errorCount = 0; for (auto const& it : objectList) { result = it.second->initialize(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 object_id_t var = it.first; - sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) - << std::setfill('0') << var - << " failed to " - "initialize with code 0x" - << result << std::dec << std::setfill(' ') << std::endl; -#endif + FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, + result); errorCount++; } } if (errorCount > 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::ObjectManager: Counted " << errorCount - << " failed initializations." << std::endl; -#endif + FSFW_LOGWT("{}", "initialize: Counted failed initializations\n"); } // Init was successful. Now check successful interconnections. errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex << (int)it.first - << " connection check failed with code 0x" << result << std::dec << std::endl; -#endif + FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, + result); errorCount++; } } if (errorCount > 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ObjectManager::ObjectManager: Counted " << errorCount - << " failed connection checks." << std::endl; -#endif + FSFW_LOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n", + errorCount); } } void ObjectManager::printList() { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "ObjectManager: Object List contains:" << std::endl; + sif::info("ObjectManager: Object List contains:\n"); for (auto const& it : objectList) { - sif::debug << std::hex << it.first << " | " << it.second << std::endl; + sif::info("{:#08x} | {:#08x}\n", it.first, it.second); } #endif } diff --git a/src/fsfw/objectmanager/SystemObject.h b/src/fsfw/objectmanager/SystemObject.h index eeb68b8fb..c541ac5ec 100644 --- a/src/fsfw/objectmanager/SystemObject.h +++ b/src/fsfw/objectmanager/SystemObject.h @@ -50,7 +50,8 @@ class SystemObject : public SystemObjectIF { virtual ReturnValue_t initialize() override; virtual ReturnValue_t checkObjectConnections() override; - virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const override; + virtual void forwardEvent(Event event, uint32_t parameter1 = 0, + uint32_t parameter2 = 0) const override; }; #endif /* FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ */ diff --git a/src/fsfw/osal/common/UdpTcPollingTask.cpp b/src/fsfw/osal/common/UdpTcPollingTask.cpp index 38fb19211..bcc8e9e33 100644 --- a/src/fsfw/osal/common/UdpTcPollingTask.cpp +++ b/src/fsfw/osal/common/UdpTcPollingTask.cpp @@ -154,7 +154,7 @@ void UdpTcPollingTask::setTimeout(double timeoutSeconds) { #endif } #elif defined(PLATFORM_UNIX) - timeval tval {}; + timeval tval{}; tval = timevalOperations::toTimeval(timeoutSeconds); int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(receptionTimeout)); if (result == -1) { diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index 6089f266a..e3cad58ff 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -20,7 +20,7 @@ const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, - const std::string& udpServerPort_, object_id_t tmStoreId, + const std::string &udpServerPort_, object_id_t tmStoreId, object_id_t tcStoreId) : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { if (udpServerPort_.empty()) { @@ -118,7 +118,7 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { #endif ssize_t bytesSent = sendto(serverSocket, reinterpret_cast(data), dataLen, flags, - &clientAddress, clientAddressLen); + &clientAddress, clientAddressLen); if (bytesSent == SOCKET_ERROR) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcUdpBridge::sendTm: Send operation failed." << std::endl; diff --git a/src/fsfw/osal/common/UdpTmTcBridge.h b/src/fsfw/osal/common/UdpTmTcBridge.h index b0a67430f..92829c468 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.h +++ b/src/fsfw/osal/common/UdpTmTcBridge.h @@ -29,8 +29,8 @@ class UdpTmTcBridge : public TmTcBridge, public TcpIpBase { /* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_SERVER_PORT; - UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, const std::string& udpServerPort = "", - object_id_t tmStoreId = objects::TM_STORE, + UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, + const std::string& udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE, object_id_t tcStoreId = objects::TC_STORE); ~UdpTmTcBridge() override; diff --git a/src/fsfw/osal/linux/tcpipHelpers.cpp b/src/fsfw/osal/linux/tcpipHelpers.cpp index 2ae9bc8ab..aee7bd798 100644 --- a/src/fsfw/osal/linux/tcpipHelpers.cpp +++ b/src/fsfw/osal/linux/tcpipHelpers.cpp @@ -1,10 +1,9 @@ #include "fsfw/osal/common/tcpipHelpers.h" -#include - +#include #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/TaskFactory.h" void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t sleepDuration) { @@ -97,14 +96,13 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s } #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString << " | " - << infoString << std::endl; + FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); #else sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(), errorSrcString.c_str(), infoString.c_str()); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ if (sleepDuration > 0) { - TaskFactory::instance()->delayTask(sleepDuration); + TaskFactory::delayTask(sleepDuration); } } diff --git a/src/fsfw/parameters/ParameterHelper.cpp b/src/fsfw/parameters/ParameterHelper.cpp index 58356af56..e5c0357f5 100644 --- a/src/fsfw/parameters/ParameterHelper.cpp +++ b/src/fsfw/parameters/ParameterHelper.cpp @@ -2,6 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/parameters/ParameterMessage.h" +#include "fsfw/serviceinterface.h" ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) : owner(owner) {} @@ -43,10 +44,9 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "ParameterHelper::handleParameterMessage: Getting" - << " store data failed for load command." << std::endl; -#endif + FSFW_LOGE("{}", + "ParameterHelper::handleParameterMessage: Getting store data failed for " + "load command\n"); break; } diff --git a/src/fsfw/parameters/ParameterWrapper.cpp b/src/fsfw/parameters/ParameterWrapper.cpp index 27552290e..111facf2e 100644 --- a/src/fsfw/parameters/ParameterWrapper.cpp +++ b/src/fsfw/parameters/ParameterWrapper.cpp @@ -1,7 +1,7 @@ #include "fsfw/parameters/ParameterWrapper.h" #include "fsfw/FSFW.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" ParameterWrapper::ParameterWrapper() : pointsToStream(false), type(Type::UNKNOWN_TYPE) {} @@ -209,47 +209,23 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, uint16_t startWritingAtIndex) { if (data == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ParameterWrapper::copyFrom: Called on read-only variable!" << std::endl; -#else - sif::printWarning("ParameterWrapper::copyFrom: Called on read-only variable!\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("{}", "copyFrom: Called on read-only variable\n"); return READONLY; } if (from->readonlyData == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ParameterWrapper::copyFrom: Source not set!" << std::endl; -#else - sif::printWarning("ParameterWrapper::copyFrom: Source not set!\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("{}", "copyFrom: Source not set\n"); return SOURCE_NOT_SET; } if (type != from->type) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ParameterWrapper::copyFrom: Datatype missmatch!" << std::endl; -#else - sif::printWarning("ParameterWrapper::copyFrom: Datatype missmatch!\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "copyFrom: Datatype missmatch\n"); return DATATYPE_MISSMATCH; } // The smallest allowed value for rows and columns is one. if (rows == 0 or columns == 0) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ParameterWrapper::copyFrom: Columns or rows zero!" << std::endl; -#else - sif::printWarning("ParameterWrapper::copyFrom: Columns or rows zero!\n"); -#endif -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n"); return COLUMN_OR_ROWS_ZERO; } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 83129982b..86c0898ab 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" template SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength, @@ -95,11 +95,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, template uint8_t* SerialBufferAdapter::getBuffer() { if (buffer == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Wrong access function for stored type !" - " Use getConstBuffer()." - << std::endl; -#endif + FSFW_LOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n"); return nullptr; } return buffer; @@ -108,11 +104,7 @@ uint8_t* SerialBufferAdapter::getBuffer() { template const uint8_t* SerialBufferAdapter::getConstBuffer() const { if (constBuffer == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SerialBufferAdapter::getConstBuffer:" - " Buffers are unitialized!" - << std::endl; -#endif + FSFW_LOGE("{}", "getConstBuffer: Buffers are unitialized\n"); return nullptr; } return constBuffer; diff --git a/src/fsfw/serviceinterface.h b/src/fsfw/serviceinterface.h index 2e9a0b7e4..998d3d502 100644 --- a/src/fsfw/serviceinterface.h +++ b/src/fsfw/serviceinterface.h @@ -1,6 +1,7 @@ #ifndef FSFW_SRC_FSFW_SERVICEINTERFACE_H_ #define FSFW_SRC_FSFW_SERVICEINTERFACE_H_ -#include "serviceinterface/ServiceInterface.h" +#include "serviceinterface/fmtWrapper.h" +//#include "serviceinterface/ServiceInterface.h" #endif /* FSFW_SRC_FSFW_SERVICEINTERFACE_H_ */ diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/src/fsfw/serviceinterface/ServiceInterfaceStream.h index 0b3d67450..db429dad7 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceStream.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceStream.h @@ -57,10 +57,10 @@ class ServiceInterfaceStream : public std::ostream { // Forward declaration of interface streams. These should be instantiated in // main. They can then be used like std::cout or std::cerr. namespace sif { -extern ServiceInterfaceStream debug; -extern ServiceInterfaceStream info; -extern ServiceInterfaceStream warning; -extern ServiceInterfaceStream error; +// extern ServiceInterfaceStream debug; +// extern ServiceInterfaceStream info; +// extern ServiceInterfaceStream warning; +// extern ServiceInterfaceStream error; } // namespace sif #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ diff --git a/src/fsfw/serviceinterface/fmtWrapper.cpp b/src/fsfw/serviceinterface/fmtWrapper.cpp index ca9608808..36b89d2dd 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.cpp +++ b/src/fsfw/serviceinterface/fmtWrapper.cpp @@ -5,11 +5,11 @@ std::array sif::PRINT_BUF = {}; MutexIF* sif::PRINT_MUTEX = nullptr; -const char* sif::PREFIX_ARR[4]= {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX}; +const char* sif::PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX}; ReturnValue_t sif::initialize() { sif::PRINT_MUTEX = MutexFactory::instance()->createMutex(); - if(sif::PRINT_MUTEX == nullptr) { + if (sif::PRINT_MUTEX == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h index 9b957512f..c0881cb15 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.h +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -8,7 +8,6 @@ #include #include -#include "fsfw/ipc/MutexGuard.h" #include "fsfw/ipc/MutexIF.h" #include "fsfw/timemanager/Clock.h" @@ -44,12 +43,16 @@ size_t writeTypePrefix(LogLevel level); template size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed, fmt::format_string fmt, T&&... args) noexcept { - if(PRINT_MUTEX == nullptr) { + if (PRINT_MUTEX == nullptr) { fmt::print("Please call sif::initialize at program startup\n"); return 0; } try { - MutexGuard mg(PRINT_MUTEX); + auto fsfwret = PRINT_MUTEX->lockMutex(); + if (fsfwret != HasReturnvaluesIF::RETURN_OK) { + fmt::print("ERROR | {} | Locking print mutex failed", __FILENAME__); + return 0; + } size_t bufPos = writeTypePrefix(level); auto currentIter = PRINT_BUF.begin() + bufPos; if (timed) { @@ -61,27 +64,34 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed logTime.usecond / 1000, fmt::format(fmt, args...)); bufPos += result.size; } else { - const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, - " | {}[l.{}] | {}", file, line, fmt::format(fmt, args...)); + const auto result = + fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file, + line, fmt::format(fmt, args...)); bufPos += result.size; } PRINT_BUF[bufPos] = '\0'; fmt::print(fmt::runtime(PRINT_BUF.data())); + PRINT_MUTEX->unlockMutex(); return bufPos; } catch (const fmt::v8::format_error& e) { fmt::print("Printing failed with error: {}\n", e.what()); + PRINT_MUTEX->unlockMutex(); return 0; } } template size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args) noexcept { - if(PRINT_MUTEX == nullptr) { + if (PRINT_MUTEX == nullptr) { fmt::print("Please call sif::initialize at program startup\n"); return 0; } try { - MutexGuard mg(PRINT_MUTEX); + auto fsfwret = PRINT_MUTEX->lockMutex(); + if (fsfwret != HasReturnvaluesIF::RETURN_OK) { + fmt::print("ERROR | {} | Locking print mutex failed", __FILENAME__); + return 0; + } size_t bufPos = writeTypePrefix(level); auto currentIter = PRINT_BUF.begin() + bufPos; if (timed) { @@ -92,73 +102,101 @@ size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args logTime.minute, logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...)); bufPos += result.size; } else { - const auto result = fmt::format_to_n( - currentIter, PRINT_BUF.size() - bufPos, " | {}", fmt::format(fmt, args...)); + const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - bufPos, " | {}", + fmt::format(fmt, args...)); bufPos += result.size; } PRINT_BUF[bufPos] = '\0'; fmt::print(fmt::runtime(PRINT_BUF.data())); + PRINT_MUTEX->unlockMutex(); return bufPos; } catch (const fmt::v8::format_error& e) { + PRINT_MUTEX->unlockMutex(); fmt::print("Printing failed with error: {}\n", e.what()); return 0; } } template -void fdebug(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) noexcept { +void debug(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, false, fmt, args...); } template -void fdebug_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) noexcept { +void debug_t(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, true, fmt, args...); } template -void finfo_t(fmt::format_string fmt, T&&... args) { +void info_t(fmt::format_string fmt, T&&... args) { log(LogLevel::INFO, true, fmt, args...); } template -void finfo(fmt::format_string fmt, T&&... args) { +void info(fmt::format_string fmt, T&&... args) { log(LogLevel::INFO, false, fmt, args...); } template -void fwarning(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void warning(fmt::format_string fmt, T&&... args) { + log(LogLevel::ERROR, false, fmt, args...); +} + +template +void warning_t(fmt::format_string fmt, T&&... args) { + log(LogLevel::ERROR, true, fmt, args...); +} + +template +void warning_f(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::WARNING, file, line, false, fmt, args...); } template -void fwarning_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void warning_ft(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::WARNING, file, line, true, fmt, args...); } template -void ferror(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void error(fmt::format_string fmt, T&&... args) { + log(LogLevel::ERROR, false, fmt, args...); +} + +template +void error_t(fmt::format_string fmt, T&&... args) { + log(LogLevel::ERROR, true, fmt, args...); +} + +template +void error_f(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::ERROR, file, line, false, fmt, args...); } template -void ferror_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void error_ft(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::ERROR, file, line, true, fmt, args...); } } // namespace sif -#define FSFW_LOGI(format, ...) finfo(FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGI(format, ...) sif::info(FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGIT(format, ...) sif::info_t(FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGD(format, ...) sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGD(format, ...) sif::debug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGDT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGDT(format, ...) \ + sif::debug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGW(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGW(format, ...) \ + sif::warning_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGWT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGWT(format, ...) \ + sif::warning_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGE(format, ...) sif::error_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGET(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGET(format, ...) \ + sif::error_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index df2fc7507..6cf99b78b 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId) : storeId(storeId) {} @@ -46,18 +46,14 @@ const uint8_t* ConstStorageAccessor::data() const { return constDataPointer; } size_t ConstStorageAccessor::size() const { if (internalState == AccessState::UNINIT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StorageAccessor: Not initialized!" << std::endl; -#endif + FSFW_LOGW("{}", "size: Not initialized\n"); } return size_; } ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StorageAccessor: Not initialized!" << std::endl; -#endif + FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index cee1d4070..44e8e818f 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -4,6 +4,7 @@ #include "fsfw/FSFW.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface.h" LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, bool registered, bool spillsToHigherPools) @@ -11,10 +12,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, NUMBER_OF_SUBPOOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { if (NUMBER_OF_SUBPOOLS == 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPool::LocalPool: Passed pool configuration is " - << " invalid!" << std::endl; -#endif + FSFW_LOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n"); } max_subpools_t index = 0; for (const auto& currentPoolConfig : poolConfig) { @@ -127,9 +125,8 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { sizeLists[storeId.poolIndex][storeId.packetIndex] = STORAGE_FREE; } else { // pool_index or packet_index is too large -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPool::deleteData: Illegal store ID, no deletion!" << std::endl; -#endif + FSFW_LOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n", + SystemObject::getObjectId()); status = ILLEGAL_STORAGE_ID; } return status; @@ -178,11 +175,10 @@ ReturnValue_t LocalPool::initialize() { // Check if any pool size is large than the maximum allowed. for (uint8_t count = 0; count < NUMBER_OF_SUBPOOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPool::initialize: Pool is too large! " - "Max. allowed size is: " - << (STORAGE_FREE - 1) << std::endl; -#endif + FSFW_LOGW( + "LocalPool::initialize: Pool is too large- " + "Max. allowed size is: {}\n", + STORAGE_FREE - 1); return StorageManagerIF::POOL_TOO_LARGE; } } @@ -203,10 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec - << " )::reserveSpace: Packet too large." << std::endl; -#endif + FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index e2b083b21..ae1418490 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" StorageAccessor::StorageAccessor(store_address_t storeId) : ConstStorageAccessor(storeId) {} @@ -23,9 +23,7 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other) ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StorageAccessor: Not initialized!" << std::endl; -#endif + FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index d4c67b4da..81f40bdec 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/FixedTimeslotTaskIF.h" FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) : lengthMs(setLengthMs) { @@ -90,9 +90,7 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, in ReturnValue_t FixedSlotSequence::checkSequence() const { if (slotList.empty()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "FixedSlotSequence::checkSequence: Slot list is empty!" << std::endl; -#endif + FSFW_LOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n"); return FixedTimeslotTaskIF::SLOT_LIST_EMPTY; } @@ -100,10 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t result = customCheckFunction(slotList); if (result != HasReturnvaluesIF::RETURN_OK) { // Continue for now but print error output. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FixedSlotSequence::checkSequence:" - << " Custom check failed!" << std::endl; -#endif + FSFW_LOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result); } } @@ -113,10 +108,8 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { if (slot.executableObject == nullptr) { errorCount++; } else if (slot.pollingTimeMs < time) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FixedSlotSequence::checkSequence: Time: " << slot.pollingTimeMs - << " is smaller than previous with " << time << std::endl; -#endif + FSFW_LOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n", + slot.pollingTimeMs, time); errorCount++; } else { // All ok, print slot. @@ -151,11 +144,10 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } } if (count > 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FixedSlotSequence::intializeSequenceAfterTaskCreation:" - "Counted " - << count << " failed initializations!" << std::endl; -#endif + FSFW_LOGE( + "FixedSlotSequence::intializeSequenceAfterTaskCreation: Counted {} " + "failed initializations\n", + count); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 3f4bbee34..3feed941d 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -1,7 +1,7 @@ #include "fsfw/tcdistribution/CCSDSDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcpacket/SpacePacketBase.h" #define CCSDS_DISTRIBUTOR_DEBUGGING 0 @@ -27,17 +27,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { size_t size = 0; ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSDistributor::selectDestination: Getting data from" - " store failed!" - << std::endl; -#else - sif::printError( - "CCSDSDistributor::selectDestination: Getting data from" - " store failed!\n"); -#endif -#endif + FSFW_LOGWT("{}", "selectDestination: Getting data from store failed"); } SpacePacketBase currentPacket(packet); diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index d8be1543e..1b99dc449 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -21,13 +21,8 @@ CFDPDistributor::~CFDPDistributor() {} CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = this->currentMessage.getStorageId(); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " + FSFW_LOGI("selectDestination: Recie" << storeId.poolIndex << ", " << storeId.packetIndex << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, - storeId.packetIndex); -#endif #endif TcMqMapIter queueMapIt = this->queueMap.end(); if (this->currentPacket == nullptr) { diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index a650546c1..b9b3a999c 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -1,7 +1,7 @@ #include "fsfw/tcdistribution/TcDistributor.h" #include "fsfw/ipc/QueueFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) { @@ -33,14 +33,10 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl; - sif::debug << std::setfill('0') << std::setw(8) << std::hex; + FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); for (const auto& queueMapIter : queueMap) { - sif::debug << queueMapIter.first << "\t| 0x" << queueMapIter.second << std::endl; + FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); } - sif::debug << std::setfill(' ') << std::dec; -#endif } ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return RETURN_OK; } diff --git a/src/fsfw/timemanager/Stopwatch.cpp b/src/fsfw/timemanager/Stopwatch.cpp index 05d5c0e8b..983c97134 100644 --- a/src/fsfw/timemanager/Stopwatch.cpp +++ b/src/fsfw/timemanager/Stopwatch.cpp @@ -1,6 +1,6 @@ #include "fsfw/timemanager/Stopwatch.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 #include @@ -29,22 +29,12 @@ double Stopwatch::stopSeconds() { void Stopwatch::display() { if (displayMode == StopwatchDisplayMode::MILLIS) { - dur_millis_t timeMillis = + auto timeMillis = static_cast(elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Stopwatch: Operation took " << timeMillis << " milliseconds" << std::endl; -#else - sif::printInfo("Stopwatch: Operation took %lu milliseconds\n\r", - static_cast(timeMillis)); -#endif + FSFW_LOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis); } else if (displayMode == StopwatchDisplayMode::SECONDS) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Stopwatch: Operation took " << std::setprecision(3) << std::fixed - << timevalOperations::toDouble(elapsedTime) << " seconds" << std::endl; -#else - sif::printInfo("Stopwatch: Operation took %.3f seconds\n\r", - static_cast(timevalOperations::toDouble(elapsedTime))); -#endif + FSFW_LOGIT("Stopwatch::display: {} seconds elapsed\n", + static_cast(timevalOperations::toDouble(elapsedTime))); } } diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 756d7e508..891585937 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) { this->data = reinterpret_cast(const_cast(setAddress)); @@ -18,13 +18,7 @@ uint8_t SpacePacketBase::getPacketVersionNumber(void) { ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount) { if (data == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpacePacketBase::initSpacePacketHeader: Data pointer is invalid" << std::endl; -#else - sif::printWarning("SpacePacketBase::initSpacePacketHeader: Data pointer is invalid!\n"); -#endif -#endif + FSFW_LOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } // reset header to zero: diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 5df50cd79..5f8957091 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -4,17 +4,13 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {} CFDPPacket::~CFDPPacket() {} void CFDPPacket::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "CFDPPacket::print:" << std::endl; -#else - sif::printInfo("CFDPPacket::print:\n"); -#endif + FSFW_LOGI("{}", "CFDPPacket::print:\n"); arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 3af2b82ce..0786d2250 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -2,7 +2,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tcdistribution/PUSDistributorIF.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -22,10 +22,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusService " << (uint16_t)this->serviceId << ": performService returned with " - << (int16_t)result << std::endl; -#endif + FSFW_LOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result); return RETURN_FAILED; } return RETURN_OK; @@ -74,11 +71,8 @@ void PusServiceBase::handleRequestQueue() { // ": no new packet." << std::endl; break; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusServiceBase::performOperation: Service " << this->serviceId - << ": Error receiving packet. Code: " << std::hex << status << std::dec - << std::endl; -#endif + FSFW_LOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId, + status); } } } @@ -92,15 +86,13 @@ ReturnValue_t PusServiceBase::initialize() { if (result != RETURN_OK) { return result; } - AcceptsTelemetryIF* destService = - ObjectManager::instance()->get(packetDestination); - PUSDistributorIF* distributor = ObjectManager::instance()->get(packetSource); + auto* destService = ObjectManager::instance()->get(packetDestination); + auto* distributor = ObjectManager::instance()->get(packetSource); if (destService == nullptr or distributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId - << ": Configuration error. Make sure " - << "packetSource and packetDestination are defined correctly" << std::endl; -#endif + FSFW_LOGWT( + "ctor: Service {} | Make sure static packetSource and packetDestination " + "are defined correctly\n", + serviceId); return ObjectManagerIF::CHILD_INIT_FAILED; } this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue()); -- 2.34.1 From 83a2882f9d46df5bd480f3ac9e6f9d85dc7f4dcc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 00:09:13 +0200 Subject: [PATCH 03/16] it compiles again --- hal/src/fsfw_hal/common/gpio/GpioCookie.cpp | 21 +- .../devicehandlers/GyroL3GD20Handler.cpp | 23 +- .../devicehandlers/MgmLIS3MDLHandler.cpp | 60 ++--- .../devicehandlers/MgmRM3100Handler.cpp | 29 +-- hal/src/fsfw_hal/linux/CommandExecutor.cpp | 51 +---- hal/src/fsfw_hal/linux/CommandExecutor.h | 2 +- hal/src/fsfw_hal/linux/UnixFileGuard.cpp | 11 +- hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp | 36 +-- hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 22 +- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 55 ++--- hal/src/fsfw_hal/linux/utility.cpp | 16 +- src/fsfw/action/ActionHelper.cpp | 6 +- src/fsfw/cfdp/CFDPHandler.cpp | 2 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 6 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 2 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 2 +- src/fsfw/datapool/PoolDataSetBase.cpp | 8 +- src/fsfw/datapool/PoolEntry.cpp | 2 +- src/fsfw/datapool/PoolReadGuard.h | 2 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 2 +- .../datapoollocal/LocalDataPoolManager.cpp | 20 +- .../datapoollocal/LocalPoolDataSetBase.cpp | 4 +- .../datapoollocal/LocalPoolObjectBase.cpp | 12 +- src/fsfw/datapoollocal/LocalPoolVector.tpp | 4 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 26 +-- .../DeviceHandlerFailureIsolation.cpp | 7 +- src/fsfw/events/EventManagerIF.h | 2 +- src/fsfw/fdir/FailureIsolationBase.cpp | 9 +- src/fsfw/globalfunctions/arrayprinter.cpp | 4 +- src/fsfw/health/HealthHelper.cpp | 10 +- src/fsfw/health/HealthTable.cpp | 2 +- .../internalerror/InternalErrorReporter.cpp | 14 +- src/fsfw/ipc/MessageQueueMessage.cpp | 2 +- src/fsfw/memory/MemoryHelper.cpp | 2 +- .../monitoring/MonitoringMessageContent.h | 2 +- src/fsfw/objectmanager/ObjectManager.cpp | 22 +- src/fsfw/osal/common/TcpTmTcBridge.cpp | 8 +- src/fsfw/osal/common/TcpTmTcServer.cpp | 75 ++----- src/fsfw/osal/common/UdpTcPollingTask.cpp | 35 +-- src/fsfw/osal/common/UdpTmTcBridge.cpp | 10 +- src/fsfw/osal/common/tcpipCommon.cpp | 24 +- src/fsfw/osal/host/Clock.cpp | 32 +-- src/fsfw/osal/host/FixedTimeslotTask.cpp | 23 +- src/fsfw/osal/host/MessageQueue.cpp | 6 +- src/fsfw/osal/host/PeriodicTask.cpp | 10 +- src/fsfw/osal/host/QueueMapManager.cpp | 21 +- src/fsfw/osal/host/SemaphoreFactory.cpp | 14 +- src/fsfw/osal/host/TaskFactory.cpp | 8 +- src/fsfw/osal/linux/tcpipHelpers.cpp | 2 +- src/fsfw/parameters/ParameterHelper.cpp | 6 +- src/fsfw/parameters/ParameterWrapper.cpp | 8 +- src/fsfw/pus/CService201HealthCommanding.cpp | 15 +- src/fsfw/pus/CService201HealthCommanding.h | 2 +- .../pus/Service1TelecommandVerification.cpp | 20 +- src/fsfw/pus/Service20ParameterManagement.cpp | 39 +--- src/fsfw/pus/Service20ParameterManagement.h | 2 +- src/fsfw/pus/Service2DeviceAccess.cpp | 20 +- src/fsfw/pus/Service3Housekeeping.cpp | 35 +-- src/fsfw/pus/Service5EventReporting.cpp | 14 +- src/fsfw/pus/Service8FunctionManagement.cpp | 16 +- .../pus/servicepackets/Service20Packets.h | 13 +- src/fsfw/serialize/SerialBufferAdapter.cpp | 4 +- src/fsfw/serviceinterface/fmtWrapper.h | 70 ++++-- .../storagemanager/ConstStorageAccessor.cpp | 4 +- src/fsfw/storagemanager/LocalPool.cpp | 10 +- src/fsfw/storagemanager/StorageAccessor.cpp | 2 +- src/fsfw/subsystem/SubsystemBase.cpp | 4 +- src/fsfw/tasks/FixedSlotSequence.cpp | 10 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 14 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 54 +---- src/fsfw/tcdistribution/PUSDistributor.cpp | 43 +--- src/fsfw/tcdistribution/TcDistributor.cpp | 4 +- src/fsfw/timemanager/Stopwatch.cpp | 6 +- src/fsfw/tmtcpacket/SpacePacketBase.cpp | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 24 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h | 2 +- .../tmtcpacket/pus/tc/TcPacketPusBase.cpp | 8 +- .../tmtcpacket/pus/tc/TcPacketStoredBase.cpp | 24 +- .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 2 +- .../tmtcpacket/pus/tc/TcPacketStoredPus.cpp | 20 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 18 +- .../tmtcpacket/pus/tm/TmPacketStoredBase.cpp | 14 +- .../tmtcservices/CommandingServiceBase.cpp | 33 +-- src/fsfw/tmtcservices/PusServiceBase.cpp | 8 +- src/fsfw/tmtcservices/SpacePacketParser.cpp | 16 +- src/fsfw/tmtcservices/SpacePacketParser.h | 4 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 83 +++---- src/fsfw/tmtcservices/TmTcBridge.h | 10 +- .../tmtcservices/VerificationReporter.cpp | 48 ++-- .../integration/assemblies/TestAssembly.cpp | 9 +- .../integration/devices/TestDeviceHandler.cpp | 210 ++++-------------- .../integration/devices/TestEchoComIF.cpp | 28 +-- .../internal/InternalUnitTester.cpp | 13 +- .../fsfw_tests/internal/UnittDefinitions.cpp | 10 +- .../fsfw_tests/internal/UnittDefinitions.h | 2 +- 96 files changed, 563 insertions(+), 1210 deletions(-) diff --git a/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp b/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp index 4c4b4d145..43c764c0e 100644 --- a/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp +++ b/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp @@ -1,30 +1,19 @@ #include "fsfw_hal/common/gpio/GpioCookie.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" -GpioCookie::GpioCookie() {} +GpioCookie::GpioCookie() = default; ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { if (gpioConfig == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; -#else - sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n"); -#endif + FSFW_LOGW("addGpio: gpioConfig is nullpointer\n"); return HasReturnvaluesIF::RETURN_FAILED; } auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { auto statusPair = gpioMap.emplace(gpioId, gpioConfig); - if (statusPair.second == false) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map" - << std::endl; -#else - sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId); -#endif -#endif + if (!statusPair.second) { + FSFW_LOGW("addGpio: Failed to add GPIO {} to GPIO map\n", gpioId); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp index 94e1331c6..c63de9ed2 100644 --- a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp @@ -60,16 +60,8 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t return buildCommandFromCommand(*id, nullptr, 0); } default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 /* Might be a configuration error. */ - sif::warning << "GyroL3GD20Handler::buildTransitionDeviceCommand: " - "Unknown internal state!" - << std::endl; -#else - sif::printDebug( - "GyroL3GD20Handler::buildTransitionDeviceCommand: " - "Unknown internal state!\n"); -#endif + FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n"); return HasReturnvaluesIF::RETURN_OK; } return HasReturnvaluesIF::RETURN_OK; @@ -192,17 +184,8 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, if (periodicPrintout) { if (debugDivider.checkAndIncrement()) { /* Set terminal to utf-8 if there is an issue with micro printout. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; -#else - sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n"); - sif::printInfo("X: %f\n", angVelocX); - sif::printInfo("Y: %f\n", angVelocY); - sif::printInfo("Z: %f\n", angVelocZ); -#endif + FSFW_LOGI("GyroHandlerL3GD20H: Angular velocities (deg/s):\nX {} | Y {} | Z {}\n", + angVelocX, angVelocY, angVelocZ); } } diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 644b488dd..ff501368c 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -76,21 +76,16 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t } default: { /* might be a configuration error. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" - << std::endl; -#else - sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n"); return HasReturnvaluesIF::RETURN_OK; } } - return buildCommandFromCommand(*id, NULL, 0); + return buildCommandFromCommand(*id, nullptr, 0); } uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) { command |= (1 << MGMLIS3MDL::RW_BIT); - if (continuousCom == true) { + if (continuousCom) { command |= (1 << MGMLIS3MDL::MS_BIT); } return command; @@ -98,7 +93,7 @@ uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) { uint8_t MgmLIS3MDLHandler::writeCommand(uint8_t command, bool continuousCom) { command &= ~(1 << MGMLIS3MDL::RW_BIT); - if (continuousCom == true) { + if (continuousCom) { command |= (1 << MGMLIS3MDL::MS_BIT); } return command; @@ -186,13 +181,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, // Check validity by checking config registers if (start[1] != registers[0] or start[2] != registers[1] or start[3] != registers[2] or start[4] != registers[3] or start[5] != registers[4]) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl; -#else - sif::printWarning("MGMHandlerLIS3MDL::scanForReply: Invalid registers!\n"); -#endif -#endif + FSFW_LOGW("scanForReply: Invalid registers\n"); return DeviceHandlerIF::INVALID_DATA; } if (mode == _MODE_START_UP) { @@ -210,17 +199,9 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, *foundId = getPendingCommand(); if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) { if (start[1] != MGMLIS3MDL::DEVICE_ID) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "MGMHandlerLIS3MDL::scanForReply: " - "Device identification failed!" - << std::endl; -#else - sif::printWarning( - "MGMHandlerLIS3MDL::scanForReply: " - "Device identification failed!\n"); -#endif -#endif + FSFW_FLOGW( + "scanForReply: Device identification failed, found ID {} not equal to expected {}\n", + start[1], MGMLIS3MDL::DEVICE_ID); return DeviceHandlerIF::INVALID_DATA; } @@ -268,19 +249,10 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons if (periodicPrintout) { if (debugDivider.checkAndIncrement()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MGMHandlerLIS3: Magnetic field strength in" - " microtesla:" - << std::endl; - sif::info << "X: " << mgmX << " uT" << std::endl; - sif::info << "Y: " << mgmY << " uT" << std::endl; - sif::info << "Z: " << mgmZ << " uT" << std::endl; -#else - sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n"); - sif::printInfo("X: %f uT\n", mgmX); - sif::printInfo("Y: %f uT\n", mgmY); - sif::printInfo("Z: %f uT\n", mgmZ); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ + FSFW_LOGI( + "MGMHandlerLIS3: Magnetic field strength in" + " microtesla (uT):\nX {} | Y {} | Z {}\n", + mgmX, mgmY, mgmZ); } } @@ -311,15 +283,11 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons } case MGMLIS3MDL::READ_TEMPERATURE: { - int16_t tempValueRaw = packet[2] << 8 | packet[1]; + auto tempValueRaw = static_cast((packet[2] << 8) | packet[1]); float tempValue = 25.0 + ((static_cast(tempValueRaw)) / 8.0); if (periodicPrintout) { if (debugDivider.check()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl; -#else - sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n"); -#endif + FSFW_LOGI("MGMHandlerLIS3: Temperature: {} C\n", tempValue); } } diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index f9929d638..529659003 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -81,18 +81,8 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t * break; } default: -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 // Might be a configuration error - sif::warning << "MgmRM3100Handler::buildTransitionDeviceCommand: " - "Unknown internal state" - << std::endl; -#else - sif::printWarning( - "MgmRM3100Handler::buildTransitionDeviceCommand: " - "Unknown internal state\n"); -#endif -#endif + FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n"); return HasReturnvaluesIF::RETURN_OK; } @@ -335,19 +325,10 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { if (periodicPrintout) { if (debugDivider.checkAndIncrement()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MgmRM3100Handler: Magnetic field strength in" - " microtesla:" - << std::endl; - sif::info << "X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl; -#else - sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n"); - sif::printInfo("X: %f uT\n", fieldStrengthX); - sif::printInfo("Y: %f uT\n", fieldStrengthY); - sif::printInfo("Z: %f uT\n", fieldStrengthZ); -#endif + FSFW_LOGI( + "MgmRM3100Handler: Magnetic field strength in" + " microtesla(uT)\nX {} | Y {} | Z {}\n", + fieldStrengthX, fieldStrengthY, fieldStrengthZ); } } diff --git a/hal/src/fsfw_hal/linux/CommandExecutor.cpp b/hal/src/fsfw_hal/linux/CommandExecutor.cpp index 49c44ebf2..539bb3519 100644 --- a/hal/src/fsfw_hal/linux/CommandExecutor.cpp +++ b/hal/src/fsfw_hal/linux/CommandExecutor.cpp @@ -59,22 +59,16 @@ ReturnValue_t CommandExecutor::close() { return HasReturnvaluesIF::RETURN_OK; } -void CommandExecutor::printLastError(std::string funcName) const { +void CommandExecutor::printLastError(const std::string& funcName) const { if (lastError != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << funcName << " pclose failed with code " << lastError << ": " - << strerror(lastError) << std::endl; -#else - sif::printError("%s pclose failed with code %d: %s\n", funcName, lastError, - strerror(lastError)); -#endif + FSFW_FLOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError)); } } -void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer, - DynamicFIFO* sizesFifo) { - this->ringBuffer = ringBuffer; - this->sizesFifo = sizesFifo; +void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer_, + DynamicFIFO* sizesFifo_) { + this->ringBuffer = ringBuffer_; + this->sizesFifo = sizesFifo_; } ReturnValue_t CommandExecutor::check(bool& replyReceived) { @@ -102,23 +96,13 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { ssize_t readBytes = read(currentFd, readVec.data(), readVec.size()); if (readBytes == 0) { // Should not happen -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CommandExecutor::check: No bytes read " - "after poll event.." - << std::endl; -#else - sif::printWarning("CommandExecutor::check: No bytes read after poll event..\n"); -#endif + FSFW_LOGWT("CommandExecutor::check: No bytes read after poll event\n"); break; } else if (readBytes > 0) { replyReceived = true; if (printOutput) { // It is assumed the command output is line terminated -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << currentCmd << " | " << readVec.data(); -#else - sif::printInfo("%s | %s", currentCmd, readVec.data()); -#endif + FSFW_LOGIT("{} | {}", currentCmd, readVec.data()); } if (ringBuffer != nullptr) { ringBuffer->writeData(reinterpret_cast(readVec.data()), readBytes); @@ -130,20 +114,11 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { } } else { // Should also not happen -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CommandExecutor::check: Error " << errno << ": " << strerror(errno) - << std::endl; -#else - sif::printWarning("CommandExecutor::check: Error %d: %s\n", errno, strerror(errno)); -#endif + FSFW_LOGW("check: Error {} | {}\n", errno, strerror(errno)); } } if (waiter.revents & POLLERR) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CommandExecuter::check: Poll error" << std::endl; -#else - sif::printWarning("CommandExecuter::check: Poll error\n"); -#endif + FSFW_LOGW("check: Poll error\n"); return COMMAND_ERROR; } if (waiter.revents & POLLHUP) { @@ -183,11 +158,7 @@ ReturnValue_t CommandExecutor::executeBlocking() { while (fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) { std::string output(readVec.data()); if (printOutput) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << currentCmd << " | " << output; -#else - sif::printInfo("%s | %s", currentCmd, output); -#endif + FSFW_LOGI("{} | {}", currentCmd, output); } if (ringBuffer != nullptr) { ringBuffer->writeData(reinterpret_cast(output.data()), output.size()); diff --git a/hal/src/fsfw_hal/linux/CommandExecutor.h b/hal/src/fsfw_hal/linux/CommandExecutor.h index 90662c0fd..be1c180c9 100644 --- a/hal/src/fsfw_hal/linux/CommandExecutor.h +++ b/hal/src/fsfw_hal/linux/CommandExecutor.h @@ -93,7 +93,7 @@ class CommandExecutor { States getCurrentState() const; int getLastError() const; - void printLastError(std::string funcName) const; + void printLastError(const std::string& funcName) const; /** * Assign a ring buffer and a FIFO which will be filled by the executor with the output diff --git a/hal/src/fsfw_hal/linux/UnixFileGuard.cpp b/hal/src/fsfw_hal/linux/UnixFileGuard.cpp index 412938158..ed7dd215e 100644 --- a/hal/src/fsfw_hal/linux/UnixFileGuard.cpp +++ b/hal/src/fsfw_hal/linux/UnixFileGuard.cpp @@ -14,15 +14,8 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags, } *fileDescriptor = open(device.c_str(), flags); if (*fileDescriptor < 0) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << diagnosticPrefix << ": Opening device failed with error code " << errno << ": " - << strerror(errno) << std::endl; -#else - sif::printWarning("%s: Opening device failed with error code %d: %s\n", diagnosticPrefix, errno, - strerror(errno)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("{} | Opening device failed with error code {} | {}\n", diagnosticPrefix, errno, + strerror(errno)); openStatus = OPEN_FILE_FAILED; } } diff --git a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp index a509dad1e..01d19c85b 100644 --- a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -26,7 +26,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; if (cookie == nullptr) { - FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n"); + FSFW_FLOGE("{}", "initializeInterface: Invalid cookie\n"); return NULLPOINTER; } auto* i2cCookie = dynamic_cast(cookie); @@ -38,14 +38,14 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance); if (not statusPair.second) { - FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n", - i2cAddress); + FSFW_FLOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; } - FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress); + FSFW_FLOGE("initializeInterface: Device with address {} already in use\n", i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } @@ -55,7 +55,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s std::string deviceFile; if (sendData == nullptr) { - FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n"); + FSFW_FLOGW("{}", "sendMessage: Send Data is nullptr\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -65,14 +65,14 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n"); + FSFW_FLOGWT("{}", "sendMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n"); + FSFW_FLOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -87,8 +87,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (write(fd, sendData, sendLen) != static_cast(sendLen)) { - FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno, - strerror(errno)); + FSFW_FLOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } @@ -112,7 +112,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n"); + FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n"); i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } @@ -120,8 +120,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap", - i2cAddress); + FSFW_FLOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap", + i2cAddress); i2cDeviceMapIter->second.replyLen = 0; return HasReturnvaluesIF::RETURN_FAILED; } @@ -141,7 +141,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe ssize_t readLen = read(fd, replyBuffer, requestLen); if (readLen != static_cast(requestLen)) { - FSFW_LOGWT( + FSFW_FLOGWT( "requestReceiveMessage: Reading from I2C device failed with error code " "{} | {}\nRead only {} from {} bytes\n", errno, strerror(errno), readLen, requestLen); @@ -161,15 +161,15 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n"); + FSFW_FLOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n", - i2cAddress); + FSFW_FLOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); @@ -181,8 +181,8 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, int* fileDescriptor) { if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) { - FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno, - strerror(errno)); + FSFW_FLOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index e98b9de8b..51ee797cb 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -19,7 +19,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SystemObject(objectId), gpioComIF(gpioComIF) { if (gpioComIF == nullptr) { - FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n"); + FSFW_FLOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n"); } spiMutex = MutexFactory::instance()->createMutex(); @@ -40,7 +40,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { SpiInstance spiInstance(bufferSize); auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance); if (not statusPair.second) { - FSFW_LOGWT( + FSFW_FLOGWT( "SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device " "map\n", spiAddress); @@ -50,7 +50,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { to the SPI driver transfer struct */ spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data()); } else { - FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n"); + FSFW_FLOGWT("{}", "initializeInterface: SPI address already exists\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -123,7 +123,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (sendLen > spiCookie->getMaxBufferSize()) { - FSFW_LOGW( + FSFW_FLOGW( "sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n", spiCookie->getMaxBufferSize(), sendLen); return DeviceCommunicationIF::TOO_MUCH_DATA; @@ -173,12 +173,12 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { - FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n"); + FSFW_FLOGET("{}", "sendMessage: Failed to lock mutex\n"); return result; } result = gpioComIF->pullLow(gpioId); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n"); + FSFW_FLOGW("{}", "sendMessage: Pulling low CS pin failed\n"); return result; } } @@ -197,7 +197,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const } else { /* We write with a blocking half-duplex transfer here */ if (write(fileDescriptor, sendData, sendLen) != static_cast(sendLen)) { - FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n"); + FSFW_FLOGET("{}", "sendMessage: Half-Duplex write operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } } @@ -206,7 +206,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { - FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n"); + FSFW_FLOGWT("{}", "sendMessage: Failed to unlock mutex\n"); return result; } } @@ -248,14 +248,14 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { - FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n"); + FSFW_FLOGW("{}", "getSendSuccess: Failed to lock mutex\n"); return result; } gpioComIF->pullLow(gpioId); } if (read(fileDescriptor, rxBuf, readSize) != static_cast(readSize)) { - FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n"); + FSFW_FLOGW("{}", "sendMessage: Half-Duplex read operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } @@ -263,7 +263,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { - FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n"); + FSFW_FLOGW("{}", "getSendSuccess: Failed to unlock mutex\n"); return result; } } diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 6f042efaf..49d4de766 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -25,7 +25,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n"); + FSFW_FLOGE("{}", "initializeInterface: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -41,11 +41,12 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { UartElements uartElements = {fileDescriptor, std::vector(maxReplyLen), 0}; auto status = uartDeviceMap.emplace(deviceFile, uartElements); if (!status.second) { - FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile); + FSFW_FLOGW("initializeInterface: Failed to insert device {} to UART device map\n", + deviceFile); return RETURN_FAILED; } } else { - FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile); + FSFW_FLOGW("initializeInterface: UART device {} already in use\n", deviceFile); return RETURN_FAILED; } @@ -65,14 +66,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { int fd = open(deviceFile.c_str(), flags); if (fd < 0) { - FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile, - errno, strerror(errno)); + FSFW_FLOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile, + errno, strerror(errno)); return fd; } /* Read in existing settings */ if (tcgetattr(fd, &options) != 0) { - FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno)); + FSFW_FLOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno)); return fd; } @@ -93,8 +94,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { /* Save option settings */ if (tcsetattr(fd, TCSANOW, &options) != 0) { - FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno, - strerror(errno)); + FSFW_FLOGW("configureUartPort: Failed to set options with error {} | {}\n", errno, + strerror(errno)); return fd; } return fd; @@ -146,8 +147,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook options->c_cflag |= CS8; break; default: - FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n", - static_cast(uartCookie->getBitsPerWord())); + FSFW_FLOGW("setDatasizeOptions: Invalid size {} specified\n", + static_cast(uartCookie->getBitsPerWord())); break; } } @@ -300,7 +301,7 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki break; #endif // ! __APPLE__ default: - FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n"); + FSFW_FLOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n"); break; } } @@ -315,27 +316,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, } if (sendData == nullptr) { - FSFW_LOGWT("{}", "sendMessage: Send data is nullptr"); + FSFW_FLOGWT("{}", "sendMessage: Send data is nullptr"); return RETURN_FAILED; } auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n"); + FSFW_FLOGWT("{}", "sendMessage: Invalid UART Cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile); + FSFW_FLOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } fd = uartDeviceMapIter->second.fileDescriptor; if (write(fd, sendData, sendLen) != static_cast(sendLen)) { - FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno)); + FSFW_FLOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno)); return RETURN_FAILED; } @@ -350,7 +351,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n"); + FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -363,7 +364,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile); + FSFW_FLOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -392,7 +393,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (currentBytesRead >= maxReplySize) { // Overflow risk. Emit warning, trigger event and break. If this happens, // the reception buffer is not large enough or data is not polled often enough. - FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n"); + FSFW_FLOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n"); result = UART_RX_BUFFER_TOO_SMALL; break; } else { @@ -403,7 +404,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (bytesRead < 0) { // EAGAIN: No data available in non-blocking mode if (errno != EAGAIN) { - FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno)); + FSFW_FLOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno)); return RETURN_FAILED; } @@ -423,7 +424,7 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow if (requestLen > uartCookie.getMaxReplyLen()) { - FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n"); + FSFW_FLOGW("{}", "requestReceiveMessage: Next read would cause overflow\n"); return UART_RX_BUFFER_TOO_SMALL; } ssize_t bytesRead = read(fd, bufferPtr, requestLen); @@ -431,8 +432,8 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi return RETURN_FAILED; } else if (bytesRead != static_cast(requestLen)) { if (uartCookie.isReplySizeFixed()) { - FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead, - requestLen); + FSFW_FLOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead, + requestLen); return RETURN_FAILED; } } @@ -446,14 +447,14 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie"); + FSFW_FLOGWT("{}", "readReceivedMessage: Invalid uart cookie"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile); + FSFW_FLOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -471,7 +472,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n"); + FSFW_FLOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -489,7 +490,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n"); + FSFW_FLOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -507,7 +508,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n"); + FSFW_FLOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); diff --git a/hal/src/fsfw_hal/linux/utility.cpp b/hal/src/fsfw_hal/linux/utility.cpp index 95d3f0d77..bfaaea9a5 100644 --- a/hal/src/fsfw_hal/linux/utility.cpp +++ b/hal/src/fsfw_hal/linux/utility.cpp @@ -3,21 +3,11 @@ #include #include -#include "fsfw/FSFW.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" void utility::handleIoctlError(const char* const customPrintout) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 if (customPrintout != nullptr) { - sif::warning << customPrintout << std::endl; + FSFW_LOGW(customPrintout); } - sif::warning << "handleIoctlError: Error code " << errno << ", " << strerror(errno) << std::endl; -#else - if (customPrintout != nullptr) { - sif::printWarning("%s\n", customPrintout); - } - sif::printWarning("handleIoctlError: Error code %d, %s\n", errno, strerror(errno)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGW("Error code {} | {}\n", errno, strerror(errno)); } diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index 13cc6fdc4..e0d570279 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -28,7 +28,7 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { } if (queueToUse == nullptr) { - FSFW_LOGW("{}", "initialize: No queue set\n"); + FSFW_FLOGW("{}", "initialize: No queue set\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -90,7 +90,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("{}", "reportData: Getting free element from IPC store failed\n"); + FSFW_FLOGWT("{}", "reportData: Getting free element from IPC store failed\n"); return result; } result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); @@ -125,7 +125,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("{}", "reportData: Adding data to IPC store failed\n"); + FSFW_FLOGWT("{}", "reportData: Adding data to IPC store failed\n"); return result; } diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp index 7c23c1334..3b2c8ebaf 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CFDPHandler.cpp @@ -29,7 +29,7 @@ ReturnValue_t CFDPHandler::initialize() { } ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { - FSFW_LOGDT("{}", "CFDPHandler::handleRequest\n"); + FSFW_FLOGDT("{}", "CFDPHandler::handleRequest\n"); // TODO read out packet from store using storeId diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index 3e77f2211..c9d2b5bcd 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -50,9 +50,9 @@ ReturnValue_t EofPduDeserializer::parseData() { if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { EntityIdTlv* tlvPtr = info.getFaultLoc(); if (tlvPtr == nullptr) { - FSFW_LOGW("{}", - "parseData: Ca not deserialize fault location," - " given TLV pointer invalid\n"); + FSFW_FLOGW("{}", + "parseData: Ca not deserialize fault location," + " given TLV pointer invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness); diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index 24b04b4a9..98391d415 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -7,7 +7,7 @@ cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("{}", "cfdp::VarLenField: Setting value failed\n"); + FSFW_FLOGW("{}", "cfdp::VarLenField: Setting value failed\n"); } } diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 528c482b8..0f4dbf209 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -128,7 +128,7 @@ class FilestoreTlvBase : public TlvIF { } void secondFileNameMissing() const { - FSFW_LOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n"); + FSFW_FLOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n"); } FilestoreActionCode getActionCode() const { return actionCode; } diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index 891a95e2c..93d2ab246 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -17,15 +17,15 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { return HasReturnvaluesIF::RETURN_FAILED; } if (state != States::STATE_SET_UNINITIALISED) { - FSFW_LOGW("{}", "registerVariable: Call made in wrong position\n"); + FSFW_FLOGW("{}", "registerVariable: Call made in wrong position\n"); return DataSetIF::DATA_SET_UNINITIALISED; } if (variable == nullptr) { - FSFW_LOGW("{}", "registerVariable: Pool variable is nullptr\n"); + FSFW_FLOGW("{}", "registerVariable: Pool variable is nullptr\n"); return DataSetIF::POOL_VAR_NULL; } if (fillCount >= maxFillCount) { - FSFW_LOGW("{}", "registerVariable: DataSet is full\n"); + FSFW_FLOGW("{}", "registerVariable: DataSet is full\n"); return DataSetIF::DATA_SET_FULL; } registeredVariables[fillCount] = variable; @@ -47,7 +47,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l state = States::STATE_SET_WAS_READ; unlockDataPool(); } else { - FSFW_LOGWT("{}", "read: Call made in wrong position. commit call might be missing\n"); + FSFW_FLOGWT("{}", "read: Call made in wrong position. commit call might be missing\n"); result = SET_WAS_ALREADY_READ; } diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp index c52f1a0fa..97b23d716 100644 --- a/src/fsfw/datapool/PoolEntry.cpp +++ b/src/fsfw/datapool/PoolEntry.cpp @@ -68,7 +68,7 @@ void PoolEntry::print() { } else { validString = "Invalid"; } - FSFW_LOGI("PoolEntry Info. Validity {}\n", validString); + FSFW_FLOGI("PoolEntry Info. Validity {}\n", validString); arrayprinter::print(reinterpret_cast(address), getByteSize()); } diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h index d9c42fa76..8520bc1a2 100644 --- a/src/fsfw/datapool/PoolReadGuard.h +++ b/src/fsfw/datapool/PoolReadGuard.h @@ -17,7 +17,7 @@ class PoolReadGuard { if (readObject != nullptr) { readResult = readObject->read(timeoutType, mutexTimeout); if (readResult != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("{}", "ctor: Read failed\n"); + FSFW_FLOGW("{}", "ctor: Read failed\n"); } } } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index 8650c29e7..930ccad11 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -166,7 +166,7 @@ class HasLocalDataPoolIF { * @return */ virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { - FSFW_LOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n"); + FSFW_FLOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n"); return nullptr; } }; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 94da2ac98..5bff44639 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -695,7 +695,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true); if (result != HasReturnvaluesIF::RETURN_OK) { /* Configuration error */ - FSFW_LOGWT("{}", "performHkOperation: HK generation failed"); + FSFW_FLOGWT("{}", "performHkOperation: HK generation failed"); } } @@ -852,23 +852,9 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, } if (outputType == sif::OutputTypes::OUT_WARNING) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" << std::setw(8) - << std::setfill('0') << std::hex << objectId << " | " << errorPrint << std::dec - << std::setfill(' ') << std::endl; -#else - sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", functionName, objectId, - errorPrint); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_FLOGWT("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); } else if (outputType == sif::OutputTypes::OUT_ERROR) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" << std::setw(8) - << std::setfill('0') << std::hex << objectId << " | " << errorPrint << std::dec - << std::setfill(' ') << std::endl; -#else - sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", functionName, objectId, - errorPrint); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_FLOGET("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); } #endif /* #if FSFW_VERBOSE_LEVEL >= 1 */ } diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index cd533cd99..ed534896a 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -16,7 +16,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t : PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if (hkOwner == nullptr) { // Configuration error. - FSFW_LOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n"); + FSFW_FLOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n"); return; } AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -179,7 +179,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("{}", "serializeLocalPoolIds: Serialization error\n"); + FSFW_FLOGW("{}", "serializeLocalPoolIds: Serialization error\n"); return result; } } diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 5d0a3068f..4a920664e 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -11,10 +11,10 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { - FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); + FSFW_FLOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } if (hkOwner == nullptr) { - FSFW_LOGET("{}", "ctor: Supplied pool owner is a invalid\n"); + FSFW_FLOGET("{}", "ctor: Supplied pool owner is a invalid\n"); return; } AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -29,11 +29,11 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { - FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); + FSFW_FLOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } auto* hkOwner = ObjectManager::instance()->get(poolOwner); if (hkOwner == nullptr) { - FSFW_LOGWT( + FSFW_FLOGWT( "ctor: The supplied pool owner {:#08x} did not implement the correct interface " "HasLocalDataPoolIF\n", poolOwner); @@ -94,6 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return errMsg = "Unknown error code"; } - FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, - objectId, lpId); + FSFW_FLOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, + objectId, lpId); } diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index 8112f92ca..e26d1fbbb 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -98,7 +98,7 @@ inline T& LocalPoolVector::operator [](size_t i) { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. - FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); + FSFW_FLOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } @@ -109,7 +109,7 @@ inline const T& LocalPoolVector::operator [](size_t i) const { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. - FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); + FSFW_FLOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index e51043d92..1ca03a31b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -156,9 +156,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Raw receiver object ID set but no valid object found."); - FSFW_LOGE("{}", - "Make sure the raw receiver object is set up properly " - "and implements AcceptsDeviceResponsesIF"); + FSFW_FLOGE("{}", + "Make sure the raw receiver object is set up properly " + "and implements AcceptsDeviceResponsesIF"); return ObjectManagerIF::CHILD_INIT_FAILED; } defaultRawReceiver = rawReceiver->getDeviceQueue(); @@ -170,9 +170,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); - FSFW_LOGE("{}", - "Make sure the power switcher object is set up " - "properly and implements PowerSwitchIF\n"); + FSFW_FLOGE("{}", + "Make sure the power switcher object is set up " + "properly and implements PowerSwitchIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -755,9 +755,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD printWarningOrError(sif::OutputTypes::OUT_ERROR, "parseReply", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); - FSFW_LOGW("{}", - "DeviceHandlerBase::parseReply: foundLen is 0! " - "Packet parsing will be stuck\n"); + FSFW_FLOGW("{}", + "DeviceHandlerBase::parseReply: foundLen is 0! " + "Packet parsing will be stuck\n"); } break; } @@ -1462,11 +1462,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch } if (errorType == sif::OutputTypes::OUT_WARNING) { - FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), - errorPrint); + FSFW_FLOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } else if (errorType == sif::OutputTypes::OUT_ERROR) { - FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), - errorPrint); + FSFW_FLOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } } diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index 185de217a..f5285f80b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -163,7 +163,7 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGE("{}", "initialize: Could not initialize FailureIsolationBase\n"); + FSFW_FLOGE("{}", "initialize: Could not initialize FailureIsolationBase\n"); return result; } auto* power = ObjectManager::instance()->get(powerConfirmationId); @@ -239,10 +239,7 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(EventMessage* ev if (owner == nullptr) { // Configuration error. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "DeviceHandlerFailureIsolation::" - << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; -#endif + FSFW_LOGE("isFdirInActionOrAreWeFaulty: Owner not set\n"); return false; } diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index 2ab9af411..5e2f3b548 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -41,7 +41,7 @@ class EventManagerIF { if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) { auto* eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (eventmanager == nullptr) { - FSFW_LOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n"); + FSFW_FLOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n"); return; } eventmanagerQueue = eventmanager->getEventReportQueue(); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 39fbe0221..b1f731d19 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -20,7 +20,7 @@ FailureIsolationBase::~FailureIsolationBase() { ReturnValue_t FailureIsolationBase::initialize() { auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { - FSFW_LOGE("{}", "initialize: Event Manager has not been initialized\n"); + FSFW_FLOGE("{}", "initialize: Event Manager has not been initialized\n"); return RETURN_FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); @@ -34,7 +34,7 @@ ReturnValue_t FailureIsolationBase::initialize() { } owner = ObjectManager::instance()->get(ownerId); if (owner == nullptr) { - FSFW_LOGE( + FSFW_FLOGE( "FailureIsolationBase::intialize: Owner object {:#08x} invalid. " "Does it implement HasHealthIF?\n", ownerId); @@ -44,8 +44,9 @@ ReturnValue_t FailureIsolationBase::initialize() { if (faultTreeParent != objects::NO_OBJECT) { auto* parentIF = ObjectManager::instance()->get(faultTreeParent); if (parentIF == nullptr) { - FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", - faultTreeParent); + FSFW_FLOGW( + "intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", + faultTreeParent); return ObjectManagerIF::CHILD_INIT_FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); diff --git a/src/fsfw/globalfunctions/arrayprinter.cpp b/src/fsfw/globalfunctions/arrayprinter.cpp index c8de86102..c434bc558 100644 --- a/src/fsfw/globalfunctions/arrayprinter.cpp +++ b/src/fsfw/globalfunctions/arrayprinter.cpp @@ -8,11 +8,11 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool printInfo, size_t maxCharPerLine) { if (size == 0) { - FSFW_LOGI("{}", "Size is zero, nothing to print\n"); + FSFW_FLOGI("{}", "Size is zero, nothing to print\n"); return; } - FSFW_LOGI("Printing data with size {}:\n", size); + FSFW_FLOGI("Printing data with size {}:\n", size); if (type == OutputType::HEX) { arrayprinter::printHex(data, size, maxCharPerLine); } else if (type == OutputType::DEC) { diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 954a1e19d..22ca76ce4 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -35,12 +35,12 @@ ReturnValue_t HealthHelper::initialize() { eventSender = ObjectManager::instance()->get(objectId); if (healthTable == nullptr) { - FSFW_LOGE("{}", "initialize: Health table object needs to be created in factory\n"); + FSFW_FLOGE("{}", "initialize: Health table object needs to be created in factory\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } if (eventSender == nullptr) { - FSFW_LOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n"); + FSFW_FLOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -69,7 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); + FSFW_FLOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); } } @@ -86,7 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", - objectId); + FSFW_FLOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", + objectId); } } diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index e9358bd7f..850e647b3 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -69,7 +69,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { ReturnValue_t result = SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("{}", "printAll: Serialization of health table failed\n"); + FSFW_FLOGW("{}", "printAll: Serialization of health table failed\n"); return; } for (const auto& health : healthMap) { diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index fa16ec3f6..86a6cde48 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -34,18 +34,8 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { #if FSFW_VERBOSE_LEVEL >= 1 if (diagnosticPrintout) { if ((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "InternalErrorReporter::performOperation: Errors " - << "occured!" << std::endl; - sif::debug << "Queue errors: " << newQueueHits << std::endl; - sif::debug << "TM errors: " << newTmHits << std::endl; - sif::debug << "Store errors: " << newStoreHits << std::endl; -#else - sif::printDebug("InternalErrorReporter::performOperation: Errors occured!\n"); - sif::printDebug("Queue errors: %lu\n", static_cast(newQueueHits)); - sif::printDebug("TM errors: %lu\n", static_cast(newTmHits)); - sif::printDebug("Store errors: %lu\n", static_cast(newStoreHits)); -#endif + FSFW_LOGW("performOperation: Errors occured\nQueue {} | TM {} | Store {}\n", newQueueHits, + newTmHits, newStoreHits); } } #endif diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index bbaddda1a..4b3477fc3 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -15,7 +15,7 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) memcpy(this->getData(), data, size); this->messageSize = this->HEADER_SIZE + size; } else { - FSFW_LOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n"); + FSFW_FLOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n"); memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); this->messageSize = this->HEADER_SIZE; } diff --git a/src/fsfw/memory/MemoryHelper.cpp b/src/fsfw/memory/MemoryHelper.cpp index 34cd30171..0a3bf779e 100644 --- a/src/fsfw/memory/MemoryHelper.cpp +++ b/src/fsfw/memory/MemoryHelper.cpp @@ -17,7 +17,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { lastSender = message->getSender(); lastCommand = message->getCommand(); if (busy) { - FSFW_LOGW("{}", "MemoryHelper: Busy\n"); + FSFW_FLOGW("{}", "MemoryHelper: Busy\n"); } switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index ebb473988..9096fdfd3 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -81,7 +81,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); if (timeStamper == nullptr) { - FSFW_LOGET("{}", "checkAndSetStamper: Stamper not found\n"); + FSFW_FLOGET("{}", "checkAndSetStamper: Stamper not found\n"); return false; } } diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 86fe8d182..83d193493 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -38,8 +38,8 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { #endif return this->RETURN_OK; } else { - FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", - static_cast(id)); + FSFW_FLOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", + static_cast(id)); // This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); } @@ -54,7 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { #endif return RETURN_OK; } else { - FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id); + FSFW_FLOGW("removeObject: Requested object {:#08x} not found\n", id); return NOT_FOUND; } } @@ -78,27 +78,27 @@ void ObjectManager::initialize() { result = it.second->initialize(); if (result != RETURN_OK) { object_id_t var = it.first; - FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, - result); + FSFW_FLOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, + result); errorCount++; } } if (errorCount > 0) { - FSFW_LOGWT("{}", "initialize: Counted failed initializations\n"); + FSFW_FLOGWT("{}", "initialize: Counted failed initializations\n"); } // Init was successful. Now check successful interconnections. errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if (result != RETURN_OK) { - FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, - result); + FSFW_FLOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, + result); errorCount++; } } if (errorCount > 0) { - FSFW_LOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n", - errorCount); + FSFW_FLOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n", + errorCount); } } @@ -106,7 +106,7 @@ void ObjectManager::printList() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info("ObjectManager: Object List contains:\n"); for (auto const& it : objectList) { - sif::info("{:#08x} | {:#08x}\n", it.first, it.second); + sif::info("{:#08x} | {:#08x}\n", it.first, fmt::ptr(it.second)); } #endif } diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index 4b2bea738..b490082e2 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -21,17 +21,13 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ob : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); // Connection is always up, TM is requested by connecting to server and receiving packets - registerCommConnect(); + TmTcBridge::registerCommConnect(); } ReturnValue_t TcpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; -#else - sif::printError("TcpTmTcBridge::initialize: TmTcBridge initialization failed!\n"); -#endif + FSFW_LOGE("TcpTmTcBridge::initialize: TmTcBridge initialization failed\n"); return result; } diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index 2e6910c5a..b45013fd3 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -8,7 +8,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/TaskFactory.h" #include "fsfw/tmtcservices/SpacePacketParser.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -54,11 +54,7 @@ ReturnValue_t TcpTmTcServer::initialize() { } tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (tcStore == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcpTmTcServer::initialize: TC store uninitialized!" << std::endl; -#else - sif::printError("TcpTmTcServer::initialize: TC store uninitialized!\n"); -#endif + FSFW_LOGE("TcpTmTcServer::initialize: TC store uninitialized\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -204,11 +200,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) { ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t packetSize) { if (wiretappingEnabled) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Received TC:" << std::endl; -#else - sif::printInfo("Received TC:\n"); -#endif + FSFW_LOGI("Received TC:\n"); arrayprinter::print(spacePacket, packetSize); } @@ -218,17 +210,7 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack store_address_t storeId; ReturnValue_t result = tcStore->addData(&storeId, spacePacket, packetSize); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcpTmTcServer::handleServerOperation: Data storage with packet size" - << packetSize << " failed" << std::endl; -#else - sif::printWarning( - "TcpTmTcServer::handleServerOperation: Data storage with packet size %d " - "failed\n", - packetSize); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_FLOGWT("handleTcReception: Data storage with packet size {} failed\n", packetSize); return result; } @@ -236,17 +218,7 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcpTmTcServer::handleServerOperation: " - " Sending message to queue failed" - << std::endl; -#else - sif::printWarning( - "TcpTmTcServer::handleServerOperation: " - " Sending message to queue failed\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("handleTcReception: Sending message to queue failed\n"); tcStore->deleteData(storeId); } return result; @@ -254,15 +226,15 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack std::string TcpTmTcServer::getTcpPort() const { return tcpConfig.tcpPort; } -void TcpTmTcServer::setSpacePacketParsingOptions(std::vector validPacketIds) { - this->validPacketIds = validPacketIds; +void TcpTmTcServer::setSpacePacketParsingOptions(std::vector validPacketIds_) { + this->validPacketIds = std::move(validPacketIds_); } TcpTmTcServer::TcpConfig& TcpTmTcServer::getTcpConfigStruct() { return tcpConfig; } ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) { // Access to the FIFO is mutex protected because it is filled by the bridge - MutexGuard(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs); + MutexGuard mg(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs); store_address_t storeId; while ((not tmtcBridge->tmFifo->empty()) and (tmtcBridge->packetSentCounter < tmtcBridge->sentPacketsPerCycle)) { @@ -276,15 +248,11 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) return result; } if (wiretappingEnabled) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Sending TM:" << std::endl; -#else - sif::printInfo("Sending TM:\n"); -#endif + FSFW_LOGI("Sending TM:"); arrayprinter::print(storeAccessor.data(), storeAccessor.size()); } - int retval = send(connSocket, reinterpret_cast(storeAccessor.data()), - storeAccessor.size(), tcpConfig.tcpTmFlags); + ssize_t retval = send(connSocket, reinterpret_cast(storeAccessor.data()), + storeAccessor.size(), tcpConfig.tcpTmFlags); if (retval == static_cast(storeAccessor.size())) { // Packet sent, clear FIFO entry tmtcBridge->tmFifo->pop(); @@ -305,31 +273,14 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { size_t readAmount = availableReadData; lastRingBufferSize = availableReadData; if (readAmount >= ringBuffer.getMaxSize()) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 // Possible configuration error, too much data or/and data coming in too fast, // requiring larger buffers - sif::warning << "TcpTmTcServer::handleServerOperation: Ring buffer reached " - << "fill count" << std::endl; -#else - sif::printWarning( - "TcpTmTcServer::handleServerOperation: Ring buffer reached " - "fill count"); -#endif -#endif + FSFW_LOGWT("handleTcRingBufferData: Ring buffer reached fill count\n"); } if (readAmount >= receptionBuffer.size()) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 // Possible configuration error, too much data or/and data coming in too fast, // requiring larger buffers - sif::warning << "TcpTmTcServer::handleServerOperation: " - "Reception buffer too small " - << std::endl; -#else - sif::printWarning("TcpTmTcServer::handleServerOperation: Reception buffer too small\n"); -#endif -#endif + FSFW_LOGWT("handleTcRingBufferData: Reception buffer too small\n"); readAmount = receptionBuffer.size(); } ringBuffer.readData(receptionBuffer.data(), readAmount, true); diff --git a/src/fsfw/osal/common/UdpTcPollingTask.cpp b/src/fsfw/osal/common/UdpTcPollingTask.cpp index bcc8e9e33..91adc3494 100644 --- a/src/fsfw/osal/common/UdpTcPollingTask.cpp +++ b/src/fsfw/osal/common/UdpTcPollingTask.cpp @@ -4,7 +4,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/osal/common/tcpipHelpers.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #ifdef PLATFORM_WIN #include @@ -51,9 +51,7 @@ UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUdpBrid receptionFlags, &senderAddress, &senderAddressSize); if (bytesReceived == SOCKET_ERROR) { /* Handle error */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UdpTcPollingTask::performOperation: Reception error." << std::endl; -#endif + FSFW_LOGW("performOperation: Reception error\n"); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::RECVFROM_CALL, 1000); continue; } @@ -81,12 +79,7 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t result = tcStore->addData(&storeId, receptionBuffer.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UdpTcPollingTask::transferPusToSoftwareBus: Data storage failed." << std::endl; - sif::warning << "Packet size: " << bytesRead << std::endl; -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("handleSuccessfullTcRead: Data storage failed. Packet size {}\n", bytesRead); return HasReturnvaluesIF::RETURN_FAILED; } @@ -94,13 +87,7 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) { result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UdpTcPollingTask::handleSuccessfullTcRead: " - " Sending message to queue failed" - << std::endl; -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + FSFW_LOGWT("handleSuccessfullTcRead: Sending message to queue failed\n"); tcStore->deleteData(storeId); } return result; @@ -109,17 +96,13 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t UdpTcPollingTask::initialize() { tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (tcStore == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UdpTcPollingTask::initialize: TC store uninitialized!" << std::endl; -#endif + FSFW_LOGE("initialize: TC store uninitialized\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } tmtcBridge = ObjectManager::instance()->get(tmtcBridgeId); if (tmtcBridge == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UdpTcPollingTask::initialize: Invalid TMTC bridge object!" << std::endl; -#endif + FSFW_LOGE("initialize: Invalid TMTC bridge object\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -158,11 +141,7 @@ void UdpTcPollingTask::setTimeout(double timeoutSeconds) { tval = timevalOperations::toTimeval(timeoutSeconds); int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(receptionTimeout)); if (result == -1) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " - "receive timeout failed with " - << strerror(errno) << std::endl; -#endif + FSFW_LOGW("setTimeout: Setting receive timeout failed with {} | {}", errno, strerror(errno)); } #endif } diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index e3cad58ff..1c9f09ea7 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -36,13 +36,11 @@ UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ReturnValue_t UdpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "UdpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; -#endif + FSFW_LOGE("initialize: TmTcBridge initialization failed\n"); return result; } -#ifdef _WIN32 +#ifdef PLATFORM_WIN /* Initiates Winsock DLL. */ WSAData wsaData; WORD wVersionRequested = MAKEWORD(2, 2); @@ -120,9 +118,7 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { ssize_t bytesSent = sendto(serverSocket, reinterpret_cast(data), dataLen, flags, &clientAddress, clientAddressLen); if (bytesSent == SOCKET_ERROR) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcUdpBridge::sendTm: Send operation failed." << std::endl; -#endif + FSFW_LOGWT("sendTm: Send operation failed\n"); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::SENDTO_CALL); } #if FSFW_CPP_OSTREAM_ENABLED == 1 && FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1 diff --git a/src/fsfw/osal/common/tcpipCommon.cpp b/src/fsfw/osal/common/tcpipCommon.cpp index 7594079fe..dbc0792ce 100644 --- a/src/fsfw/osal/common/tcpipCommon.cpp +++ b/src/fsfw/osal/common/tcpipCommon.cpp @@ -1,7 +1,9 @@ #include "fsfw/osal/common/tcpipCommon.h" +#include + #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #ifdef PLATFORM_WIN #include @@ -48,28 +50,20 @@ void tcpip::printAddress(struct sockaddr *addr) { const char *stringPtr = NULL; switch (addr->sa_family) { case AF_INET: { - struct sockaddr_in *addrIn = reinterpret_cast(addr); + auto *addrIn = reinterpret_cast(addr); stringPtr = inet_ntop(AF_INET, &(addrIn->sin_addr), ipAddress, INET_ADDRSTRLEN); break; } case AF_INET6: { - struct sockaddr_in6 *addrIn = reinterpret_cast(addr); + auto *addrIn = reinterpret_cast(addr); stringPtr = inet_ntop(AF_INET6, &(addrIn->sin6_addr), ipAddress, INET6_ADDRSTRLEN); break; } } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - if (stringPtr == NULL) { - sif::debug << "Could not convert IP address to text representation, error code " << errno - << std::endl; + if (stringPtr == nullptr) { + FSFW_FLOGDT("Could not convert IP address to text representation, error code {} | {}", errno, + strerror(errno)); } else { - sif::debug << "IP Address Sender: " << ipAddress << std::endl; + FSFW_FLOGDT("IP Address Sender {}\n", ipAddress); } -#else - if (stringPtr == NULL) { - sif::printDebug("Could not convert IP address to text representation, error code %d\n", errno); - } else { - sif::printDebug("IP Address Sender: %s\n", ipAddress); - } -#endif } diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 19e120b39..20888b304 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -14,36 +14,24 @@ using SystemClock = std::chrono::system_clock; -uint32_t Clock::getTicksPerSecond(void) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::getTicksPerSecond: Not implemented for host OSAL" << std::endl; -#else - sif::printWarning("Clock::getTicksPerSecond: Not implemented for host OSAL\n"); -#endif +uint32_t Clock::getTicksPerSecond() { + FSFW_LOGW("getTicksPerSecond: Not implemented for host OSAL\n"); /* To avoid division by zero */ return 1; } ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { - /* I don't know why someone would need to set a clock which is probably perfectly fine on a - host system with internet access so this is not implemented for now. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::setClock: Not implemented for host OSAL" << std::endl; -#else - sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); -#endif - return HasReturnvaluesIF::RETURN_OK; + // I don't know why someone would need to set a clock which is probably perfectly fine on a + // host system with internet access so this is not implemented for now. + FSFW_LOGI("Clock::setClock: Not implemented for host OSAL\n"); + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t Clock::setClock(const timeval* time) { - /* I don't know why someone would need to set a clock which is probably perfectly fine on a - host system with internet access so this is not implemented for now. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::setClock: Not implemented for host OSAL" << std::endl; -#else - sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); -#endif - return HasReturnvaluesIF::RETURN_OK; + // I don't know why someone would need to set a clock which is probably perfectly fine on a + // host system with internet access so this is not implemented for now. + FSFW_LOGI("Clock::setClock: Not implemented for host OSAL\n"); + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t Clock::getClock_timeval(timeval* time) { diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 078539381..784594394 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -9,7 +9,7 @@ #include "fsfw/osal/host/Mutex.h" #include "fsfw/osal/host/taskHelpers.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/ExecutableObjectIF.h" #if defined(PLATFORM_WIN) @@ -48,7 +48,7 @@ FixedTimeslotTask::~FixedTimeslotTask(void) { } void FixedTimeslotTask::taskEntryPoint(void* argument) { - FixedTimeslotTask* originalTask(reinterpret_cast(argument)); + auto* originalTask(reinterpret_cast(argument)); if (not originalTask->started) { // we have to suspend/block here until the task is started. @@ -58,11 +58,7 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "FixedTimeslotTask::taskEntryPoint: " - "Returned from taskFunctionality." - << std::endl; -#endif + FSFW_LOGET("taskEntryPoint: Returned from taskFunctionality\n"); } ReturnValue_t FixedTimeslotTask::startTask() { @@ -114,22 +110,13 @@ void FixedTimeslotTask::taskFunctionality() { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { - ExecutableObjectIF* executableObject = - ObjectManager::instance()->get(componentId); + auto* executableObject = ObjectManager::instance()->get(componentId); if (executableObject != nullptr) { pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, executableObject, this); return HasReturnvaluesIF::RETURN_OK; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Component " << std::hex << "0x" << componentId - << "not found, " - "not adding it to PST.." - << std::dec << std::endl; -#else - sif::printError("Component 0x%08x not found, not adding it to PST..\n", - static_cast(componentId)); -#endif + FSFW_FLOGE("addSlot: Component {:#08x} not found, not adding it to PST\n", componentId); return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index d0a128505..b47498527 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -15,11 +15,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* a queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &id); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MessageQueue::MessageQueue: Could not be created" << std::endl; -#else - sif::printError("MessageQueue::MessageQueue: Could not be created\n"); -#endif + FSFW_LOGET("ctor: Could not be created\n"); } } diff --git a/src/fsfw/osal/host/PeriodicTask.cpp b/src/fsfw/osal/host/PeriodicTask.cpp index cdcfafa67..ec5b8af3d 100644 --- a/src/fsfw/osal/host/PeriodicTask.cpp +++ b/src/fsfw/osal/host/PeriodicTask.cpp @@ -8,7 +8,7 @@ #include "fsfw/osal/host/Mutex.h" #include "fsfw/osal/host/taskHelpers.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/ExecutableObjectIF.h" #if defined(PLATFORM_WIN) @@ -42,7 +42,7 @@ PeriodicTask::~PeriodicTask(void) { } void PeriodicTask::taskEntryPoint(void* argument) { - PeriodicTask* originalTask(reinterpret_cast(argument)); + auto* originalTask(reinterpret_cast(argument)); if (not originalTask->started) { // we have to suspend/block here until the task is started. @@ -52,11 +52,7 @@ void PeriodicTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PeriodicTask::taskEntryPoint: " - "Returned from taskFunctionality." - << std::endl; -#endif + FSFW_LOGE("taskEntryPoint: Returned from taskFunctionality\n"); } ReturnValue_t PeriodicTask::startTask() { diff --git a/src/fsfw/osal/host/QueueMapManager.cpp b/src/fsfw/osal/host/QueueMapManager.cpp index 72c70baa6..7b20de532 100644 --- a/src/fsfw/osal/host/QueueMapManager.cpp +++ b/src/fsfw/osal/host/QueueMapManager.cpp @@ -30,15 +30,10 @@ ReturnValue_t QueueMapManager::addMessageQueue(MessageQueueIF* queueToInsert, auto returnPair = queueMap.emplace(currentId, queueToInsert); if (not returnPair.second) { /* This should never happen for the atomic variable. */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "QueueMapManager::addMessageQueue This ID is already " - "inside the map!" - << std::endl; -#else - sif::printError( - "QueueMapManager::addMessageQueue This ID is already " - "inside the map!\n"); -#endif + FSFW_LOGE( + "QueueMapManager::addMessageQueue The ID {} is already " + "inside the map\n", + currentId); return HasReturnvaluesIF::RETURN_FAILED; } if (id != nullptr) { @@ -52,13 +47,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId if (queueIter != queueMap.end()) { return queueIter->second; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId - << " does not exists in the map!" << std::endl; -#else - sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n", - messageQueueId); -#endif + FSFW_LOGWT("getMessageQueue: The ID does not exists in the map\n"); } return nullptr; } diff --git a/src/fsfw/osal/host/SemaphoreFactory.cpp b/src/fsfw/osal/host/SemaphoreFactory.cpp index cead3c3d3..cd293375f 100644 --- a/src/fsfw/osal/host/SemaphoreFactory.cpp +++ b/src/fsfw/osal/host/SemaphoreFactory.cpp @@ -1,6 +1,6 @@ #include "fsfw/tasks/SemaphoreFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; @@ -17,22 +17,14 @@ SemaphoreFactory* SemaphoreFactory::instance() { SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) { // Just gonna wait for full C++20 for now. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet." - " Returning nullptr!\n" - << std::flush; -#endif + FSFW_LOGE("SemaphoreFactory: Binary Semaphore not implemented yet. Returning nullptr!\n"); return nullptr; } SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, uint8_t initCount, uint32_t arguments) { // Just gonna wait for full C++20 for now. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet." - " Returning nullptr!\n" - << std::flush; -#endif + FSFW_LOGE("SemaphoreFactory: Counting Semaphore not implemented yet. Returning nullptr!\n"); return nullptr; } diff --git a/src/fsfw/osal/host/TaskFactory.cpp b/src/fsfw/osal/host/TaskFactory.cpp index 6e74fd57f..1e91745e4 100644 --- a/src/fsfw/osal/host/TaskFactory.cpp +++ b/src/fsfw/osal/host/TaskFactory.cpp @@ -6,7 +6,7 @@ #include "fsfw/osal/host/PeriodicTask.h" #include "fsfw/osal/host/taskHelpers.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/PeriodicTaskIF.h" TaskFactory* TaskFactory::factoryInstance = new TaskFactory(); @@ -47,9 +47,5 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { void TaskFactory::printMissedDeadline() { std::string name = tasks::getTaskName(std::this_thread::get_id()); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TaskFactory::printMissedDeadline: " << name << std::endl; -#else - sif::printWarning("TaskFactory::printMissedDeadline: %s\n", name); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGW("printMissedDeadline: {}\n", name); } diff --git a/src/fsfw/osal/linux/tcpipHelpers.cpp b/src/fsfw/osal/linux/tcpipHelpers.cpp index aee7bd798..24a70ce87 100644 --- a/src/fsfw/osal/linux/tcpipHelpers.cpp +++ b/src/fsfw/osal/linux/tcpipHelpers.cpp @@ -96,7 +96,7 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s } #if FSFW_CPP_OSTREAM_ENABLED == 1 - FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); + FSFW_FLOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); #else sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(), errorSrcString.c_str(), infoString.c_str()); diff --git a/src/fsfw/parameters/ParameterHelper.cpp b/src/fsfw/parameters/ParameterHelper.cpp index e5c0357f5..6543d78ea 100644 --- a/src/fsfw/parameters/ParameterHelper.cpp +++ b/src/fsfw/parameters/ParameterHelper.cpp @@ -44,9 +44,9 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGE("{}", - "ParameterHelper::handleParameterMessage: Getting store data failed for " - "load command\n"); + FSFW_FLOGE("{}", + "ParameterHelper::handleParameterMessage: Getting store data failed for " + "load command\n"); break; } diff --git a/src/fsfw/parameters/ParameterWrapper.cpp b/src/fsfw/parameters/ParameterWrapper.cpp index 111facf2e..04da8df69 100644 --- a/src/fsfw/parameters/ParameterWrapper.cpp +++ b/src/fsfw/parameters/ParameterWrapper.cpp @@ -209,23 +209,23 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, uint16_t startWritingAtIndex) { if (data == nullptr) { - FSFW_LOGWT("{}", "copyFrom: Called on read-only variable\n"); + FSFW_FLOGWT("{}", "copyFrom: Called on read-only variable\n"); return READONLY; } if (from->readonlyData == nullptr) { - FSFW_LOGWT("{}", "copyFrom: Source not set\n"); + FSFW_FLOGWT("{}", "copyFrom: Source not set\n"); return SOURCE_NOT_SET; } if (type != from->type) { - FSFW_LOGW("{}", "copyFrom: Datatype missmatch\n"); + FSFW_FLOGW("{}", "copyFrom: Datatype missmatch\n"); return DATATYPE_MISSMATCH; } // The smallest allowed value for rows and columns is one. if (rows == 0 or columns == 0) { - FSFW_LOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n"); + FSFW_FLOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n"); return COLUMN_OR_ROWS_ZERO; } diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index 4d9806f9d..d196e19b6 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -4,7 +4,7 @@ #include "fsfw/health/HealthMessage.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service201Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, @@ -22,9 +22,7 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): return RETURN_OK; default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Invalid Subservice" << std::endl; -#endif + FSFW_LOGWT("Invalid Subservice\n"); return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -43,8 +41,8 @@ ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject(uint8_t subs } ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( - MessageQueueId_t *messageQueueToSet, object_id_t *objectId) { - HasHealthIF *destination = ObjectManager::instance()->get(*objectId); + MessageQueueId_t *messageQueueToSet, const object_id_t *objectId) { + auto *destination = ObjectManager::instance()->get(*objectId); if (destination == nullptr) { return CommandingServiceBase::INVALID_OBJECT; } @@ -96,9 +94,8 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep // Not used for now, health state already reported by event ReturnValue_t CService201HealthCommanding::prepareHealthSetReply(const CommandMessage *reply) { - prepareHealthSetReply(reply); - uint8_t health = static_cast(HealthMessage::getHealth(reply)); - uint8_t oldHealth = static_cast(HealthMessage::getOldHealth(reply)); + auto health = static_cast(HealthMessage::getHealth(reply)); + auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); } diff --git a/src/fsfw/pus/CService201HealthCommanding.h b/src/fsfw/pus/CService201HealthCommanding.h index 5e52ab39e..0c901ca9a 100644 --- a/src/fsfw/pus/CService201HealthCommanding.h +++ b/src/fsfw/pus/CService201HealthCommanding.h @@ -41,7 +41,7 @@ class CService201HealthCommanding : public CommandingServiceBase { ReturnValue_t checkAndAcquireTargetID(object_id_t *objectIdToSet, const uint8_t *tcData, size_t tcDataLen); ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet, - object_id_t *objectId); + const object_id_t *objectId); ReturnValue_t prepareHealthSetReply(const CommandMessage *reply); diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 13d6a1c41..39f153ce0 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service1Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -53,11 +53,9 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( result = generateSuccessReport(message); } if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service1TelecommandVerification::sendVerificationReport: " - "Sending verification packet failed !" - << std::endl; -#endif + FSFW_LOGE( + "Service1TelecommandVerification::sendVerificationReport: " + "Sending verification packet failed\n"); } return result; } @@ -91,15 +89,9 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( ReturnValue_t Service1TelecommandVerification::initialize() { // Get target object for TC verification messages - AcceptsTelemetryIF* funnel = - ObjectManager::instance()->get(targetDestination); + auto* funnel = ObjectManager::instance()->get(targetDestination); if (funnel == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service1TelecommandVerification::initialize: Specified" - " TM funnel invalid. Make sure it is set up and implements" - " AcceptsTelemetryIF." - << std::endl; -#endif + FSFW_LOGE("initialize: Specified TM funnel invalid. Does it implement AcceptsTelemetryIF?\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } tmQueue->setDefaultDestination(funnel->getReportReceptionQueue()); diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 61e29412e..3974a10d8 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -14,7 +14,7 @@ Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, commandTimeoutSeconds) {} -Service20ParameterManagement::~Service20ParameterManagement() {} +Service20ParameterManagement::~Service20ParameterManagement() = default; ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { @@ -22,11 +22,7 @@ ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice case Subservice::PARAMETER_DUMP: return HasReturnvaluesIF::RETURN_OK; default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Invalid Subservice for Service 20" << std::endl; -#else - sif::printError("Invalid Subservice for Service 20\n"); -#endif + FSFW_FLOGE("Invalid Subservice {} for Service 20\n", subservice); return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -48,38 +44,21 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* size_t tcDataLen) { if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " - << "Invalid data." << std::endl; -#else - sif::printError( - "Service20ParameterManagement::" - "checkAndAcquireTargetID: Invalid data.\n"); -#endif + FSFW_LOGE("checkAndAcquireTargetID: Invalid data\n"); return CommandingServiceBase::INVALID_TC; } return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( - MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { + MessageQueueId_t* messageQueueToSet, const object_id_t* objectId) { // check ReceivesParameterMessagesIF property of target - ReceivesParameterMessagesIF* possibleTarget = - ObjectManager::instance()->get(*objectId); + auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire" - << "MessageQueue: Can't access object" << std::endl; - sif::error << "Object ID: " << std::hex << objectId << std::dec << std::endl; - sif::error << "Make sure it implements ReceivesParameterMessagesIF!" << std::endl; -#else - sif::printError( - "Service20ParameterManagement::checkInterfaceAndAcquire" - "MessageQueue: Can't access object\n"); - sif::printError("Object ID: 0x%08x\n", *objectId); - sif::printError("Make sure it implements ReceivesParameterMessagesIF!\n"); -#endif - + FSFW_FLOGE( + "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#08x}\n" + "Does it implement ReceivesParameterMessagesIF?\n", + *objectId); return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); diff --git a/src/fsfw/pus/Service20ParameterManagement.h b/src/fsfw/pus/Service20ParameterManagement.h index ae1fb4ea9..8ba1f5787 100644 --- a/src/fsfw/pus/Service20ParameterManagement.h +++ b/src/fsfw/pus/Service20ParameterManagement.h @@ -37,7 +37,7 @@ class Service20ParameterManagement : public CommandingServiceBase { ReturnValue_t checkAndAcquireTargetID(object_id_t* objectIdToSet, const uint8_t* tcData, size_t tcDataLen); ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t* messageQueueToSet, - object_id_t* objectId); + const object_id_t* objectId); ReturnValue_t prepareDirectCommand(CommandMessage* message, const uint8_t* tcData, size_t tcDataLen); diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 3430271e0..bea926b87 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -8,7 +8,7 @@ #include "fsfw/serialize/EndianConverter.h" #include "fsfw/serialize/SerialLinkedListAdapter.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" Service2DeviceAccess::Service2DeviceAccess(object_id_t objectId, uint16_t apid, uint8_t serviceId, @@ -25,9 +25,7 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { case Subservice::COMMAND_TOGGLE_WIRETAPPING: return HasReturnvaluesIF::RETURN_OK; default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Invalid Subservice" << std::endl; -#endif + FSFW_FLOGW("Invalid Subservice {}\n", subservice); return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -118,11 +116,8 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) { sendWiretappingTm(reply, static_cast(Subservice::REPLY_RAW)); break; default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Unknown message in Service2DeviceAccess::" - "handleUnrequestedReply with command ID " - << reply->getCommand() << std::endl; -#endif + FSFW_FLOGET("handleUnrequestedReply: Unknown message with command ID {}\n", + reply->getCommand()); break; } // Must be reached by all cases to clear message @@ -137,11 +132,8 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " - "handleUnrequestedReply with failure ID " - << result << std::endl; -#endif + FSFW_LOGW("sendWiretappingTm: Data Lost in handleUnrequestedReply with failure ID {:#04x}\n", + result); return; } diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 075747836..66cea1026 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -212,15 +212,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service3Housekeeping::handleReply: Invalid reply with " - << "reply command " << command << "!" << std::endl; -#else - sif::printWarning( - "Service3Housekeeping::handleReply: Invalid reply with " - "reply command %hu!\n", - command); -#endif + FSFW_FLOGW("handleReply: Invalid reply with reply command {}\n", command); return CommandingServiceBase::INVALID_REPLY; } return HasReturnvaluesIF::RETURN_OK; @@ -241,39 +233,20 @@ void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) { break; } - case (HousekeepingMessage::HK_REQUEST_SUCCESS): { - break; - } - + case (HousekeepingMessage::HK_REQUEST_SUCCESS): case (HousekeepingMessage::HK_REQUEST_FAILURE): { break; } default: { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service3Housekeeping::handleUnrequestedReply: Invalid reply with reply " - "command " - << command << "!" << std::endl; -#else - sif::printWarning( - "Service3Housekeeping::handleUnrequestedReply: Invalid reply with " - "reply command %hu!\n", - command); -#endif + FSFW_LOGW("handleUnrequestedReply: Invalid reply with reply command {}\n", command); return; } } if (result != HasReturnvaluesIF::RETURN_OK) { /* Configuration error */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service3Housekeeping::handleUnrequestedReply: Could not generate reply!" - << std::endl; -#else - sif::printWarning( - "Service3Housekeeping::handleUnrequestedReply: " - "Could not generate reply!\n"); -#endif + FSFW_LOGWT("handleUnrequestedReply: Could not generate reply\n"); } } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 4517bc262..d35cd9d40 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -36,9 +36,7 @@ ReturnValue_t Service5EventReporting::performService() { } } } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service5EventReporting::generateEventReport: Too many events" << std::endl; -#endif + FSFW_LOGWT("generateEventReport: Too many events\n"); return HasReturnvaluesIF::RETURN_OK; } @@ -55,15 +53,7 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) ReturnValue_t result = tmPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service5EventReporting::generateEventReport: " - "Could not send TM packet" - << std::endl; -#else - sif::printWarning( - "Service5EventReporting::generateEventReport: " - "Could not send TM packet\n"); -#endif + FSFW_LOGW("generateEventReport: Could not send TM packet\n"); } return result; } diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index be8d90580..f0740ba3d 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -6,7 +6,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/pus/servicepackets/Service8Packets.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId, @@ -65,10 +65,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m return HasReturnvaluesIF::RETURN_FAILED; } if (tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Service8FunctionManagement::prepareDirectCommand:" - << " TC size smaller thant minimum size of direct command." << std::endl; -#endif + FSFW_LOGWT("prepareDirectCommand: TC size smaller thant minimum size of direct command\n"); return CommandingServiceBase::INVALID_TC; } @@ -132,9 +129,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* const uint8_t* buffer = nullptr; ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; -#endif + FSFW_LOGWT("Service 8: Could not retrieve data for data reply\n"); return result; } DataReply dataReply(objectId, actionId, buffer, size); @@ -142,10 +137,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* auto deletionResult = IPCStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service8FunctionManagement::handleReply: Deletion" - << " of data in pool failed." << std::endl; -#endif + FSFW_LOGWT("Service8FunctionManagement::handleReply: Deletion of data in pool failed\n"); } return result; } diff --git a/src/fsfw/pus/servicepackets/Service20Packets.h b/src/fsfw/pus/servicepackets/Service20Packets.h index ceefa1ee4..007919f5e 100644 --- a/src/fsfw/pus/servicepackets/Service20Packets.h +++ b/src/fsfw/pus/servicepackets/Service20Packets.h @@ -1,12 +1,13 @@ #ifndef FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_ #define FSFW_PUS_SERVICEPACKETS_SERVICE20PACKETS_H_ -#include #include #include #include #include -#include + +#include "fsfw/FSFW.h" +#include "fsfw/serviceinterface.h" /** * @brief This class encapsulates the packets sent to the PUS service 20 or sent by the @@ -26,15 +27,9 @@ class ParameterCommand */ ParameterCommand(uint8_t* storePointer, size_t parameterDataLen) : parameterBuffer(storePointer, parameterDataLen) { -#if FSFW_VERBOSE_LEVEL >= 1 if (parameterDataLen == 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "ParameterCommand: Parameter data length is 0" << std::endl; -#else - sif::printWarning("ParameterCommand: Parameter data length is 0!\n"); -#endif + FSFW_LOGWT("ParameterCommand: Parameter data length is 0\n"); } -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ setLoadLinks(); } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 86c0898ab..f3068dad5 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -95,7 +95,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, template uint8_t* SerialBufferAdapter::getBuffer() { if (buffer == nullptr) { - FSFW_LOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n"); + FSFW_FLOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n"); return nullptr; } return buffer; @@ -104,7 +104,7 @@ uint8_t* SerialBufferAdapter::getBuffer() { template const uint8_t* SerialBufferAdapter::getConstBuffer() const { if (constBuffer == nullptr) { - FSFW_LOGE("{}", "getConstBuffer: Buffers are unitialized\n"); + FSFW_FLOGE("{}", "getConstBuffer: Buffers are unitialized\n"); return nullptr; } return constBuffer; diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h index c0881cb15..d378f98c6 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.h +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -123,17 +123,26 @@ void debug(const char* file, unsigned int line, fmt::format_string fmt, logTraced(LogLevel::DEBUG, file, line, false, fmt, args...); } +/** + * Debug logger with timestamp and file/line number prefix + */ template void debug_t(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, true, fmt, args...); } +/** + * Info logger with time stamp + */ template void info_t(fmt::format_string fmt, T&&... args) { log(LogLevel::INFO, true, fmt, args...); } +/** + * Info logger + */ template void info(fmt::format_string fmt, T&&... args) { log(LogLevel::INFO, false, fmt, args...); @@ -144,18 +153,27 @@ void warning(fmt::format_string fmt, T&&... args) { log(LogLevel::ERROR, false, fmt, args...); } +/** + * Warning logger with time stamp + */ template void warning_t(fmt::format_string fmt, T&&... args) { log(LogLevel::ERROR, true, fmt, args...); } +/** + * Warning logger with file/line number prefix + */ template -void warning_f(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void warning_s(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::WARNING, file, line, false, fmt, args...); } +/** + * Warning logger with timestamp and source file information + */ template -void warning_ft(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void warning_st(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::WARNING, file, line, true, fmt, args...); } @@ -164,39 +182,61 @@ void error(fmt::format_string fmt, T&&... args) { log(LogLevel::ERROR, false, fmt, args...); } +/** + * Error logger with timestamp + */ template void error_t(fmt::format_string fmt, T&&... args) { log(LogLevel::ERROR, true, fmt, args...); } +/** + * Error logger with source file information + */ template -void error_f(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void error_s(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::ERROR, file, line, false, fmt, args...); } +/** + * Error logger with timestamp and source file information + */ template -void error_ft(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { +void error_st(const char* file, unsigned int line, fmt::format_string fmt, T&&... args) { logTraced(LogLevel::ERROR, file, line, true, fmt, args...); } } // namespace sif -#define FSFW_LOGI(format, ...) sif::info(FMT_STRING(format), __VA_ARGS__) +// Helper macros to simplify calling the logger functions +// The macros prefixed with F can be used to print formatted output +// The macros postfixed with T are the log variant with timing information -#define FSFW_LOGIT(format, ...) sif::info_t(FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGI(...) sif::info(__VA_ARGS__) +#define FSFW_FLOGI(format, ...) sif::info(FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGD(format, ...) sif::debug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGIT(...) sif::info_t(__VA_ARGS__) +#define FSFW_FLOGIT(format, ...) sif::info_t(FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGDT(format, ...) \ +#define FSFW_LOGD(...) sif::debug(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGD(format, ...) sif::debug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) + +#define FSFW_LOGDT(...) sif::debug_t(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGDT(format, ...) \ sif::debug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGW(format, ...) \ - sif::warning_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGW(...) sif::warning_s(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGW(format, ...) \ + sif::warning_s(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGWT(format, ...) \ - sif::warning_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGWT(...) sif::warning_st(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGWT(format, ...) \ + sif::warning_st(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGE(format, ...) sif::error_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGE(...) sif::error_s(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGE(format, ...) \ + sif::error_s(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) -#define FSFW_LOGET(format, ...) \ - sif::error_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) +#define FSFW_LOGET(...) sif::error_st(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_FLOGET(format, ...) \ + sif::error_st(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index 6cf99b78b..c050f7cc5 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -46,14 +46,14 @@ const uint8_t* ConstStorageAccessor::data() const { return constDataPointer; } size_t ConstStorageAccessor::size() const { if (internalState == AccessState::UNINIT) { - FSFW_LOGW("{}", "size: Not initialized\n"); + FSFW_FLOGW("{}", "size: Not initialized\n"); } return size_; } ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { - FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); + FSFW_FLOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 44e8e818f..00be83a62 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -12,7 +12,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, NUMBER_OF_SUBPOOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { if (NUMBER_OF_SUBPOOLS == 0) { - FSFW_LOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n"); + FSFW_FLOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n"); } max_subpools_t index = 0; for (const auto& currentPoolConfig : poolConfig) { @@ -125,8 +125,8 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { sizeLists[storeId.poolIndex][storeId.packetIndex] = STORAGE_FREE; } else { // pool_index or packet_index is too large - FSFW_LOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n", - SystemObject::getObjectId()); + FSFW_FLOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n", + SystemObject::getObjectId()); status = ILLEGAL_STORAGE_ID; } return status; @@ -175,7 +175,7 @@ ReturnValue_t LocalPool::initialize() { // Check if any pool size is large than the maximum allowed. for (uint8_t count = 0; count < NUMBER_OF_SUBPOOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { - FSFW_LOGW( + FSFW_FLOGW( "LocalPool::initialize: Pool is too large- " "Max. allowed size is: {}\n", STORAGE_FREE - 1); @@ -199,7 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { - FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); + FSFW_FLOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index ae1418490..dbfe780b3 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -23,7 +23,7 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other) ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { - FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); + FSFW_FLOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 104db3c32..60e6e8a4d 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -83,9 +83,7 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod object_id_t object = tableIter.value->getObject(); if ((iter = childrenMap.find(object)) == childrenMap.end()) { // illegal table entry, should only happen due to misconfigured mode table -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << std::hex << getObjectId() << ": invalid mode table entry" << std::endl; -#endif + FSFW_LOGD("{}: Invalid mode table entry\n"); continue; } diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index 81f40bdec..4ba02528e 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -90,7 +90,7 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, in ReturnValue_t FixedSlotSequence::checkSequence() const { if (slotList.empty()) { - FSFW_LOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n"); + FSFW_FLOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n"); return FixedTimeslotTaskIF::SLOT_LIST_EMPTY; } @@ -98,7 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t result = customCheckFunction(slotList); if (result != HasReturnvaluesIF::RETURN_OK) { // Continue for now but print error output. - FSFW_LOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result); + FSFW_FLOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result); } } @@ -108,8 +108,8 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { if (slot.executableObject == nullptr) { errorCount++; } else if (slot.pollingTimeMs < time) { - FSFW_LOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n", - slot.pollingTimeMs, time); + FSFW_FLOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n", + slot.pollingTimeMs, time); errorCount++; } else { // All ok, print slot. @@ -144,7 +144,7 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } } if (count > 0) { - FSFW_LOGE( + FSFW_FLOGE( "FixedSlotSequence::intializeSequenceAfterTaskCreation: Counted {} " "failed initializations\n", count); diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 3feed941d..8dcb39e95 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -27,7 +27,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { size_t size = 0; ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("{}", "selectDestination: Getting data from store failed"); + FSFW_FLOGWT("{}", "selectDestination: Getting data from store failed"); } SpacePacketBase currentPacket(packet); @@ -72,17 +72,7 @@ ReturnValue_t CCSDSDistributor::initialize() { ReturnValue_t status = this->TcDistributor::initialize(); this->tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (this->tcStore == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSDistributor::initialize: Could not initialize" - " TC store!" - << std::endl; -#else - sif::printError( - "CCSDSDistributor::initialize: Could not initialize" - " TC store!\n"); -#endif -#endif + FSFW_LOGE("CCSDSDistributor::initialize: Could not initialize TC store\n"); status = RETURN_FAILED; } return status; diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 1b99dc449..475ec1998 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -1,6 +1,7 @@ #include "fsfw/tcdistribution/CFDPDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" #include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" @@ -21,8 +22,8 @@ CFDPDistributor::~CFDPDistributor() {} CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = this->currentMessage.getStorageId(); - FSFW_LOGI("selectDestination: Recie" << storeId.poolIndex << ", " - << storeId.packetIndex << std::endl; + FSFW_FLOGI("selectDestination was called with pool index {} and packet index {}\n", + storeId.poolIndex, storeId.packetIndex); #endif TcMqMapIter queueMapIt = this->queueMap.end(); if (this->currentPacket == nullptr) { @@ -32,15 +33,8 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { if (currentPacket->getWholeData() != nullptr) { tcStatus = checker.checkPacket(currentPacket); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " - << static_cast(tcStatus) << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", - static_cast(tcStatus)); -#endif -#endif + FSFW_FLOGWT("selectDestination: Packet format invalid, code {}\n", + static_cast(tcStatus)); } queueMapIt = this->queueMap.find(0); } else { @@ -49,13 +43,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { if (queueMapIt == this->queueMap.end()) { tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif + FSFW_FLOGWT("{}", "handlePacket: Destination not found\n"); } if (tcStatus != RETURN_OK) { @@ -68,26 +56,11 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { uint16_t handlerId = handler->getIdentifier(); // should be 0, because CFDPHandler does not set a set a service-ID -#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) - << std::endl; -#else - sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast(handlerId)); -#endif -#endif + FSFW_FLOGIT("CFDPDistributor::registerHandler: Handler ID {}\n", static_cast(handlerId)); MessageQueueId_t queue = handler->getRequestQueue(); auto returnPair = queueMap.emplace(handlerId, queue); if (not returnPair.second) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CFDPDistributor::registerHandler: Service ID already" - " exists in map" - << std::endl; -#else - sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); -#endif -#endif + FSFW_FLOGE("{}", "CFDPDistributor::registerHandler: Service ID already exists in map\n"); return SERVICE_ID_ALREADY_EXISTS; } return HasReturnvaluesIF::RETURN_OK; @@ -122,16 +95,9 @@ ReturnValue_t CFDPDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - CCSDSDistributorIF* ccsdsDistributor = - ObjectManager::instance()->get(packetSource); + auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); if (ccsdsDistributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; - sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; -#else - sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); -#endif + FSFW_FLOGE("{}", "initialize: Packet source invalid. Does it implement CCSDSDistributorIF?\n"); return RETURN_FAILED; } return ccsdsDistributor->registerApplication(this); diff --git a/src/fsfw/tcdistribution/PUSDistributor.cpp b/src/fsfw/tcdistribution/PUSDistributor.cpp index aadecd695..36ab75a74 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.cpp +++ b/src/fsfw/tcdistribution/PUSDistributor.cpp @@ -1,7 +1,7 @@ #include "fsfw/tcdistribution/PUSDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -44,15 +44,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { } else if (tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) { keyword = "incomplete packet"; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword - << " error" << std::endl; -#else - sif::printWarning( - "PUSDistributor::handlePacket: Packet format invalid, " - "%s error\n", - keyword); -#endif + FSFW_FLOGWT("selectDestination: Packet format invalid, {} error\n", keyword); #endif } uint32_t queue_id = currentPacket->getService(); @@ -63,13 +55,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { if (queueMapIt == this->queueMap.end()) { tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif + FSFW_LOGW("selectDestination: Destination not found\n"); } if (tcStatus != RETURN_OK) { @@ -91,15 +77,7 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { MessageQueueId_t queue = service->getRequestQueue(); auto returnPair = queueMap.emplace(serviceId, queue); if (not returnPair.second) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PUSDistributor::registerService: Service ID already" - " exists in map" - << std::endl; -#else - sif::printError("PUSDistributor::registerService: Service ID already exists in map\n"); -#endif -#endif + FSFW_LOGW("registerService: Service ID already exists in map\n"); return SERVICE_ID_ALREADY_EXISTS; } return HasReturnvaluesIF::RETURN_OK; @@ -133,16 +111,11 @@ ReturnValue_t PUSDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - CCSDSDistributorIF* ccsdsDistributor = - ObjectManager::instance()->get(packetSource); + auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); if (ccsdsDistributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; - sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; -#else - sif::printError("PUSDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); -#endif + FSFW_LOGWT( + "initialize: Packet source invalid\n Make sure it exists and implements " + "CCSDSDistributorIF\n"); return RETURN_FAILED; } return ccsdsDistributor->registerApplication(this); diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index b9b3a999c..42c283705 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -33,9 +33,9 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { - FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); + FSFW_FLOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); for (const auto& queueMapIter : queueMap) { - FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); + FSFW_FLOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); } } diff --git a/src/fsfw/timemanager/Stopwatch.cpp b/src/fsfw/timemanager/Stopwatch.cpp index 983c97134..f54dc389e 100644 --- a/src/fsfw/timemanager/Stopwatch.cpp +++ b/src/fsfw/timemanager/Stopwatch.cpp @@ -31,10 +31,10 @@ void Stopwatch::display() { if (displayMode == StopwatchDisplayMode::MILLIS) { auto timeMillis = static_cast(elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000); - FSFW_LOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis); + FSFW_FLOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis); } else if (displayMode == StopwatchDisplayMode::SECONDS) { - FSFW_LOGIT("Stopwatch::display: {} seconds elapsed\n", - static_cast(timevalOperations::toDouble(elapsedTime))); + FSFW_FLOGIT("Stopwatch::display: {} seconds elapsed\n", + static_cast(timevalOperations::toDouble(elapsedTime))); } } diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 891585937..03ae5427d 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -18,7 +18,7 @@ uint8_t SpacePacketBase::getPacketVersionNumber(void) { ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount) { if (data == nullptr) { - FSFW_LOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n"); + FSFW_FLOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } // reset header to zero: diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 5f8957091..816ffbc58 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -11,6 +11,6 @@ CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {} CFDPPacket::~CFDPPacket() {} void CFDPPacket::print() { - FSFW_LOGI("{}", "CFDPPacket::print:\n"); + FSFW_FLOGI("{}", "CFDPPacket::print:\n"); arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index 9a410b40b..1c3dc18ec 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -1,8 +1,9 @@ #include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface.h" -StorageManagerIF* CFDPPacketStored::store = nullptr; +StorageManagerIF* CFDPPacketStored::STORE = nullptr; CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {} @@ -15,19 +16,19 @@ CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacke return; } if (this->checkAndSetStore()) { - ReturnValue_t status = store->addData(&storeAddress, data, size); + ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { this->setData(nullptr, -1); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. - store->getData(storeAddress, &storePtr, &size); + STORE->getData(storeAddress, &storePtr, &size); this->setData(const_cast(storePtr), size); } } ReturnValue_t CFDPPacketStored::deletePacket() { - ReturnValue_t result = this->store->deleteData(this->storeAddress); + ReturnValue_t result = CFDPPacketStored::STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks this->setData(nullptr, -1); @@ -43,7 +44,7 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { size_t tempSize; ReturnValue_t status = StorageManagerIF::RETURN_FAILED; if (this->checkAndSetStore()) { - status = this->store->getData(this->storeAddress, &tempData, &tempSize); + status = CFDPPacketStored::STORE->getData(this->storeAddress, &tempData, &tempSize); } if (status == StorageManagerIF::RETURN_OK) { this->setData(const_cast(tempData), tempSize); @@ -67,12 +68,10 @@ ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSiz // } bool CFDPPacketStored::checkAndSetStore() { - if (this->store == nullptr) { - this->store = ObjectManager::instance()->get(objects::TC_STORE); - if (this->store == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!" << std::endl; -#endif + if (CFDPPacketStored::STORE == nullptr) { + CFDPPacketStored::STORE = ObjectManager::instance()->get(objects::TC_STORE); + if (CFDPPacketStored::STORE == nullptr) { + FSFW_LOGE("CFDPPacketStored::CFDPPacketStored: TC Store not found\n"); return false; } } @@ -82,7 +81,8 @@ bool CFDPPacketStored::checkAndSetStore() { bool CFDPPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; - ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); + ReturnValue_t status = + CFDPPacketStored::STORE->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { if (this->getFullSize() == temp_size) { return true; diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h index f9c73bdd9..54da3e5a8 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h @@ -45,7 +45,7 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { * call tries to set it and throws an error message in case of failures. * The default store is objects::TC_STORE. */ - static StorageManagerIF* store; + static StorageManagerIF* STORE; /** * The address where the packet data of the object instance is stored. */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp index 812bae433..b44771db7 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp @@ -4,17 +4,13 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketBase(setData) {} TcPacketPusBase::~TcPacketPusBase() {} void TcPacketPusBase::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TcPacketBase::print:" << std::endl; -#else - sif::printInfo("TcPacketBase::print:\n"); -#endif + FSFW_LOGI("TcPacketBase::print:\n"); arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp index 8cc38c5f9..7f6dac08c 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp @@ -4,9 +4,9 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" -StorageManagerIF* TcPacketStoredBase::store = nullptr; +StorageManagerIF* TcPacketStoredBase::STORE = nullptr; TcPacketStoredBase::TcPacketStoredBase() { this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; @@ -16,24 +16,18 @@ TcPacketStoredBase::TcPacketStoredBase() { TcPacketStoredBase::~TcPacketStoredBase() {} ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) { - auto result = this->store->getData(storeAddress, dataPtr, dataSize); + auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcPacketStoredBase: Could not get data!" << std::endl; -#else - sif::printWarning("TcPacketStoredBase: Could not get data!\n"); -#endif + FSFW_LOGW("TcPacketStoredBase: Could not get data\n"); } return result; } bool TcPacketStoredBase::checkAndSetStore() { - if (this->store == nullptr) { - this->store = ObjectManager::instance()->get(objects::TC_STORE); - if (this->store == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found!" << std::endl; -#endif + if (TcPacketStoredBase::STORE == nullptr) { + TcPacketStoredBase::STORE = ObjectManager::instance()->get(objects::TC_STORE); + if (TcPacketStoredBase::STORE == nullptr) { + FSFW_LOGE("TcPacketStoredBase::TcPacketStoredBase: TC Store not found\n"); return false; } } @@ -47,7 +41,7 @@ void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, size_t tempSize; ReturnValue_t status = StorageManagerIF::RETURN_FAILED; if (this->checkAndSetStore()) { - status = this->store->getData(this->storeAddress, &tempData, &tempSize); + status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize); } if (status == StorageManagerIF::RETURN_OK) { diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index 86f0d94ec..70cdfa271 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -65,7 +65,7 @@ class TcPacketStoredBase : public TcPacketStoredIF { * call tries to set it and throws an error message in case of failures. * The default store is objects::TC_STORE. */ - static StorageManagerIF* store; + static StorageManagerIF* STORE; /** * The address where the packet data of the object instance is stored. */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp index 153ad8636..9177b23fd 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t sequenceCount, const uint8_t* data, size_t size, @@ -13,12 +13,10 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t sub return; } uint8_t* pData = nullptr; - ReturnValue_t returnValue = - this->store->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); - if (returnValue != this->store->RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcPacketStoredBase: Could not get free element from store!" << std::endl; -#endif + ReturnValue_t returnValue = TcPacketStoredPus::STORE->getFreeElement( + &this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); + if (returnValue != StorageManagerIF::RETURN_OK) { + FSFW_LOGW("TcPacketStoredBase: Could not get free element from store\n"); return; } this->setData(pData, TC_PACKET_MIN_SIZE + size); @@ -44,19 +42,19 @@ TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacke return; } if (this->checkAndSetStore()) { - ReturnValue_t status = store->addData(&storeAddress, data, size); + ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { this->setData(nullptr, size); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. - store->getData(storeAddress, &storePtr, &size); + STORE->getData(storeAddress, &storePtr, &size); this->setData(const_cast(storePtr), size); } } ReturnValue_t TcPacketStoredPus::deletePacket() { - ReturnValue_t result = this->store->deleteData(this->storeAddress); + ReturnValue_t result = this->STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks this->setData(nullptr, -1); @@ -68,7 +66,7 @@ TcPacketPusBase* TcPacketStoredPus::getPacketBase() { return this; } bool TcPacketStoredPus::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; - ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); + ReturnValue_t status = this->STORE->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { if (this->getFullSize() == temp_size) { return true; diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp index bc761d0d8..1e290a3d1 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp @@ -5,7 +5,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/timemanager/CCSDSTime.h" TimeStamperIF* TmPacketBase::timeStamper = nullptr; @@ -41,14 +41,10 @@ ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const { } bool TmPacketBase::checkAndSetStamper() { - if (timeStamper == NULL) { + if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); - if (timeStamper == NULL) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; -#else - sif::printWarning("TmPacketBase::checkAndSetStamper: Stamper not found!\n"); -#endif + if (timeStamper == nullptr) { + FSFW_LOGW("TmPacketBase::checkAndSetStamper: Stamper not found\n"); return false; } } @@ -56,10 +52,6 @@ bool TmPacketBase::checkAndSetStamper() { } void TmPacketBase::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TmPacketBase::print:" << std::endl; -#else - sif::printInfo("TmPacketBase::print:\n"); -#endif + FSFW_LOGI("TmPacketBase::print:\n"); arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp index 4d37bf46f..ad07e2557 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" StorageManagerIF *TmPacketStoredBase::store = nullptr; @@ -45,9 +45,7 @@ bool TmPacketStoredBase::checkAndSetStore() { if (store == nullptr) { store = ObjectManager::instance()->get(objects::TM_STORE); if (store == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmPacketStored::TmPacketStored: TM Store not found!" << std::endl; -#endif + FSFW_LOGW("TmPacketStored::TmPacketStored: TM Store not found\n"); return false; } } @@ -91,13 +89,13 @@ void TmPacketStoredBase::handleStoreFailure(const char *const packetType, Return switch (result) { #if FSFW_CPP_OSTREAM_ENABLED == 1 case (StorageManagerIF::DATA_STORAGE_FULL): { - sif::warning << "TmPacketStoredPus" << packetType << ": " - << "Store full for packet with size" << sizeToReserve << std::endl; + FSFW_FLOGWT("handleStoreFailure: {} | Store full for packet with size {}\n", packetType, + sizeToReserve); break; } case (StorageManagerIF::DATA_TOO_LARGE): { - sif::warning << "TmPacketStoredPus" << packetType << ": Data with size " << sizeToReserve - << " too large" << std::endl; + FSFW_FLOGWT("handleStoreFailure: {} | Data with size {} too large\n", packetType, + sizeToReserve); break; } #else diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index bbdf8d2af..40a33df97 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -2,7 +2,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tcdistribution/PUSDistributorIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcpacket/pus/tm.h" @@ -58,20 +58,15 @@ ReturnValue_t CommandingServiceBase::initialize() { if (packetDestination == objects::NO_OBJECT) { packetDestination = defaultPacketDestination; } - AcceptsTelemetryIF* packetForwarding = - ObjectManager::instance()->get(packetDestination); + auto* packetForwarding = ObjectManager::instance()->get(packetDestination); if (packetSource == objects::NO_OBJECT) { packetSource = defaultPacketSource; } - PUSDistributorIF* distributor = ObjectManager::instance()->get(packetSource); + auto* distributor = ObjectManager::instance()->get(packetSource); if (packetForwarding == nullptr or distributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CommandingServiceBase::intialize: Packet source or " - "packet destination invalid!" - << std::endl; -#endif + FSFW_LOGE("CommandingServiceBase::intialize: Packet source or packet destination invalid\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -82,11 +77,7 @@ ReturnValue_t CommandingServiceBase::initialize() { TCStore = ObjectManager::instance()->get(objects::TC_STORE); if (IPCStore == nullptr or TCStore == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CommandingServiceBase::intialize: IPC store or TC store " - "not initialized yet!" - << std::endl; -#endif + FSFW_LOGE("CommandingServiceBase::intialize: IPC store or TC store not initialized yet\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -104,18 +95,10 @@ void CommandingServiceBase::handleCommandQueue() { } else if (result == MessageQueueIF::EMPTY) { break; } else { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CommandingServiceBase::handleCommandQueue: Receiving message failed" - "with code" - << result << std::endl; -#else - sif::printWarning( - "CommandingServiceBase::handleCommandQueue: Receiving message " - "failed with code %d\n", + FSFW_FLOGWT( + "CommandingServiceBase::handleCommandQueue: Receiving message failed" + "with code {}", result); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ break; } } diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 0786d2250..a8cf58c96 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -22,7 +22,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); if (result != RETURN_OK) { - FSFW_LOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result); + FSFW_FLOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result); return RETURN_FAILED; } return RETURN_OK; @@ -71,8 +71,8 @@ void PusServiceBase::handleRequestQueue() { // ": no new packet." << std::endl; break; } else { - FSFW_LOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId, - status); + FSFW_FLOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId, + status); } } } @@ -89,7 +89,7 @@ ReturnValue_t PusServiceBase::initialize() { auto* destService = ObjectManager::instance()->get(packetDestination); auto* distributor = ObjectManager::instance()->get(packetSource); if (destService == nullptr or distributor == nullptr) { - FSFW_LOGWT( + FSFW_FLOGWT( "ctor: Service {} | Make sure static packetSource and packetDestination " "are defined correctly\n", serviceId); diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index 4c10ae9e3..9ea2e80ea 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -1,10 +1,12 @@ -#include -#include +#include "SpacePacketParser.h" #include +#include + +#include "fsfw/serviceinterface.h" SpacePacketParser::SpacePacketParser(std::vector validPacketIds) - : validPacketIds(validPacketIds) {} + : validPacketIds(std::move(validPacketIds)) {} ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize, size_t& startIndex, size_t& foundSize) { @@ -17,11 +19,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t& startIndex, size_t& foundSize, size_t& readLen) { if (buffer == nullptr or maxSize < 5) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl; -#else - sif::printWarning("SpacePacketParser::parseSpacePackets: Frame invalid\n"); -#endif + FSFW_LOGW("SpacePacketParser::parseSpacePackets: Frame invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } const uint8_t* bufPtr = *buffer; @@ -49,7 +47,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t idx = 0; // Space packet ID as start marker - if (validPacketIds.size() > 0) { + if (!validPacketIds.empty()) { while (idx < maxSize - 5) { uint16_t currentPacketId = bufPtr[idx] << 8 | bufPtr[idx + 1]; if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) != diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index f0a9e8e24..388ba2e75 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -33,7 +33,7 @@ class SpacePacketParser { * If an empty vector is passed, the parser will assume that the start of the given stream * contains the start of a new space packet. */ - SpacePacketParser(std::vector validPacketIds); + explicit SpacePacketParser(std::vector validPacketIds); /** * Parse a given frame for space packets but also increment the given buffer and assign the @@ -53,7 +53,7 @@ class SpacePacketParser { * will be assigned. * -@c RETURN_OK if a packet was found */ - ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, size_t& startIndex, + ReturnValue_t parseSpacePackets(const uint8_t** buffer, size_t maxSize, size_t& startIndex, size_t& foundSize, size_t& readLen); /** diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 8ea671195..f8c70cff9 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -3,7 +3,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #define TMTCBRIDGE_WIRETAPPING 0 @@ -20,30 +20,27 @@ TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_i TmTcBridge::~TmTcBridge() { QueueFactory::instance()->deleteMessageQueue(tmTcReceptionQueue); } -ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle) { +ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle_) { if (sentPacketsPerCycle <= LIMIT_STORED_DATA_SENT_PER_CYCLE) { - this->sentPacketsPerCycle = sentPacketsPerCycle; + this->sentPacketsPerCycle = sentPacketsPerCycle_; return RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of " - << "packets sent per cycle exceeds limits. " - << "Keeping default value." << std::endl; -#endif + FSFW_LOGW( + "setNumberOfSentPacketsPerCycle: Number of packets sent per cycle exceeds limits. " + "Keeping default value\n"); return RETURN_FAILED; } } -ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored) { +ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored_) { if (maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) { - this->maxNumberOfPacketsStored = maxNumberOfPacketsStored; + this->maxNumberOfPacketsStored = maxNumberOfPacketsStored_; return RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " - << "packets stored exceeds limits. " - << "Keeping default value." << std::endl; -#endif + FSFW_FLOGW( + "setMaxNumberOfPacketsStored: Passed number of packets {} stored exceeds " + "limit {}\nKeeping default value\n", + maxNumberOfPacketsStored_, LIMIT_DOWNLINK_PACKETS_STORED); return RETURN_FAILED; } } @@ -51,28 +48,17 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPackets ReturnValue_t TmTcBridge::initialize() { tcStore = ObjectManager::instance()->get(tcStoreId); if (tcStore == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcBridge::initialize: TC store invalid. Make sure" - "it is created and set up properly." - << std::endl; -#endif + FSFW_LOGE("initialize: TC store invalid. Make sure it is created and set up properly\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } tmStore = ObjectManager::instance()->get(tmStoreId); if (tmStore == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcBridge::initialize: TM store invalid. Make sure" - "it is created and set up properly." - << std::endl; -#endif + FSFW_LOGE("initialize: TM store invalid. Make sure it is created and set up properly\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); + auto* tcDistributor = ObjectManager::instance()->get(tcDestination); if (tcDistributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcBridge::initialize: TC Distributor invalid" << std::endl; -#endif + FSFW_LOGE("initialize: TC Distributor invalid\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -86,17 +72,11 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { ReturnValue_t result; result = handleTc(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "TmTcBridge::performOperation: " - << "Error handling TCs" << std::endl; -#endif + FSFW_LOGWT("performOperation: Error handling TCs, code {}\n", result); } result = handleTm(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "TmTcBridge::performOperation: " - << "Error handling TMs" << std::endl; -#endif + FSFW_LOGWT("performOperation: Error handling TMs, code {}\n", result); } return result; } @@ -107,19 +87,14 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcBridge::handleTm: Error handling TM queue with error code 0x" << std::hex - << result << std::dec << "!" << std::endl; -#endif + FSFW_FLOGET("handleTm: Error handling TM queue with error code {:#04x}\n", result); status = result; } if (tmStored and communicationLinkUp and (packetSentCounter < sentPacketsPerCycle)) { result = handleStoredTm(); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcBridge::handleTm: Error handling stored TMs!" << std::endl; -#endif + FSFW_LOGE("handleTm: Error handling stored TMs\n"); status = result; } } @@ -143,7 +118,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { #endif #endif /* FSFW_VERBOSE_LEVEL >= 3 */ - if (communicationLinkUp == false or packetSentCounter >= sentPacketsPerCycle) { + if (!communicationLinkUp or packetSentCounter >= sentPacketsPerCycle) { storeDownlinkData(&message); continue; } @@ -172,15 +147,9 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { } if (tmFifo->full()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number " - "of stored packet IDs reached!" - << std::endl; -#else - sif::printWarning( - "TmTcBridge::storeDownlinkData: TM downlink max. number " - "of stored packet IDs reached!\n"); -#endif + FSFW_LOGWT( + "storeDownlinkData: TM downlink max. number " + "of stored packet IDs reached\n"); if (overwriteOld) { tmFifo->retrieve(&storeId); tmStore->deleteData(storeId); @@ -214,9 +183,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { result = sendTm(data, size); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TMTC Bridge: Could not send stored downlink data" << std::endl; -#endif + FSFW_LOGW("handleStoredTm: Could not send stored downlink data, code {:#04x}\n", result); status = result; } packetSentCounter++; diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 237f1f3ec..f00b8cde2 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -58,19 +58,19 @@ class TmTcBridge : public AcceptsTelemetryIF, * Initializes necessary FSFW components for the TMTC Bridge * @return */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; /** * @brief Handles TMTC reception */ - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t performOperation(uint8_t operationCode) override; /** AcceptsTelemetryIF override */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; /** AcceptsTelecommandsIF override */ - virtual uint16_t getIdentifier() override; - virtual MessageQueueId_t getRequestQueue() override; + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; protected: //! Cached for initialize function. diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 9d06adc4e..8323362ae 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -26,10 +26,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB currentPacket->getPacketSequenceControl(), 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendSuccessReport: Error writing " - << "to queue. Code: " << std::hex << status << std::dec << std::endl; -#endif + FSFW_FLOGET("VerificationReporter::sendSuccessReport: Error writing to queue. Code: {}\n", + status); } } @@ -43,10 +41,10 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendSuccessReport: Error writing " - << "to queue. Code: " << std::hex << status << std::dec << std::endl; -#endif + FSFW_FLOGET( + "VerificationReporter::sendSuccessReport: Error writing " + "to queue. Code: {}\n", + status); } } @@ -64,10 +62,10 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendFailureReport: Error writing " - << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; -#endif + FSFW_FLOGET( + "VerificationReporter::sendFailureReport: Error writing " + "to queue. Code: {}\n", + status); } } @@ -82,30 +80,22 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, uint8_t ackFlags step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendFailureReport: Error writing " - << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; -#endif + FSFW_LOGE("sendFailureReport: Error writing to queue. Code {:#04x}\n", status); } } void VerificationReporter::initialize() { if (messageReceiver == objects::NO_OBJECT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "VerificationReporter::initialize: Verification message" - " receiver object ID not set yet in Factory!" - << std::endl; -#endif + FSFW_LOGW( + "initialize: Verification message " + "receiver object ID not set yet in Factory\n"); return; } - AcceptsVerifyMessageIF* temp = - ObjectManager::instance()->get(messageReceiver); + auto* temp = ObjectManager::instance()->get(messageReceiver); if (temp == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::initialize: Message " - << "receiver invalid. Make sure it is set up properly and " - << "implementsAcceptsVerifyMessageIF" << std::endl; -#endif + FSFW_LOGE( + "VerificationReporter::initialize: Message receiver invalid. " + "Does it implement AcceptsVerifyMessageIF?\n"); return; } this->acknowledgeQueue = temp->getVerificationQueue(); diff --git a/tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index a0313f96b..beaae69b9 100644 --- a/tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -21,15 +21,10 @@ TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, object_id commandTable.insert(newModeListEntry); } -TestAssembly::~TestAssembly() {} +TestAssembly::~TestAssembly() = default; ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestAssembly: Received command to go to mode " << mode << " submode " - << (int)submode << std::endl; -#else - sif::printInfo("TestAssembly: Received command to go to mode %d submode %d\n", mode, submode); -#endif + FSFW_LOGI("TestAssembly: Received command to go to mode {} submode {}", mode, submode); ReturnValue_t result = RETURN_OK; if (mode == MODE_OFF) { commandTable[0].setMode(MODE_OFF); diff --git a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index cd15d6e01..12f8501bc 100644 --- a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -17,11 +17,7 @@ TestDevice::~TestDevice() {} void TestDevice::performOperationHook() { if (periodicPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::performOperationHook: Alive!" << std::endl; -#else - sif::printInfo("TestDevice%d::performOperationHook: Alive!", deviceIdx); -#endif + FSFW_FLOGI("TestDevice {} | performOperationHook: Alive!\n", deviceIdx); } if (oneShot) { @@ -31,28 +27,18 @@ void TestDevice::performOperationHook() { void TestDevice::doStartUp() { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::doStartUp: Switching On" << std::endl; -#else - sif::printInfo("TestDevice%d::doStartUp: Switching On\n", static_cast(deviceIdx)); -#endif + FSFW_FLOGI("TestDevice {} | doStartUp: Switching On\n", deviceIdx); } setMode(_MODE_TO_ON); - return; } void TestDevice::doShutDown() { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::doShutDown: Switching Off" << std::endl; -#else - sif::printInfo("TestDevice%d::doShutDown: Switching Off\n", static_cast(deviceIdx)); -#endif + FSFW_FLOGI("TestDevice {} | doShutDown: Switching Off\n", deviceIdx); } setMode(_MODE_SHUT_DOWN); - return; } ReturnValue_t TestDevice::buildNormalDeviceCommand(DeviceCommandId_t* id) { @@ -67,49 +53,28 @@ ReturnValue_t TestDevice::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { if (mode == _MODE_TO_ON) { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::buildTransitionDeviceCommand: Was called" - " from _MODE_TO_ON mode" - << std::endl; -#else - sif::printInfo( - "TestDevice%d::buildTransitionDeviceCommand: " - "Was called from _MODE_TO_ON mode\n", + FSFW_FLOGI( + "TestDevice {} | buildTransitionDeviceCommand: Was called" + " from _MODE_TO_ON mode\n", deviceIdx); -#endif } } if (mode == _MODE_TO_NORMAL) { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::buildTransitionDeviceCommand: Was called " - "from _MODE_TO_NORMAL mode" - << std::endl; -#else - sif::printInfo( - "TestDevice%d::buildTransitionDeviceCommand: Was called from " - " _MODE_TO_NORMAL mode\n", + FSFW_FLOGI( + "TestDevice {} | buildTransitionDeviceCommand: Was called " + "from _MODE_TO_NORMAL mode\n", deviceIdx); -#endif } setMode(MODE_NORMAL); } if (mode == _MODE_SHUT_DOWN) { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::buildTransitionDeviceCommand: Was called " - "from _MODE_SHUT_DOWN mode" - << std::endl; -#else - sif::printInfo( - "TestDevice%d::buildTransitionDeviceCommand: Was called from " - "_MODE_SHUT_DOWN mode\n", + FSFW_FLOGI( + "TestDevice {} | buildTransitionDeviceCommand: Was called " + "from _MODE_SHUT_DOWN mode\n", deviceIdx); -#endif } setMode(MODE_OFF); @@ -120,14 +85,10 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { void TestDevice::doTransition(Mode_t modeFrom, Submode_t submodeFrom) { if (mode == _MODE_TO_NORMAL) { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::doTransition: Custom transition to " - "normal mode" - << std::endl; -#else - sif::printInfo("TestDevice%d::doTransition: Custom transition to normal mode\n", deviceIdx); -#endif + FSFW_FLOGI( + "TestDevice {} | doTransition: Custom transition to " + "normal mode\n", + deviceIdx); } } else { @@ -229,17 +190,10 @@ ReturnValue_t TestDevice::buildTestCommand0(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { using namespace testdevice; if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::buildTestCommand0: Executing simple command " - " with completion reply" - << std::endl; -#else - sif::printInfo( - "TestDevice%d::buildTestCommand0: Executing simple command with " - "completion reply\n", + FSFW_LOGI( + "TestDevice {} | buildTestCommand0: Executing simple command " + "with completion reply\n", deviceIdx); -#endif } if (commandDataLen > MAX_BUFFER_SIZE - sizeof(DeviceCommandId_t)) { @@ -258,15 +212,10 @@ ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, return DeviceHandlerIF::INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS; } if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::buildTestCommand1: Executing command with " - "data reply" - << std::endl; -#else - sif::printInfo("TestDevice%d:buildTestCommand1: Executing command with data reply\n", - deviceIdx); -#endif + FSFW_LOGI( + "TestDevice {} | buildTestCommand1: Executing command " + "with data reply\n", + deviceIdx); } deviceCommand = EndianConverter::convertBigEndian(deviceCommand); @@ -374,17 +323,8 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC return DeviceHandlerIF::LENGTH_MISSMATCH; } if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::scanForReply: Reply for simple command " - "(ID " - << TEST_COMMAND_0 << ") received!" << std::endl; -#else - sif::printInfo( - "TestDevice%d::scanForReply: Reply for simple command (ID %d) " - "received!\n", - deviceIdx, TEST_COMMAND_0); -#endif + FSFW_LOGIT("TestDevice {} | scanForReply: Reply for simple command (ID {}) received!\n", + deviceIdx, TEST_COMMAND_0); } *foundLen = TEST_COMMAND_0_SIZE; @@ -394,17 +334,8 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC case (TEST_COMMAND_1): { if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::scanForReply: Reply for data command " - "(ID " - << TEST_COMMAND_1 << ") received!" << std::endl; -#else - sif::printInfo( - "TestDevice%d::scanForReply: Reply for data command (ID %d) " - "received\n", - deviceIdx, TEST_COMMAND_1); -#endif + FSFW_LOGIT("TestDevice {} | scanForReply: Reply for data command (ID {}) received\n", + deviceIdx, TEST_COMMAND_1); } *foundLen = len; @@ -576,12 +507,7 @@ ReturnValue_t TestDevice::interpretingNormalModeReply() { ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uint8_t* packet) { CommandMessage commandMessage; if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice::interpretingTestReply0: Generating step and finish reply" - << std::endl; -#else - sif::printInfo("TestDevice::interpretingTestReply0: Generating step and finish reply\n"); -#endif + FSFW_LOGI("interpretingTestReply0: Generating step and finish reply\n"); } MessageQueueId_t commander = getCommanderQueueId(id); @@ -595,12 +521,7 @@ ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uin ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uint8_t* packet) { CommandMessage directReplyMessage; if (fullInfoPrintout) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::interpretingReply1: Setting data reply" - << std::endl; -#else - sif::printInfo("TestDevice%d::interpretingReply1: Setting data reply\n", deviceIdx); -#endif + FSFW_LOGIT("TestDevice {} | interpretingReply1: Setting data reply\n", deviceIdx); } MessageQueueId_t commander = getCommanderQueueId(id); @@ -609,25 +530,14 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin actionHelper.reportData(commander, id, packet, testdevice::TEST_COMMAND_1_SIZE, false); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TestDevice" << deviceIdx - << "::interpretingReply1: Sending data " - "reply failed!" - << std::endl; -#else - sif::printError("TestDevice%d::interpretingReply1: Sending data reply failed!\n", deviceIdx); -#endif + FSFW_LOGWT("TestDevice {} | interpretingReply1: Sending data reply failed\n", deviceIdx); + /* Finish reply */ + actionHelper.finish(false, commander, id, result); return result; } - if (result == HasReturnvaluesIF::RETURN_OK) { - /* Finish reply */ - actionHelper.finish(true, commander, id); - } else { - /* Finish reply */ - actionHelper.finish(false, commander, id, result); - } - + /* Finish reply */ + actionHelper.finish(true, commander, id); return RETURN_OK; } @@ -659,15 +569,8 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, uint32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); if (result == HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::getParameter: Setting parameter 0 to " - "new value " - << newValue << std::endl; -#else - sif::printInfo("TestDevice%d::getParameter: Setting parameter 0 to new value %lu\n", - deviceIdx, static_cast(newValue)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGIT("TestDevice {} | getParameter: Setting parameter 0 to new value {}\n", + newValue); } } parameterWrapper->set(testParameter0); @@ -678,15 +581,8 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, int32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); if (result == HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::getParameter: Setting parameter 1 to " - "new value " - << newValue << std::endl; -#else - sif::printInfo("TestDevice%d::getParameter: Setting parameter 1 to new value %lu\n", - deviceIdx, static_cast(newValue)); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGIT("TestDevice {} | getParameter: Setting parameter 1 to new value {}\n", + newValue); } } parameterWrapper->set(testParameter1); @@ -700,18 +596,10 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, newValues->getElement(newVector + 2, 0, 2) != RETURN_OK) { return HasReturnvaluesIF::RETURN_FAILED; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx - << "::getParameter: Setting parameter 3 to " - "(float vector with 3 entries) to new values [" - << newVector[0] << ", " << newVector[1] << ", " << newVector[2] << "]" - << std::endl; -#else - sif::printInfo( - "TestDevice%d::getParameter: Setting parameter 3 to new values " - "[%f, %f, %f]\n", - deviceIdx, newVector[0], newVector[1], newVector[2]); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGIT( + "TestDevice {} | getParameter: Setting parameter 3 (float vec with 3 entries) " + "to new values 0 {}, 1 {}, 2 {}\n", + newVector[0], newVector[1], newVector[2]); } parameterWrapper->setVector(vectorFloatParams2); break; @@ -729,12 +617,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, } else { printout = "disabled"; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::getParameter: Periodic printout " << printout - << std::endl; -#else - sif::printInfo("TestDevice%d::getParameter: Periodic printout %s", printout); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGIT("TestDevice {} | getParameter: Periodic printout {}\n", deviceIdx, printout); } parameterWrapper->set(periodicPrintout); @@ -762,12 +645,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, } else { printout = "disabled"; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TestDevice" << deviceIdx << "::getParameter: Changing datasets " << printout - << std::endl; -#else - sif::printInfo("TestDevice%d::getParameter: Changing datasets %s", printout); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + FSFW_LOGI("TestDevice {} | getParameter: Changing datasets {}\n", deviceIdx, printout); } parameterWrapper->set(changingDatasets); diff --git a/tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp b/tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp index 727381a28..0488ebf77 100644 --- a/tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp +++ b/tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp @@ -1,24 +1,20 @@ #include "TestEchoComIF.h" #include -#include #include #include #include "TestCookie.h" +#include "fsfw/serviceinterface.h" TestEchoComIF::TestEchoComIF(object_id_t objectId) : SystemObject(objectId) {} -TestEchoComIF::~TestEchoComIF() {} +TestEchoComIF::~TestEchoComIF() = default; ReturnValue_t TestEchoComIF::initializeInterface(CookieIF *cookie) { - TestCookie *dummyCookie = dynamic_cast(cookie); + auto *dummyCookie = dynamic_cast(cookie); if (dummyCookie == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TestEchoComIF::initializeInterface: Invalid cookie!" << std::endl; -#else - sif::printWarning("TestEchoComIF::initializeInterface: Invalid cookie!\n"); -#endif + FSFW_LOGW("TestEchoComIF::initializeInterface: Invalid cookie\n"); return NULLPOINTER; } @@ -32,24 +28,14 @@ ReturnValue_t TestEchoComIF::initializeInterface(CookieIF *cookie) { ReturnValue_t TestEchoComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { - TestCookie *dummyCookie = dynamic_cast(cookie); + auto *dummyCookie = dynamic_cast(cookie); if (dummyCookie == nullptr) { return NULLPOINTER; } ReplyBuffer &replyBuffer = replyMap.find(dummyCookie->getAddress())->second; if (sendLen > replyBuffer.capacity()) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TestEchoComIF::sendMessage: Send length " << sendLen - << " larger than " - "current reply buffer length!" - << std::endl; -#else - sif::printWarning( - "TestEchoComIF::sendMessage: Send length %d larger than current " - "reply buffer length!\n", - sendLen); -#endif + FSFW_LOGWT("sendMessage: Send length larger than current reply buffer length\n"); return HasReturnvaluesIF::RETURN_FAILED; } replyBuffer.resize(sendLen); @@ -64,7 +50,7 @@ ReturnValue_t TestEchoComIF::requestReceiveMessage(CookieIF *cookie, size_t requ } ReturnValue_t TestEchoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - TestCookie *dummyCookie = dynamic_cast(cookie); + auto *dummyCookie = dynamic_cast(cookie); if (dummyCookie == nullptr) { return NULLPOINTER; } diff --git a/tests/src/fsfw_tests/internal/InternalUnitTester.cpp b/tests/src/fsfw_tests/internal/InternalUnitTester.cpp index 4e45d25b2..ac0079341 100644 --- a/tests/src/fsfw_tests/internal/InternalUnitTester.cpp +++ b/tests/src/fsfw_tests/internal/InternalUnitTester.cpp @@ -2,6 +2,7 @@ #include +#include "fsfw/serviceinterface.h" #include "fsfw_tests/internal/UnittDefinitions.h" #include "fsfw_tests/internal/globalfunctions/TestArrayPrinter.h" #include "fsfw_tests/internal/osal/testMq.h" @@ -15,11 +16,7 @@ InternalUnitTester::~InternalUnitTester() {} ReturnValue_t InternalUnitTester::performTests( const struct InternalUnitTester::TestConfig& testConfig) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Running internal unit tests.. Error messages might follow" << std::endl; -#else - sif::printInfo("Running internal unit tests..\n"); -#endif + FSFW_LOGI("Running internal unit tests.. Error messages might follow\n"); testserialize::test_serialization(); testmq::testMq(); @@ -32,10 +29,6 @@ ReturnValue_t InternalUnitTester::performTests( arrayprinter::testArrayPrinter(); } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Internal unit tests finished." << std::endl; -#else - sif::printInfo("Internal unit tests finished.\n"); -#endif + FSFW_LOGI("Internal unit tests finished\n"); return RETURN_OK; } diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.cpp b/tests/src/fsfw_tests/internal/UnittDefinitions.cpp index 3322b1adb..f2822af30 100644 --- a/tests/src/fsfw_tests/internal/UnittDefinitions.cpp +++ b/tests/src/fsfw_tests/internal/UnittDefinitions.cpp @@ -1,10 +1,8 @@ #include "fsfw_tests/internal/UnittDefinitions.h" -ReturnValue_t unitt::put_error(std::string errorId) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Unit Tester error: Failed at test ID " << errorId << std::endl; -#else - sif::printError("Unit Tester error: Failed at test ID %s\n", errorId.c_str()); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#include "fsfw/serviceinterface.h" + +ReturnValue_t unitt::put_error(const std::string& errorId) { + FSFW_FLOGET("Unit Tester error: Failed at test ID {}\n", errorId); return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.h b/tests/src/fsfw_tests/internal/UnittDefinitions.h index 11e83d227..a361b8b16 100644 --- a/tests/src/fsfw_tests/internal/UnittDefinitions.h +++ b/tests/src/fsfw_tests/internal/UnittDefinitions.h @@ -27,7 +27,7 @@ static const double tv_sdouble{-2.2421e19}; } // namespace tv namespace unitt { -ReturnValue_t put_error(std::string errorId); +ReturnValue_t put_error(const std::string& errorId); } #endif /* UNITTEST_INTERNAL_UNITTDEFINITIONS_H_ */ -- 2.34.1 From b45b6b37580cbe6a3acae6a958c7ccdd7e1fa184 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 00:25:48 +0200 Subject: [PATCH 04/16] replace FLOG with LOG variants --- .../devicehandlers/MgmLIS3MDLHandler.cpp | 2 +- hal/src/fsfw_hal/linux/CommandExecutor.cpp | 2 +- hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp | 36 ++++++------ hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 22 ++++---- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 55 +++++++++---------- src/fsfw/action/ActionHelper.cpp | 6 +- src/fsfw/cfdp/CFDPHandler.cpp | 2 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 6 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 2 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 2 +- src/fsfw/datapool/PoolDataSetBase.cpp | 8 +-- src/fsfw/datapool/PoolEntry.cpp | 2 +- src/fsfw/datapool/PoolReadGuard.h | 2 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 2 +- .../datapoollocal/LocalDataPoolManager.cpp | 6 +- .../datapoollocal/LocalPoolDataSetBase.cpp | 4 +- .../datapoollocal/LocalPoolObjectBase.cpp | 12 ++-- src/fsfw/datapoollocal/LocalPoolVector.tpp | 4 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 26 ++++----- .../DeviceHandlerFailureIsolation.cpp | 2 +- src/fsfw/events/EventManagerIF.h | 2 +- src/fsfw/fdir/FailureIsolationBase.cpp | 9 ++- src/fsfw/globalfunctions/arrayprinter.cpp | 4 +- src/fsfw/health/HealthHelper.cpp | 10 ++-- src/fsfw/health/HealthTable.cpp | 2 +- src/fsfw/ipc/MessageQueueMessage.cpp | 2 +- src/fsfw/memory/MemoryHelper.cpp | 2 +- .../monitoring/MonitoringMessageContent.h | 2 +- src/fsfw/objectmanager/ObjectManager.cpp | 20 +++---- src/fsfw/osal/common/TcpTmTcServer.cpp | 2 +- src/fsfw/osal/common/tcpipCommon.cpp | 6 +- src/fsfw/osal/host/FixedTimeslotTask.cpp | 2 +- src/fsfw/osal/linux/tcpipHelpers.cpp | 2 +- src/fsfw/parameters/ParameterHelper.cpp | 6 +- src/fsfw/parameters/ParameterWrapper.cpp | 8 +-- src/fsfw/pus/Service20ParameterManagement.cpp | 4 +- src/fsfw/pus/Service2DeviceAccess.cpp | 6 +- src/fsfw/pus/Service3Housekeeping.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.cpp | 4 +- src/fsfw/serviceinterface/fmtWrapper.h | 17 ------ .../storagemanager/ConstStorageAccessor.cpp | 4 +- src/fsfw/storagemanager/LocalPool.cpp | 10 ++-- src/fsfw/storagemanager/StorageAccessor.cpp | 2 +- src/fsfw/tasks/FixedSlotSequence.cpp | 10 ++-- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 15 +++-- src/fsfw/tcdistribution/PUSDistributor.cpp | 2 +- src/fsfw/tcdistribution/TcDistributor.cpp | 4 +- src/fsfw/timemanager/Stopwatch.cpp | 6 +- src/fsfw/tmtcpacket/SpacePacketBase.cpp | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 2 +- .../tmtcpacket/pus/tm/TmPacketStoredBase.cpp | 8 +-- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 8 +-- src/fsfw/tmtcservices/TmTcBridge.cpp | 4 +- .../tmtcservices/VerificationReporter.cpp | 8 +-- .../integration/devices/TestDeviceHandler.cpp | 14 ++--- .../fsfw_tests/internal/UnittDefinitions.cpp | 2 +- 58 files changed, 200 insertions(+), 220 deletions(-) diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index ff501368c..251b73a85 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -199,7 +199,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, *foundId = getPendingCommand(); if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) { if (start[1] != MGMLIS3MDL::DEVICE_ID) { - FSFW_FLOGW( + FSFW_LOGW( "scanForReply: Device identification failed, found ID {} not equal to expected {}\n", start[1], MGMLIS3MDL::DEVICE_ID); return DeviceHandlerIF::INVALID_DATA; diff --git a/hal/src/fsfw_hal/linux/CommandExecutor.cpp b/hal/src/fsfw_hal/linux/CommandExecutor.cpp index 539bb3519..63b3e30b3 100644 --- a/hal/src/fsfw_hal/linux/CommandExecutor.cpp +++ b/hal/src/fsfw_hal/linux/CommandExecutor.cpp @@ -61,7 +61,7 @@ ReturnValue_t CommandExecutor::close() { void CommandExecutor::printLastError(const std::string& funcName) const { if (lastError != 0) { - FSFW_FLOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError)); + FSFW_LOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError)); } } diff --git a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 01d19c85b..a509dad1e 100644 --- a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -26,7 +26,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; if (cookie == nullptr) { - FSFW_FLOGE("{}", "initializeInterface: Invalid cookie\n"); + FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n"); return NULLPOINTER; } auto* i2cCookie = dynamic_cast(cookie); @@ -38,14 +38,14 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance); if (not statusPair.second) { - FSFW_FLOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n", - i2cAddress); + FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; } - FSFW_FLOGE("initializeInterface: Device with address {} already in use\n", i2cAddress); + FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } @@ -55,7 +55,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s std::string deviceFile; if (sendData == nullptr) { - FSFW_FLOGW("{}", "sendMessage: Send Data is nullptr\n"); + FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -65,14 +65,14 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_FLOGWT("{}", "sendMessage: Invalid I2C Cookie\n"); + FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_FLOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n"); + FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -87,8 +87,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (write(fd, sendData, sendLen) != static_cast(sendLen)) { - FSFW_FLOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno, - strerror(errno)); + FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } @@ -112,7 +112,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n"); + FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n"); i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } @@ -120,8 +120,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_FLOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap", - i2cAddress); + FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap", + i2cAddress); i2cDeviceMapIter->second.replyLen = 0; return HasReturnvaluesIF::RETURN_FAILED; } @@ -141,7 +141,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe ssize_t readLen = read(fd, replyBuffer, requestLen); if (readLen != static_cast(requestLen)) { - FSFW_FLOGWT( + FSFW_LOGWT( "requestReceiveMessage: Reading from I2C device failed with error code " "{} | {}\nRead only {} from {} bytes\n", errno, strerror(errno), readLen, requestLen); @@ -161,15 +161,15 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { auto* i2cCookie = dynamic_cast(cookie); if (i2cCookie == nullptr) { - FSFW_FLOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n"); + FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n"); return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { - FSFW_FLOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n", - i2cAddress); + FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n", + i2cAddress); return HasReturnvaluesIF::RETURN_FAILED; } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); @@ -181,8 +181,8 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, int* fileDescriptor) { if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) { - FSFW_FLOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno, - strerror(errno)); + FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno, + strerror(errno)); return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index 51ee797cb..e98b9de8b 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -19,7 +19,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF) : SystemObject(objectId), gpioComIF(gpioComIF) { if (gpioComIF == nullptr) { - FSFW_FLOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n"); + FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n"); } spiMutex = MutexFactory::instance()->createMutex(); @@ -40,7 +40,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { SpiInstance spiInstance(bufferSize); auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance); if (not statusPair.second) { - FSFW_FLOGWT( + FSFW_LOGWT( "SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device " "map\n", spiAddress); @@ -50,7 +50,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { to the SPI driver transfer struct */ spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data()); } else { - FSFW_FLOGWT("{}", "initializeInterface: SPI address already exists\n"); + FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -123,7 +123,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } if (sendLen > spiCookie->getMaxBufferSize()) { - FSFW_FLOGW( + FSFW_LOGW( "sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n", spiCookie->getMaxBufferSize(), sendLen); return DeviceCommunicationIF::TOO_MUCH_DATA; @@ -173,12 +173,12 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { - FSFW_FLOGET("{}", "sendMessage: Failed to lock mutex\n"); + FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n"); return result; } result = gpioComIF->pullLow(gpioId); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGW("{}", "sendMessage: Pulling low CS pin failed\n"); + FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n"); return result; } } @@ -197,7 +197,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const } else { /* We write with a blocking half-duplex transfer here */ if (write(fileDescriptor, sendData, sendLen) != static_cast(sendLen)) { - FSFW_FLOGET("{}", "sendMessage: Half-Duplex write operation failed\n"); + FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } } @@ -206,7 +206,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { - FSFW_FLOGWT("{}", "sendMessage: Failed to unlock mutex\n"); + FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n"); return result; } } @@ -248,14 +248,14 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); if (result != RETURN_OK) { - FSFW_FLOGW("{}", "getSendSuccess: Failed to lock mutex\n"); + FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n"); return result; } gpioComIF->pullLow(gpioId); } if (read(fileDescriptor, rxBuf, readSize) != static_cast(readSize)) { - FSFW_FLOGW("{}", "sendMessage: Half-Duplex read operation failed\n"); + FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n"); result = HALF_DUPLEX_TRANSFER_FAILED; } @@ -263,7 +263,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); if (result != RETURN_OK) { - FSFW_FLOGW("{}", "getSendSuccess: Failed to unlock mutex\n"); + FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n"); return result; } } diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 49d4de766..6f042efaf 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -25,7 +25,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGE("{}", "initializeInterface: Invalid UART Cookie\n"); + FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -41,12 +41,11 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { UartElements uartElements = {fileDescriptor, std::vector(maxReplyLen), 0}; auto status = uartDeviceMap.emplace(deviceFile, uartElements); if (!status.second) { - FSFW_FLOGW("initializeInterface: Failed to insert device {} to UART device map\n", - deviceFile); + FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile); return RETURN_FAILED; } } else { - FSFW_FLOGW("initializeInterface: UART device {} already in use\n", deviceFile); + FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile); return RETURN_FAILED; } @@ -66,14 +65,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { int fd = open(deviceFile.c_str(), flags); if (fd < 0) { - FSFW_FLOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile, - errno, strerror(errno)); + FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile, + errno, strerror(errno)); return fd; } /* Read in existing settings */ if (tcgetattr(fd, &options) != 0) { - FSFW_FLOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno)); + FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno)); return fd; } @@ -94,8 +93,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { /* Save option settings */ if (tcsetattr(fd, TCSANOW, &options) != 0) { - FSFW_FLOGW("configureUartPort: Failed to set options with error {} | {}\n", errno, - strerror(errno)); + FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno, + strerror(errno)); return fd; } return fd; @@ -147,8 +146,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook options->c_cflag |= CS8; break; default: - FSFW_FLOGW("setDatasizeOptions: Invalid size {} specified\n", - static_cast(uartCookie->getBitsPerWord())); + FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n", + static_cast(uartCookie->getBitsPerWord())); break; } } @@ -301,7 +300,7 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki break; #endif // ! __APPLE__ default: - FSFW_FLOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n"); + FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n"); break; } } @@ -316,27 +315,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, } if (sendData == nullptr) { - FSFW_FLOGWT("{}", "sendMessage: Send data is nullptr"); + FSFW_LOGWT("{}", "sendMessage: Send data is nullptr"); return RETURN_FAILED; } auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "sendMessage: Invalid UART Cookie\n"); + FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_FLOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile); + FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } fd = uartDeviceMapIter->second.fileDescriptor; if (write(fd, sendData, sendLen) != static_cast(sendLen)) { - FSFW_FLOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno)); + FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno)); return RETURN_FAILED; } @@ -351,7 +350,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n"); + FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n"); return NULLPOINTER; } @@ -364,7 +363,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_FLOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile); + FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -393,7 +392,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (currentBytesRead >= maxReplySize) { // Overflow risk. Emit warning, trigger event and break. If this happens, // the reception buffer is not large enough or data is not polled often enough. - FSFW_FLOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n"); + FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n"); result = UART_RX_BUFFER_TOO_SMALL; break; } else { @@ -404,7 +403,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM if (bytesRead < 0) { // EAGAIN: No data available in non-blocking mode if (errno != EAGAIN) { - FSFW_FLOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno)); + FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno)); return RETURN_FAILED; } @@ -424,7 +423,7 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow if (requestLen > uartCookie.getMaxReplyLen()) { - FSFW_FLOGW("{}", "requestReceiveMessage: Next read would cause overflow\n"); + FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n"); return UART_RX_BUFFER_TOO_SMALL; } ssize_t bytesRead = read(fd, bufferPtr, requestLen); @@ -432,8 +431,8 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi return RETURN_FAILED; } else if (bytesRead != static_cast(requestLen)) { if (uartCookie.isReplySizeFixed()) { - FSFW_FLOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead, - requestLen); + FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead, + requestLen); return RETURN_FAILED; } } @@ -447,14 +446,14 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "readReceivedMessage: Invalid uart cookie"); + FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { - FSFW_FLOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile); + FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile); return RETURN_FAILED; } @@ -472,7 +471,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n"); + FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -490,7 +489,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n"); + FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); @@ -508,7 +507,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { UartDeviceMapIter uartDeviceMapIter; auto* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - FSFW_FLOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n"); + FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n"); return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index e0d570279..13cc6fdc4 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -28,7 +28,7 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { } if (queueToUse == nullptr) { - FSFW_FLOGW("{}", "initialize: No queue set\n"); + FSFW_LOGW("{}", "initialize: No queue set\n"); return HasReturnvaluesIF::RETURN_FAILED; } @@ -90,7 +90,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("{}", "reportData: Getting free element from IPC store failed\n"); + FSFW_LOGWT("{}", "reportData: Getting free element from IPC store failed\n"); return result; } result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); @@ -125,7 +125,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("{}", "reportData: Adding data to IPC store failed\n"); + FSFW_LOGWT("{}", "reportData: Adding data to IPC store failed\n"); return result; } diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp index 3b2c8ebaf..7c23c1334 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CFDPHandler.cpp @@ -29,7 +29,7 @@ ReturnValue_t CFDPHandler::initialize() { } ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { - FSFW_FLOGDT("{}", "CFDPHandler::handleRequest\n"); + FSFW_LOGDT("{}", "CFDPHandler::handleRequest\n"); // TODO read out packet from store using storeId diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index c9d2b5bcd..3e77f2211 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -50,9 +50,9 @@ ReturnValue_t EofPduDeserializer::parseData() { if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { EntityIdTlv* tlvPtr = info.getFaultLoc(); if (tlvPtr == nullptr) { - FSFW_FLOGW("{}", - "parseData: Ca not deserialize fault location," - " given TLV pointer invalid\n"); + FSFW_LOGW("{}", + "parseData: Ca not deserialize fault location," + " given TLV pointer invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness); diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index 98391d415..24b04b4a9 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -7,7 +7,7 @@ cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGW("{}", "cfdp::VarLenField: Setting value failed\n"); + FSFW_LOGW("{}", "cfdp::VarLenField: Setting value failed\n"); } } diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 0f4dbf209..528c482b8 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -128,7 +128,7 @@ class FilestoreTlvBase : public TlvIF { } void secondFileNameMissing() const { - FSFW_FLOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n"); + FSFW_LOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n"); } FilestoreActionCode getActionCode() const { return actionCode; } diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index 93d2ab246..891a95e2c 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -17,15 +17,15 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { return HasReturnvaluesIF::RETURN_FAILED; } if (state != States::STATE_SET_UNINITIALISED) { - FSFW_FLOGW("{}", "registerVariable: Call made in wrong position\n"); + FSFW_LOGW("{}", "registerVariable: Call made in wrong position\n"); return DataSetIF::DATA_SET_UNINITIALISED; } if (variable == nullptr) { - FSFW_FLOGW("{}", "registerVariable: Pool variable is nullptr\n"); + FSFW_LOGW("{}", "registerVariable: Pool variable is nullptr\n"); return DataSetIF::POOL_VAR_NULL; } if (fillCount >= maxFillCount) { - FSFW_FLOGW("{}", "registerVariable: DataSet is full\n"); + FSFW_LOGW("{}", "registerVariable: DataSet is full\n"); return DataSetIF::DATA_SET_FULL; } registeredVariables[fillCount] = variable; @@ -47,7 +47,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l state = States::STATE_SET_WAS_READ; unlockDataPool(); } else { - FSFW_FLOGWT("{}", "read: Call made in wrong position. commit call might be missing\n"); + FSFW_LOGWT("{}", "read: Call made in wrong position. commit call might be missing\n"); result = SET_WAS_ALREADY_READ; } diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp index 97b23d716..c52f1a0fa 100644 --- a/src/fsfw/datapool/PoolEntry.cpp +++ b/src/fsfw/datapool/PoolEntry.cpp @@ -68,7 +68,7 @@ void PoolEntry::print() { } else { validString = "Invalid"; } - FSFW_FLOGI("PoolEntry Info. Validity {}\n", validString); + FSFW_LOGI("PoolEntry Info. Validity {}\n", validString); arrayprinter::print(reinterpret_cast(address), getByteSize()); } diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h index 8520bc1a2..d9c42fa76 100644 --- a/src/fsfw/datapool/PoolReadGuard.h +++ b/src/fsfw/datapool/PoolReadGuard.h @@ -17,7 +17,7 @@ class PoolReadGuard { if (readObject != nullptr) { readResult = readObject->read(timeoutType, mutexTimeout); if (readResult != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGW("{}", "ctor: Read failed\n"); + FSFW_LOGW("{}", "ctor: Read failed\n"); } } } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index 930ccad11..8650c29e7 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -166,7 +166,7 @@ class HasLocalDataPoolIF { * @return */ virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { - FSFW_FLOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n"); + FSFW_LOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n"); return nullptr; } }; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 5bff44639..744573104 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -695,7 +695,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true); if (result != HasReturnvaluesIF::RETURN_OK) { /* Configuration error */ - FSFW_FLOGWT("{}", "performHkOperation: HK generation failed"); + FSFW_LOGWT("{}", "performHkOperation: HK generation failed"); } } @@ -852,9 +852,9 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, } if (outputType == sif::OutputTypes::OUT_WARNING) { - FSFW_FLOGWT("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); + FSFW_LOGWT("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); } else if (outputType == sif::OutputTypes::OUT_ERROR) { - FSFW_FLOGET("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); + FSFW_LOGET("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); } #endif /* #if FSFW_VERBOSE_LEVEL >= 1 */ } diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index ed534896a..cd533cd99 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -16,7 +16,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t : PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if (hkOwner == nullptr) { // Configuration error. - FSFW_FLOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n"); + FSFW_LOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n"); return; } AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -179,7 +179,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGW("{}", "serializeLocalPoolIds: Serialization error\n"); + FSFW_LOGW("{}", "serializeLocalPoolIds: Serialization error\n"); return result; } } diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 4a920664e..5d0a3068f 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -11,10 +11,10 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { - FSFW_FLOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); + FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } if (hkOwner == nullptr) { - FSFW_FLOGET("{}", "ctor: Supplied pool owner is a invalid\n"); + FSFW_LOGET("{}", "ctor: Supplied pool owner is a invalid\n"); return; } AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); @@ -29,11 +29,11 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { - FSFW_FLOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); + FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n"); } auto* hkOwner = ObjectManager::instance()->get(poolOwner); if (hkOwner == nullptr) { - FSFW_FLOGWT( + FSFW_LOGWT( "ctor: The supplied pool owner {:#08x} did not implement the correct interface " "HasLocalDataPoolIF\n", poolOwner); @@ -94,6 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return errMsg = "Unknown error code"; } - FSFW_FLOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, - objectId, lpId); + FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, + objectId, lpId); } diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index e26d1fbbb..59f3d546e 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -98,7 +98,7 @@ inline T& LocalPoolVector::operator [](size_t i) { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. - FSFW_FLOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); + FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } @@ -109,7 +109,7 @@ inline const T& LocalPoolVector::operator [](size_t i) const { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. - FSFW_FLOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); + FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); return value[vectorSize - 1]; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 1ca03a31b..e51043d92 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -156,9 +156,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Raw receiver object ID set but no valid object found."); - FSFW_FLOGE("{}", - "Make sure the raw receiver object is set up properly " - "and implements AcceptsDeviceResponsesIF"); + FSFW_LOGE("{}", + "Make sure the raw receiver object is set up properly " + "and implements AcceptsDeviceResponsesIF"); return ObjectManagerIF::CHILD_INIT_FAILED; } defaultRawReceiver = rawReceiver->getDeviceQueue(); @@ -170,9 +170,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); - FSFW_FLOGE("{}", - "Make sure the power switcher object is set up " - "properly and implements PowerSwitchIF\n"); + FSFW_LOGE("{}", + "Make sure the power switcher object is set up " + "properly and implements PowerSwitchIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -755,9 +755,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD printWarningOrError(sif::OutputTypes::OUT_ERROR, "parseReply", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); - FSFW_FLOGW("{}", - "DeviceHandlerBase::parseReply: foundLen is 0! " - "Packet parsing will be stuck\n"); + FSFW_LOGW("{}", + "DeviceHandlerBase::parseReply: foundLen is 0! " + "Packet parsing will be stuck\n"); } break; } @@ -1462,11 +1462,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch } if (errorType == sif::OutputTypes::OUT_WARNING) { - FSFW_FLOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), - errorPrint); + FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } else if (errorType == sif::OutputTypes::OUT_ERROR) { - FSFW_FLOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), - errorPrint); + FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + errorPrint); } } diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index f5285f80b..c875f62b7 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -163,7 +163,7 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGE("{}", "initialize: Could not initialize FailureIsolationBase\n"); + FSFW_LOGE("{}", "initialize: Could not initialize FailureIsolationBase\n"); return result; } auto* power = ObjectManager::instance()->get(powerConfirmationId); diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index 5e2f3b548..2ab9af411 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -41,7 +41,7 @@ class EventManagerIF { if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) { auto* eventmanager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (eventmanager == nullptr) { - FSFW_FLOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n"); + FSFW_LOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n"); return; } eventmanagerQueue = eventmanager->getEventReportQueue(); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index b1f731d19..39fbe0221 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -20,7 +20,7 @@ FailureIsolationBase::~FailureIsolationBase() { ReturnValue_t FailureIsolationBase::initialize() { auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { - FSFW_FLOGE("{}", "initialize: Event Manager has not been initialized\n"); + FSFW_LOGE("{}", "initialize: Event Manager has not been initialized\n"); return RETURN_FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); @@ -34,7 +34,7 @@ ReturnValue_t FailureIsolationBase::initialize() { } owner = ObjectManager::instance()->get(ownerId); if (owner == nullptr) { - FSFW_FLOGE( + FSFW_LOGE( "FailureIsolationBase::intialize: Owner object {:#08x} invalid. " "Does it implement HasHealthIF?\n", ownerId); @@ -44,9 +44,8 @@ ReturnValue_t FailureIsolationBase::initialize() { if (faultTreeParent != objects::NO_OBJECT) { auto* parentIF = ObjectManager::instance()->get(faultTreeParent); if (parentIF == nullptr) { - FSFW_FLOGW( - "intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", - faultTreeParent); + FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", + faultTreeParent); return ObjectManagerIF::CHILD_INIT_FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); diff --git a/src/fsfw/globalfunctions/arrayprinter.cpp b/src/fsfw/globalfunctions/arrayprinter.cpp index c434bc558..c8de86102 100644 --- a/src/fsfw/globalfunctions/arrayprinter.cpp +++ b/src/fsfw/globalfunctions/arrayprinter.cpp @@ -8,11 +8,11 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool printInfo, size_t maxCharPerLine) { if (size == 0) { - FSFW_FLOGI("{}", "Size is zero, nothing to print\n"); + FSFW_LOGI("{}", "Size is zero, nothing to print\n"); return; } - FSFW_FLOGI("Printing data with size {}:\n", size); + FSFW_LOGI("Printing data with size {}:\n", size); if (type == OutputType::HEX) { arrayprinter::printHex(data, size, maxCharPerLine); } else if (type == OutputType::DEC) { diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 22ca76ce4..954a1e19d 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -35,12 +35,12 @@ ReturnValue_t HealthHelper::initialize() { eventSender = ObjectManager::instance()->get(objectId); if (healthTable == nullptr) { - FSFW_FLOGE("{}", "initialize: Health table object needs to be created in factory\n"); + FSFW_LOGE("{}", "initialize: Health table object needs to be created in factory\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } if (eventSender == nullptr) { - FSFW_FLOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n"); + FSFW_LOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -69,7 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); + FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); } } @@ -86,7 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", - objectId); + FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", + objectId); } } diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index 850e647b3..e9358bd7f 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -69,7 +69,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { ReturnValue_t result = SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGW("{}", "printAll: Serialization of health table failed\n"); + FSFW_LOGW("{}", "printAll: Serialization of health table failed\n"); return; } for (const auto& health : healthMap) { diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 4b3477fc3..bbaddda1a 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -15,7 +15,7 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) memcpy(this->getData(), data, size); this->messageSize = this->HEADER_SIZE + size; } else { - FSFW_FLOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n"); + FSFW_LOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n"); memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); this->messageSize = this->HEADER_SIZE; } diff --git a/src/fsfw/memory/MemoryHelper.cpp b/src/fsfw/memory/MemoryHelper.cpp index 0a3bf779e..34cd30171 100644 --- a/src/fsfw/memory/MemoryHelper.cpp +++ b/src/fsfw/memory/MemoryHelper.cpp @@ -17,7 +17,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { lastSender = message->getSender(); lastCommand = message->getCommand(); if (busy) { - FSFW_FLOGW("{}", "MemoryHelper: Busy\n"); + FSFW_LOGW("{}", "MemoryHelper: Busy\n"); } switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index 9096fdfd3..ebb473988 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -81,7 +81,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); if (timeStamper == nullptr) { - FSFW_FLOGET("{}", "checkAndSetStamper: Stamper not found\n"); + FSFW_LOGET("{}", "checkAndSetStamper: Stamper not found\n"); return false; } } diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 83d193493..5d3267beb 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -38,8 +38,8 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { #endif return this->RETURN_OK; } else { - FSFW_FLOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", - static_cast(id)); + FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", + static_cast(id)); // This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); } @@ -54,7 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { #endif return RETURN_OK; } else { - FSFW_FLOGW("removeObject: Requested object {:#08x} not found\n", id); + FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id); return NOT_FOUND; } } @@ -78,27 +78,27 @@ void ObjectManager::initialize() { result = it.second->initialize(); if (result != RETURN_OK) { object_id_t var = it.first; - FSFW_FLOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, - result); + FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, + result); errorCount++; } } if (errorCount > 0) { - FSFW_FLOGWT("{}", "initialize: Counted failed initializations\n"); + FSFW_LOGWT("{}", "initialize: Counted failed initializations\n"); } // Init was successful. Now check successful interconnections. errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if (result != RETURN_OK) { - FSFW_FLOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, - result); + FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, + result); errorCount++; } } if (errorCount > 0) { - FSFW_FLOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n", - errorCount); + FSFW_LOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n", + errorCount); } } diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index b45013fd3..ab32d73ff 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -210,7 +210,7 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack store_address_t storeId; ReturnValue_t result = tcStore->addData(&storeId, spacePacket, packetSize); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("handleTcReception: Data storage with packet size {} failed\n", packetSize); + FSFW_LOGWT("handleTcReception: Data storage with packet size {} failed\n", packetSize); return result; } diff --git a/src/fsfw/osal/common/tcpipCommon.cpp b/src/fsfw/osal/common/tcpipCommon.cpp index dbc0792ce..5ac9b7d4e 100644 --- a/src/fsfw/osal/common/tcpipCommon.cpp +++ b/src/fsfw/osal/common/tcpipCommon.cpp @@ -61,9 +61,9 @@ void tcpip::printAddress(struct sockaddr *addr) { } } if (stringPtr == nullptr) { - FSFW_FLOGDT("Could not convert IP address to text representation, error code {} | {}", errno, - strerror(errno)); + FSFW_LOGDT("Could not convert IP address to text representation, error code {} | {}", errno, + strerror(errno)); } else { - FSFW_FLOGDT("IP Address Sender {}\n", ipAddress); + FSFW_LOGDT("IP Address Sender {}\n", ipAddress); } } diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 784594394..76b003688 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -116,7 +116,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotT return HasReturnvaluesIF::RETURN_OK; } - FSFW_FLOGE("addSlot: Component {:#08x} not found, not adding it to PST\n", componentId); + FSFW_LOGE("addSlot: Component {:#08x} not found, not adding it to PST\n", componentId); return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/osal/linux/tcpipHelpers.cpp b/src/fsfw/osal/linux/tcpipHelpers.cpp index 24a70ce87..aee7bd798 100644 --- a/src/fsfw/osal/linux/tcpipHelpers.cpp +++ b/src/fsfw/osal/linux/tcpipHelpers.cpp @@ -96,7 +96,7 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s } #if FSFW_CPP_OSTREAM_ENABLED == 1 - FSFW_FLOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); + FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); #else sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(), errorSrcString.c_str(), infoString.c_str()); diff --git a/src/fsfw/parameters/ParameterHelper.cpp b/src/fsfw/parameters/ParameterHelper.cpp index 6543d78ea..e5c0357f5 100644 --- a/src/fsfw/parameters/ParameterHelper.cpp +++ b/src/fsfw/parameters/ParameterHelper.cpp @@ -44,9 +44,9 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGE("{}", - "ParameterHelper::handleParameterMessage: Getting store data failed for " - "load command\n"); + FSFW_LOGE("{}", + "ParameterHelper::handleParameterMessage: Getting store data failed for " + "load command\n"); break; } diff --git a/src/fsfw/parameters/ParameterWrapper.cpp b/src/fsfw/parameters/ParameterWrapper.cpp index 04da8df69..111facf2e 100644 --- a/src/fsfw/parameters/ParameterWrapper.cpp +++ b/src/fsfw/parameters/ParameterWrapper.cpp @@ -209,23 +209,23 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, uint16_t startWritingAtIndex) { if (data == nullptr) { - FSFW_FLOGWT("{}", "copyFrom: Called on read-only variable\n"); + FSFW_LOGWT("{}", "copyFrom: Called on read-only variable\n"); return READONLY; } if (from->readonlyData == nullptr) { - FSFW_FLOGWT("{}", "copyFrom: Source not set\n"); + FSFW_LOGWT("{}", "copyFrom: Source not set\n"); return SOURCE_NOT_SET; } if (type != from->type) { - FSFW_FLOGW("{}", "copyFrom: Datatype missmatch\n"); + FSFW_LOGW("{}", "copyFrom: Datatype missmatch\n"); return DATATYPE_MISSMATCH; } // The smallest allowed value for rows and columns is one. if (rows == 0 or columns == 0) { - FSFW_FLOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n"); + FSFW_LOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n"); return COLUMN_OR_ROWS_ZERO; } diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 3974a10d8..d173d9b9f 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -22,7 +22,7 @@ ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice case Subservice::PARAMETER_DUMP: return HasReturnvaluesIF::RETURN_OK; default: - FSFW_FLOGE("Invalid Subservice {} for Service 20\n", subservice); + FSFW_LOGE("Invalid Subservice {} for Service 20\n", subservice); return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -55,7 +55,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue // check ReceivesParameterMessagesIF property of target auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { - FSFW_FLOGE( + FSFW_LOGE( "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#08x}\n" "Does it implement ReceivesParameterMessagesIF?\n", *objectId); diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index bea926b87..b38bf75b6 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -25,7 +25,7 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { case Subservice::COMMAND_TOGGLE_WIRETAPPING: return HasReturnvaluesIF::RETURN_OK; default: - FSFW_FLOGW("Invalid Subservice {}\n", subservice); + FSFW_LOGW("Invalid Subservice {}\n", subservice); return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -116,8 +116,8 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) { sendWiretappingTm(reply, static_cast(Subservice::REPLY_RAW)); break; default: - FSFW_FLOGET("handleUnrequestedReply: Unknown message with command ID {}\n", - reply->getCommand()); + FSFW_LOGET("handleUnrequestedReply: Unknown message with command ID {}\n", + reply->getCommand()); break; } // Must be reached by all cases to clear message diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 66cea1026..4ba7ed046 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -212,7 +212,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } default: - FSFW_FLOGW("handleReply: Invalid reply with reply command {}\n", command); + FSFW_LOGW("handleReply: Invalid reply with reply command {}\n", command); return CommandingServiceBase::INVALID_REPLY; } return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index f3068dad5..86c0898ab 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -95,7 +95,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, template uint8_t* SerialBufferAdapter::getBuffer() { if (buffer == nullptr) { - FSFW_FLOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n"); + FSFW_LOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n"); return nullptr; } return buffer; @@ -104,7 +104,7 @@ uint8_t* SerialBufferAdapter::getBuffer() { template const uint8_t* SerialBufferAdapter::getConstBuffer() const { if (constBuffer == nullptr) { - FSFW_FLOGE("{}", "getConstBuffer: Buffers are unitialized\n"); + FSFW_LOGE("{}", "getConstBuffer: Buffers are unitialized\n"); return nullptr; } return constBuffer; diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h index d378f98c6..d06d7d043 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.h +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -213,30 +213,13 @@ void error_st(const char* file, unsigned int line, fmt::format_string fmt, // The macros postfixed with T are the log variant with timing information #define FSFW_LOGI(...) sif::info(__VA_ARGS__) -#define FSFW_FLOGI(format, ...) sif::info(FMT_STRING(format), __VA_ARGS__) - #define FSFW_LOGIT(...) sif::info_t(__VA_ARGS__) -#define FSFW_FLOGIT(format, ...) sif::info_t(FMT_STRING(format), __VA_ARGS__) #define FSFW_LOGD(...) sif::debug(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGD(format, ...) sif::debug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) - #define FSFW_LOGDT(...) sif::debug_t(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGDT(format, ...) \ - sif::debug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) #define FSFW_LOGW(...) sif::warning_s(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGW(format, ...) \ - sif::warning_s(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) - #define FSFW_LOGWT(...) sif::warning_st(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGWT(format, ...) \ - sif::warning_st(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) #define FSFW_LOGE(...) sif::error_s(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGE(format, ...) \ - sif::error_s(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) - #define FSFW_LOGET(...) sif::error_st(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_FLOGET(format, ...) \ - sif::error_st(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__) diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index c050f7cc5..6cf99b78b 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -46,14 +46,14 @@ const uint8_t* ConstStorageAccessor::data() const { return constDataPointer; } size_t ConstStorageAccessor::size() const { if (internalState == AccessState::UNINIT) { - FSFW_FLOGW("{}", "size: Not initialized\n"); + FSFW_LOGW("{}", "size: Not initialized\n"); } return size_; } ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { - FSFW_FLOGW("{}", "getDataCopy: Not initialized\n"); + FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 00be83a62..44e8e818f 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -12,7 +12,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, NUMBER_OF_SUBPOOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { if (NUMBER_OF_SUBPOOLS == 0) { - FSFW_FLOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n"); + FSFW_LOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n"); } max_subpools_t index = 0; for (const auto& currentPoolConfig : poolConfig) { @@ -125,8 +125,8 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { sizeLists[storeId.poolIndex][storeId.packetIndex] = STORAGE_FREE; } else { // pool_index or packet_index is too large - FSFW_FLOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n", - SystemObject::getObjectId()); + FSFW_LOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n", + SystemObject::getObjectId()); status = ILLEGAL_STORAGE_ID; } return status; @@ -175,7 +175,7 @@ ReturnValue_t LocalPool::initialize() { // Check if any pool size is large than the maximum allowed. for (uint8_t count = 0; count < NUMBER_OF_SUBPOOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { - FSFW_FLOGW( + FSFW_LOGW( "LocalPool::initialize: Pool is too large- " "Max. allowed size is: {}\n", STORAGE_FREE - 1); @@ -199,7 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { - FSFW_FLOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); + FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index dbfe780b3..ae1418490 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -23,7 +23,7 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other) ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { if (internalState == AccessState::UNINIT) { - FSFW_FLOGW("{}", "getDataCopy: Not initialized\n"); + FSFW_LOGW("{}", "getDataCopy: Not initialized\n"); return HasReturnvaluesIF::RETURN_FAILED; } if (size_ > maxSize) { diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index 4ba02528e..81f40bdec 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -90,7 +90,7 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, in ReturnValue_t FixedSlotSequence::checkSequence() const { if (slotList.empty()) { - FSFW_FLOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n"); + FSFW_LOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n"); return FixedTimeslotTaskIF::SLOT_LIST_EMPTY; } @@ -98,7 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t result = customCheckFunction(slotList); if (result != HasReturnvaluesIF::RETURN_OK) { // Continue for now but print error output. - FSFW_FLOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result); + FSFW_LOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result); } } @@ -108,8 +108,8 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { if (slot.executableObject == nullptr) { errorCount++; } else if (slot.pollingTimeMs < time) { - FSFW_FLOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n", - slot.pollingTimeMs, time); + FSFW_LOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n", + slot.pollingTimeMs, time); errorCount++; } else { // All ok, print slot. @@ -144,7 +144,7 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } } if (count > 0) { - FSFW_FLOGE( + FSFW_LOGE( "FixedSlotSequence::intializeSequenceAfterTaskCreation: Counted {} " "failed initializations\n", count); diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 8dcb39e95..effa72831 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -27,7 +27,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { size_t size = 0; ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("{}", "selectDestination: Getting data from store failed"); + FSFW_LOGWT("{}", "selectDestination: Getting data from store failed"); } SpacePacketBase currentPacket(packet); diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 475ec1998..de810bd7d 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -22,8 +22,8 @@ CFDPDistributor::~CFDPDistributor() {} CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = this->currentMessage.getStorageId(); - FSFW_FLOGI("selectDestination was called with pool index {} and packet index {}\n", - storeId.poolIndex, storeId.packetIndex); + FSFW_LOGI("selectDestination was called with pool index {} and packet index {}\n", + storeId.poolIndex, storeId.packetIndex); #endif TcMqMapIter queueMapIt = this->queueMap.end(); if (this->currentPacket == nullptr) { @@ -33,8 +33,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { if (currentPacket->getWholeData() != nullptr) { tcStatus = checker.checkPacket(currentPacket); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGWT("selectDestination: Packet format invalid, code {}\n", - static_cast(tcStatus)); + FSFW_LOGWT("selectDestination: Packet format invalid, code {}\n", static_cast(tcStatus)); } queueMapIt = this->queueMap.find(0); } else { @@ -43,7 +42,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { if (queueMapIt == this->queueMap.end()) { tcStatus = DESTINATION_NOT_FOUND; - FSFW_FLOGWT("{}", "handlePacket: Destination not found\n"); + FSFW_LOGWT("{}", "handlePacket: Destination not found\n"); } if (tcStatus != RETURN_OK) { @@ -56,11 +55,11 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { uint16_t handlerId = handler->getIdentifier(); // should be 0, because CFDPHandler does not set a set a service-ID - FSFW_FLOGIT("CFDPDistributor::registerHandler: Handler ID {}\n", static_cast(handlerId)); + FSFW_LOGIT("CFDPDistributor::registerHandler: Handler ID {}\n", static_cast(handlerId)); MessageQueueId_t queue = handler->getRequestQueue(); auto returnPair = queueMap.emplace(handlerId, queue); if (not returnPair.second) { - FSFW_FLOGE("{}", "CFDPDistributor::registerHandler: Service ID already exists in map\n"); + FSFW_LOGE("{}", "CFDPDistributor::registerHandler: Service ID already exists in map\n"); return SERVICE_ID_ALREADY_EXISTS; } return HasReturnvaluesIF::RETURN_OK; @@ -97,7 +96,7 @@ ReturnValue_t CFDPDistributor::initialize() { auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); if (ccsdsDistributor == nullptr) { - FSFW_FLOGE("{}", "initialize: Packet source invalid. Does it implement CCSDSDistributorIF?\n"); + FSFW_LOGE("{}", "initialize: Packet source invalid. Does it implement CCSDSDistributorIF?\n"); return RETURN_FAILED; } return ccsdsDistributor->registerApplication(this); diff --git a/src/fsfw/tcdistribution/PUSDistributor.cpp b/src/fsfw/tcdistribution/PUSDistributor.cpp index 36ab75a74..bcd314541 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.cpp +++ b/src/fsfw/tcdistribution/PUSDistributor.cpp @@ -44,7 +44,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { } else if (tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) { keyword = "incomplete packet"; } - FSFW_FLOGWT("selectDestination: Packet format invalid, {} error\n", keyword); + FSFW_LOGWT("selectDestination: Packet format invalid, {} error\n", keyword); #endif } uint32_t queue_id = currentPacket->getService(); diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index 42c283705..b9b3a999c 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -33,9 +33,9 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { - FSFW_FLOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); + FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); for (const auto& queueMapIter : queueMap) { - FSFW_FLOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); + FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); } } diff --git a/src/fsfw/timemanager/Stopwatch.cpp b/src/fsfw/timemanager/Stopwatch.cpp index f54dc389e..983c97134 100644 --- a/src/fsfw/timemanager/Stopwatch.cpp +++ b/src/fsfw/timemanager/Stopwatch.cpp @@ -31,10 +31,10 @@ void Stopwatch::display() { if (displayMode == StopwatchDisplayMode::MILLIS) { auto timeMillis = static_cast(elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000); - FSFW_FLOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis); + FSFW_LOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis); } else if (displayMode == StopwatchDisplayMode::SECONDS) { - FSFW_FLOGIT("Stopwatch::display: {} seconds elapsed\n", - static_cast(timevalOperations::toDouble(elapsedTime))); + FSFW_LOGIT("Stopwatch::display: {} seconds elapsed\n", + static_cast(timevalOperations::toDouble(elapsedTime))); } } diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 03ae5427d..891585937 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -18,7 +18,7 @@ uint8_t SpacePacketBase::getPacketVersionNumber(void) { ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount) { if (data == nullptr) { - FSFW_FLOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n"); + FSFW_LOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n"); return HasReturnvaluesIF::RETURN_FAILED; } // reset header to zero: diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 816ffbc58..5f8957091 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -11,6 +11,6 @@ CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {} CFDPPacket::~CFDPPacket() {} void CFDPPacket::print() { - FSFW_FLOGI("{}", "CFDPPacket::print:\n"); + FSFW_LOGI("{}", "CFDPPacket::print:\n"); arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp index ad07e2557..975f3bb6c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp @@ -89,13 +89,13 @@ void TmPacketStoredBase::handleStoreFailure(const char *const packetType, Return switch (result) { #if FSFW_CPP_OSTREAM_ENABLED == 1 case (StorageManagerIF::DATA_STORAGE_FULL): { - FSFW_FLOGWT("handleStoreFailure: {} | Store full for packet with size {}\n", packetType, - sizeToReserve); + FSFW_LOGWT("handleStoreFailure: {} | Store full for packet with size {}\n", packetType, + sizeToReserve); break; } case (StorageManagerIF::DATA_TOO_LARGE): { - FSFW_FLOGWT("handleStoreFailure: {} | Data with size {} too large\n", packetType, - sizeToReserve); + FSFW_LOGWT("handleStoreFailure: {} | Data with size {} too large\n", packetType, + sizeToReserve); break; } #else diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 40a33df97..36e8981d0 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -95,7 +95,7 @@ void CommandingServiceBase::handleCommandQueue() { } else if (result == MessageQueueIF::EMPTY) { break; } else { - FSFW_FLOGWT( + FSFW_LOGWT( "CommandingServiceBase::handleCommandQueue: Receiving message failed" "with code {}", result); diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index a8cf58c96..0786d2250 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -22,7 +22,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); if (result != RETURN_OK) { - FSFW_FLOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result); + FSFW_LOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result); return RETURN_FAILED; } return RETURN_OK; @@ -71,8 +71,8 @@ void PusServiceBase::handleRequestQueue() { // ": no new packet." << std::endl; break; } else { - FSFW_FLOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId, - status); + FSFW_LOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId, + status); } } } @@ -89,7 +89,7 @@ ReturnValue_t PusServiceBase::initialize() { auto* destService = ObjectManager::instance()->get(packetDestination); auto* distributor = ObjectManager::instance()->get(packetSource); if (destService == nullptr or distributor == nullptr) { - FSFW_FLOGWT( + FSFW_LOGWT( "ctor: Service {} | Make sure static packetSource and packetDestination " "are defined correctly\n", serviceId); diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index f8c70cff9..82ab4fbf2 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -37,7 +37,7 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPackets this->maxNumberOfPacketsStored = maxNumberOfPacketsStored_; return RETURN_OK; } else { - FSFW_FLOGW( + FSFW_LOGW( "setMaxNumberOfPacketsStored: Passed number of packets {} stored exceeds " "limit {}\nKeeping default value\n", maxNumberOfPacketsStored_, LIMIT_DOWNLINK_PACKETS_STORED); @@ -87,7 +87,7 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if (result != RETURN_OK) { - FSFW_FLOGET("handleTm: Error handling TM queue with error code {:#04x}\n", result); + FSFW_LOGET("handleTm: Error handling TM queue with error code {:#04x}\n", result); status = result; } diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 8323362ae..6b5ae8261 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -26,8 +26,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB currentPacket->getPacketSequenceControl(), 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGET("VerificationReporter::sendSuccessReport: Error writing to queue. Code: {}\n", - status); + FSFW_LOGET("VerificationReporter::sendSuccessReport: Error writing to queue. Code: {}\n", + status); } } @@ -41,7 +41,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGET( + FSFW_LOGET( "VerificationReporter::sendSuccessReport: Error writing " "to queue. Code: {}\n", status); @@ -62,7 +62,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - FSFW_FLOGET( + FSFW_LOGET( "VerificationReporter::sendFailureReport: Error writing " "to queue. Code: {}\n", status); diff --git a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 12f8501bc..47ff80a65 100644 --- a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -17,7 +17,7 @@ TestDevice::~TestDevice() {} void TestDevice::performOperationHook() { if (periodicPrintout) { - FSFW_FLOGI("TestDevice {} | performOperationHook: Alive!\n", deviceIdx); + FSFW_LOGI("TestDevice {} | performOperationHook: Alive!\n", deviceIdx); } if (oneShot) { @@ -27,7 +27,7 @@ void TestDevice::performOperationHook() { void TestDevice::doStartUp() { if (fullInfoPrintout) { - FSFW_FLOGI("TestDevice {} | doStartUp: Switching On\n", deviceIdx); + FSFW_LOGI("TestDevice {} | doStartUp: Switching On\n", deviceIdx); } setMode(_MODE_TO_ON); @@ -35,7 +35,7 @@ void TestDevice::doStartUp() { void TestDevice::doShutDown() { if (fullInfoPrintout) { - FSFW_FLOGI("TestDevice {} | doShutDown: Switching Off\n", deviceIdx); + FSFW_LOGI("TestDevice {} | doShutDown: Switching Off\n", deviceIdx); } setMode(_MODE_SHUT_DOWN); @@ -53,7 +53,7 @@ ReturnValue_t TestDevice::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { if (mode == _MODE_TO_ON) { if (fullInfoPrintout) { - FSFW_FLOGI( + FSFW_LOGI( "TestDevice {} | buildTransitionDeviceCommand: Was called" " from _MODE_TO_ON mode\n", deviceIdx); @@ -61,7 +61,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { } if (mode == _MODE_TO_NORMAL) { if (fullInfoPrintout) { - FSFW_FLOGI( + FSFW_LOGI( "TestDevice {} | buildTransitionDeviceCommand: Was called " "from _MODE_TO_NORMAL mode\n", deviceIdx); @@ -71,7 +71,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { } if (mode == _MODE_SHUT_DOWN) { if (fullInfoPrintout) { - FSFW_FLOGI( + FSFW_LOGI( "TestDevice {} | buildTransitionDeviceCommand: Was called " "from _MODE_SHUT_DOWN mode\n", deviceIdx); @@ -85,7 +85,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { void TestDevice::doTransition(Mode_t modeFrom, Submode_t submodeFrom) { if (mode == _MODE_TO_NORMAL) { if (fullInfoPrintout) { - FSFW_FLOGI( + FSFW_LOGI( "TestDevice {} | doTransition: Custom transition to " "normal mode\n", deviceIdx); diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.cpp b/tests/src/fsfw_tests/internal/UnittDefinitions.cpp index f2822af30..87b60de90 100644 --- a/tests/src/fsfw_tests/internal/UnittDefinitions.cpp +++ b/tests/src/fsfw_tests/internal/UnittDefinitions.cpp @@ -3,6 +3,6 @@ #include "fsfw/serviceinterface.h" ReturnValue_t unitt::put_error(const std::string& errorId) { - FSFW_FLOGET("Unit Tester error: Failed at test ID {}\n", errorId); + FSFW_LOGET("Unit Tester error: Failed at test ID {}\n", errorId); return HasReturnvaluesIF::RETURN_FAILED; } -- 2.34.1 From f518bc53db808b2fcbb947752bcdfa4343772d8b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 01:14:23 +0200 Subject: [PATCH 05/16] moved old loggers to archive --- .../archive}/ServiceInterface.h | 0 .../archive}/ServiceInterfaceBuffer.cpp | 0 .../archive}/ServiceInterfaceBuffer.h | 0 .../archive}/ServiceInterfacePrinter.cpp | 0 .../archive}/ServiceInterfacePrinter.h | 0 .../archive}/ServiceInterfaceStream.cpp | 0 .../archive}/ServiceInterfaceStream.h | 0 .../archive}/serviceInterfaceDefintions.h | 0 src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 2 +- .../datapoollocal/LocalDataPoolManager.cpp | 81 ++++++++----------- src/fsfw/datapoollocal/LocalDataPoolManager.h | 9 +-- src/fsfw/datapoollocal/LocalPoolVariable.h | 2 +- src/fsfw/datapoollocal/LocalPoolVector.h | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 61 +++++++------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 5 +- src/fsfw/events/EventManager.h | 2 +- src/fsfw/health/HealthHelper.cpp | 2 +- .../internalerror/InternalErrorReporter.cpp | 2 +- src/fsfw/modes/ModeHelper.cpp | 2 +- .../monitoring/MonitoringMessageContent.h | 2 +- src/fsfw/objectmanager/ObjectManager.cpp | 2 +- src/fsfw/objectmanager/ObjectManagerIF.h | 2 +- src/fsfw/osal/common/TcpTmTcBridge.cpp | 2 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 2 +- src/fsfw/osal/host/Clock.cpp | 2 +- src/fsfw/osal/host/MessageQueue.cpp | 2 +- src/fsfw/osal/host/Mutex.cpp | 4 +- src/fsfw/osal/host/QueueFactory.cpp | 2 +- src/fsfw/osal/host/QueueMapManager.cpp | 2 +- src/fsfw/osal/linux/tcpipHelpers.cpp | 5 -- src/fsfw/power/PowerSwitcher.cpp | 2 +- src/fsfw/pus/CService200ModeCommanding.cpp | 4 +- src/fsfw/pus/Service17Test.cpp | 4 +- src/fsfw/pus/Service20ParameterManagement.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 2 +- src/fsfw/pus/Service9TimeManagement.cpp | 4 +- src/fsfw/pus/servicepackets/Service2Packets.h | 2 +- src/fsfw/serviceinterface.h | 1 - src/fsfw/serviceinterface/CMakeLists.txt | 3 - src/fsfw/storagemanager/LocalPool.h | 2 +- src/fsfw/subsystem/SubsystemBase.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 6 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 2 +- .../tmtcpacket/pus/tm/TmPacketStoredBase.cpp | 17 ---- .../tmtcpacket/pus/tm/TmPacketStoredPusA.cpp | 6 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.cpp | 2 +- .../integration/controller/TestController.cpp | 4 +- .../fsfw_tests/integration/task/TestTask.cpp | 4 +- .../fsfw_tests/internal/UnittDefinitions.h | 2 +- .../internal/osal/testSemaphore.cpp | 2 +- 51 files changed, 115 insertions(+), 157 deletions(-) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterface.h (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfaceBuffer.cpp (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfaceBuffer.h (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfacePrinter.cpp (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfacePrinter.h (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfaceStream.cpp (100%) rename {src/fsfw/serviceinterface => misc/archive}/ServiceInterfaceStream.h (100%) rename {src/fsfw/serviceinterface => misc/archive}/serviceInterfaceDefintions.h (100%) diff --git a/src/fsfw/serviceinterface/ServiceInterface.h b/misc/archive/ServiceInterface.h similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterface.h rename to misc/archive/ServiceInterface.h diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/misc/archive/ServiceInterfaceBuffer.cpp similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp rename to misc/archive/ServiceInterfaceBuffer.cpp diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/misc/archive/ServiceInterfaceBuffer.h similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfaceBuffer.h rename to misc/archive/ServiceInterfaceBuffer.h diff --git a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp b/misc/archive/ServiceInterfacePrinter.cpp similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp rename to misc/archive/ServiceInterfacePrinter.cpp diff --git a/src/fsfw/serviceinterface/ServiceInterfacePrinter.h b/misc/archive/ServiceInterfacePrinter.h similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfacePrinter.h rename to misc/archive/ServiceInterfacePrinter.h diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.cpp b/misc/archive/ServiceInterfaceStream.cpp similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfaceStream.cpp rename to misc/archive/ServiceInterfaceStream.cpp diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/misc/archive/ServiceInterfaceStream.h similarity index 100% rename from src/fsfw/serviceinterface/ServiceInterfaceStream.h rename to misc/archive/ServiceInterfaceStream.h diff --git a/src/fsfw/serviceinterface/serviceInterfaceDefintions.h b/misc/archive/serviceInterfaceDefintions.h similarity index 100% rename from src/fsfw/serviceinterface/serviceInterfaceDefintions.h rename to misc/archive/serviceInterfaceDefintions.h diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index 8650c29e7..c7e78fb81 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -6,8 +6,8 @@ #include "../datapool/PoolEntryIF.h" #include "../housekeeping/HousekeepingMessage.h" #include "../ipc/MessageQueueSenderIF.h" -#include "../serviceinterface/ServiceInterface.h" #include "LocalDataPoolManager.h" +#include "fsfw/serviceinterface.h" #include "localPoolDefinitions.h" class AccessPoolManagerIF; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 744573104..ea0879838 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -3,6 +3,7 @@ #include #include +#include "fsfw/FSFW.h" #include "fsfw/datapoollocal.h" #include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "fsfw/housekeeping/HousekeepingSetPacket.h" @@ -21,15 +22,15 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQue bool appendValidityBuffer) : appendValidityBuffer(appendValidityBuffer) { if (owner == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Invalid supplied owner"); + printWarningOrError(sif::LogLevel::WARNING, "ctor", HasReturnvaluesIF::RETURN_FAILED, + "Invalid supplied owner"); return; } this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Could not create mutex"); + printWarningOrError(sif::LogLevel::ERROR, "ctor", HasReturnvaluesIF::RETURN_FAILED, + "Could not create mutex"); } hkQueue = queueToUse; @@ -44,25 +45,25 @@ LocalDataPoolManager::~LocalDataPoolManager() { ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { if (queueToUse == nullptr) { /* Error, all destinations invalid */ - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", QUEUE_OR_DESTINATION_INVALID); + printWarningOrError(sif::LogLevel::ERROR, "initialize", QUEUE_OR_DESTINATION_INVALID); } hkQueue = queueToUse; ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { /* Error, all destinations invalid */ - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", HasReturnvaluesIF::RETURN_FAILED, + printWarningOrError(sif::LogLevel::ERROR, "initialize", HasReturnvaluesIF::RETURN_FAILED, "Could not set IPC store."); return HasReturnvaluesIF::RETURN_FAILED; } if (defaultHkDestination != objects::NO_OBJECT) { - AcceptsHkPacketsIF* hkPacketReceiver = + auto* hkPacketReceiver = ObjectManager::instance()->get(defaultHkDestination); if (hkPacketReceiver != nullptr) { hkDestinationId = hkPacketReceiver->getHkQueue(); } else { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", QUEUE_OR_DESTINATION_INVALID); + printWarningOrError(sif::LogLevel::ERROR, "initialize", QUEUE_OR_DESTINATION_INVALID); return QUEUE_OR_DESTINATION_INVALID; } } @@ -84,7 +85,7 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { return result; } - printWarningOrError(sif::OutputTypes::OUT_WARNING, "initializeHousekeepingPoolEntriesOnce", + printWarningOrError(sif::LogLevel::WARNING, "initializeHousekeepingPoolEntriesOnce", HasReturnvaluesIF::RETURN_FAILED, "The map should only be initialized once"); return HasReturnvaluesIF::RETURN_OK; } @@ -150,8 +151,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner, receiver.dataId.localPoolId); if (poolObj == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleNotificationUpdate", - POOLOBJECT_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "handleNotificationUpdate", POOLOBJECT_NOT_FOUND); return POOLOBJECT_NOT_FOUND; } if (poolObj->hasChanged()) { @@ -170,8 +170,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, receiver.dataId.sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleNotificationUpdate", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "handleNotificationUpdate", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } if (dataSet->hasChanged()) { @@ -199,7 +198,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner, receiver.dataId.localPoolId); if (poolObj == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleNotificationSnapshot", + printWarningOrError(sif::LogLevel::WARNING, "handleNotificationSnapshot", POOLOBJECT_NOT_FOUND); return POOLOBJECT_NOT_FOUND; } @@ -235,8 +234,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, receiver.dataId.sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleNotificationSnapshot", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "handleNotificationSnapshot", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } @@ -245,9 +243,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } /* Prepare and send update snapshot */ - timeval now; + timeval now{}; Clock::getClock_timeval(&now); - CCSDSTime::CDS_short cds; + CCSDSTime::CDS_short cds{}; CCSDSTime::convertToCcsds(&cds, &now); HousekeepingSnapshot updatePacket( reinterpret_cast(&cds), sizeof(cds), @@ -342,7 +340,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e AcceptsHkPacketsIF* hkReceiverObject = ObjectManager::instance()->get(packetDestination); if (hkReceiverObject == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket", + printWarningOrError(sif::LogLevel::WARNING, "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID); return QUEUE_OR_DESTINATION_INVALID; } @@ -368,10 +366,9 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isDiagnostics, bool reportingEnabled, object_id_t packetDestination) { - AcceptsHkPacketsIF* hkReceiverObject = - ObjectManager::instance()->get(packetDestination); + auto* hkReceiverObject = ObjectManager::instance()->get(packetDestination); if (hkReceiverObject == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket", + printWarningOrError(sif::LogLevel::WARNING, "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID); return QUEUE_OR_DESTINATION_INVALID; } @@ -524,8 +521,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me case (HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): { LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleHousekeepingMessage", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "handleHousekeepingMessage", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } if (command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT and @@ -588,8 +584,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me ReturnValue_t LocalDataPoolManager::printPoolEntry(lp_id_t localPoolId) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "printPoolEntry", - localpool::POOL_ENTRY_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "printPoolEntry", localpool::POOL_ENTRY_NOT_FOUND); return localpool::POOL_ENTRY_NOT_FOUND; } poolIter->second->print(); @@ -606,8 +601,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, MessageQueueId_t destination) { if (dataSet == nullptr) { /* Configuration error. */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "generateHousekeepingPacket", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } @@ -630,14 +624,14 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, if (hkQueue == nullptr) { /* Error, no queue available to send packet with. */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket", + printWarningOrError(sif::LogLevel::WARNING, "generateHousekeepingPacket", QUEUE_OR_DESTINATION_INVALID); return QUEUE_OR_DESTINATION_INVALID; } if (destination == MessageQueueIF::NO_QUEUE) { if (hkDestinationId == MessageQueueIF::NO_QUEUE) { /* Error, all destinations invalid */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket", + printWarningOrError(sif::LogLevel::WARNING, "generateHousekeepingPacket", QUEUE_OR_DESTINATION_INVALID); } destination = hkDestinationId; @@ -671,8 +665,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { sid_t sid = receiver.dataId.sid; LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "performPeriodicHkGeneration", DATASET_NOT_FOUND); return; } @@ -703,8 +696,7 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool ena bool isDiagnostics) { LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "togglePeriodicGeneration", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } @@ -726,8 +718,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float ne bool isDiagnostics) { LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "changeCollectionInterval", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } @@ -752,8 +743,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i /* Get and check dataset first. */ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "performPeriodicHkGeneration", - DATASET_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "performPeriodicHkGeneration", DATASET_NOT_FOUND); return DATASET_NOT_FOUND; } @@ -774,7 +764,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i store_address_t storeId; ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize, &storePtr); if (result != HasReturnvaluesIF::RETURN_OK) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "generateSetStructurePacket", + printWarningOrError(sif::LogLevel::ERROR, "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED, "Could not get free element from IPC store."); return result; @@ -788,7 +778,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i return result; } if (expectedSize != size) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateSetStructurePacket", + printWarningOrError(sif::LogLevel::WARNING, "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED, "Expected size is not equal to serialized size"); } @@ -821,9 +811,8 @@ MutexIF* LocalDataPoolManager::getLocalPoolMutex() { return this->mutex; } object_id_t LocalDataPoolManager::getCreatorObjectId() const { return owner->getObjectId(); } -void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, - const char* functionName, ReturnValue_t error, - const char* errorPrint) { +void LocalDataPoolManager::printWarningOrError(sif::LogLevel outputType, const char* functionName, + ReturnValue_t error, const char* errorPrint) { #if FSFW_VERBOSE_LEVEL >= 1 if (errorPrint == nullptr) { if (error == DATASET_NOT_FOUND) { @@ -831,7 +820,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, } else if (error == POOLOBJECT_NOT_FOUND) { errorPrint = "Pool Object not found"; } else if (error == HasReturnvaluesIF::RETURN_FAILED) { - if (outputType == sif::OutputTypes::OUT_WARNING) { + if (outputType == sif::LogLevel::WARNING) { errorPrint = "Generic Warning"; } else { errorPrint = "Generic error"; @@ -851,9 +840,9 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, objectId = owner->getObjectId(); } - if (outputType == sif::OutputTypes::OUT_WARNING) { + if (outputType == sif::LogLevel::WARNING) { FSFW_LOGWT("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); - } else if (outputType == sif::OutputTypes::OUT_ERROR) { + } else if (outputType == sif::LogLevel::ERROR) { FSFW_LOGET("{} | Object ID {} | {}\n", functionName, objectId, errorPrint); } #endif /* #if FSFW_VERBOSE_LEVEL >= 1 */ diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index e7ec0b6fa..1d0a56e99 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -16,7 +16,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/ipc/MutexIF.h" #include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -375,7 +375,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver, ReturnValue_t& status); ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId); - void printWarningOrError(sif::OutputTypes outputType, const char* functionName, + void printWarningOrError(sif::LogLevel outputType, const char* functionName, ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, const char* errorPrint = nullptr); }; @@ -389,14 +389,13 @@ inline ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry", - localpool::POOL_ENTRY_NOT_FOUND); + printWarningOrError(sif::LogLevel::WARNING, "fetchPoolEntry", localpool::POOL_ENTRY_NOT_FOUND); return localpool::POOL_ENTRY_NOT_FOUND; } *poolEntry = dynamic_cast*>(poolIter->second); if (*poolEntry == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "fetchPoolEntry", + printWarningOrError(sif::LogLevel::WARNING, "fetchPoolEntry", localpool::POOL_ENTRY_TYPE_CONFLICT); return localpool::POOL_ENTRY_TYPE_CONFLICT; } diff --git a/src/fsfw/datapoollocal/LocalPoolVariable.h b/src/fsfw/datapoollocal/LocalPoolVariable.h index 818e48837..06909f312 100644 --- a/src/fsfw/datapoollocal/LocalPoolVariable.h +++ b/src/fsfw/datapoollocal/LocalPoolVariable.h @@ -5,11 +5,11 @@ #include "../datapool/PoolVariableIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../serialize/SerializeAdapter.h" -#include "../serviceinterface/ServiceInterface.h" #include "AccessLocalPoolF.h" #include "HasLocalDataPoolIF.h" #include "LocalDataPoolManager.h" #include "LocalPoolObjectBase.h" +#include "fsfw/serviceinterface.h" #include "internal/LocalDpManagerAttorney.h" /** diff --git a/src/fsfw/datapoollocal/LocalPoolVector.h b/src/fsfw/datapoollocal/LocalPoolVector.h index aaaa051d0..26ceafb9b 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.h +++ b/src/fsfw/datapoollocal/LocalPoolVector.h @@ -6,8 +6,8 @@ #include "../datapool/PoolVariableIF.h" #include "../datapoollocal/LocalDataPoolManager.h" #include "../serialize/SerializeAdapter.h" -#include "../serviceinterface/ServiceInterface.h" #include "LocalPoolObjectBase.h" +#include "fsfw/serviceinterface.h" #include "internal/LocalDpManagerAttorney.h" /** diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index e51043d92..437e94e8e 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -8,7 +8,7 @@ #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/subsystem/SubsystemBase.h" #include "fsfw/thermal/ThermalComponentIF.h" @@ -45,16 +45,16 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", - HasReturnvaluesIF::RETURN_FAILED, "Invalid cookie"); + printWarningOrError(sif::LogLevel::ERROR, "DeviceHandlerBase", HasReturnvaluesIF::RETURN_FAILED, + "Invalid cookie"); } if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFdirParentId); } } -void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) { - this->hkDestination = hkDestination; +void DeviceHandlerBase::setHkDestination(object_id_t hkDestination_) { + this->hkDestination = hkDestination_; } void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId, @@ -130,22 +130,22 @@ ReturnValue_t DeviceHandlerBase::initialize() { communicationInterface = ObjectManager::instance()->get(deviceCommunicationId); if (communicationInterface == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", - ObjectManagerIF::CHILD_INIT_FAILED, "Passed communication IF invalid"); + printWarningOrError(sif::LogLevel::ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, + "Passed communication IF invalid"); return ObjectManagerIF::CHILD_INIT_FAILED; } result = communicationInterface->initializeInterface(comCookie); if (result != RETURN_OK) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", - ObjectManagerIF::CHILD_INIT_FAILED, "ComIF initialization failed"); + printWarningOrError(sif::LogLevel::ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, + "ComIF initialization failed"); return result; } IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); if (IPCStore == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", - ObjectManagerIF::CHILD_INIT_FAILED, "IPC Store not set up"); + printWarningOrError(sif::LogLevel::ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, + "IPC Store not set up"); return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -153,8 +153,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { auto* rawReceiver = ObjectManager::instance()->get(rawDataReceiverId); if (rawReceiver == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", - ObjectManagerIF::CHILD_INIT_FAILED, + printWarningOrError(sif::LogLevel::ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Raw receiver object ID set but no valid object found."); FSFW_LOGE("{}", "Make sure the raw receiver object is set up properly " @@ -167,8 +166,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { if (powerSwitcherId != objects::NO_OBJECT) { powerSwitcher = ObjectManager::instance()->get(powerSwitcherId); if (powerSwitcher == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", - ObjectManagerIF::CHILD_INIT_FAILED, + printWarningOrError(sif::LogLevel::ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); FSFW_LOGE("{}", "Make sure the power switcher object is set up " @@ -305,8 +303,7 @@ void DeviceHandlerBase::doStateMachine() { sprintf(printout, "Transition timeout (%lu) occured !", static_cast(childTransitionDelay)); /* Common configuration error for development, so print it */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine", RETURN_FAILED, - printout); + printWarningOrError(sif::LogLevel::WARNING, "doStateMachine", RETURN_FAILED, printout); #endif triggerEvent(MODE_TRANSITION_FAILED, childTransitionFailure, 0); setMode(transitionSourceMode, transitionSourceSubMode); @@ -598,8 +595,8 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl } DeviceCommandInfo* info = &replyInfo.command->second; if (info == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", - HasReturnvaluesIF::RETURN_FAILED, "Command pointer not found"); + printWarningOrError(sif::LogLevel::ERROR, "replyToReply", HasReturnvaluesIF::RETURN_FAILED, + "Command pointer not found"); return; } @@ -740,7 +737,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD case RETURN_OK: handleReply(receivedData, foundId, foundLen); if (foundLen == 0) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "parseReply", + printWarningOrError(sif::LogLevel::WARNING, "parseReply", ObjectManagerIF::CHILD_INIT_FAILED, "Found length is one, parsing might be stuck"); } @@ -752,7 +749,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); } if (foundLen == 0) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "parseReply", + printWarningOrError(sif::LogLevel::ERROR, "parseReply", ObjectManagerIF::CHILD_INIT_FAILED, "Power switcher set but no valid object found."); FSFW_LOGW("{}", @@ -1272,7 +1269,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue return result; } -void DeviceHandlerBase::buildInternalCommand(void) { +void DeviceHandlerBase::buildInternalCommand() { /* Neither raw nor direct could build a command */ ReturnValue_t result = NOTHING_TO_SEND; DeviceCommandId_t deviceCommandId = NO_COMMAND_ID; @@ -1280,7 +1277,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { result = buildNormalDeviceCommand(&deviceCommandId); if (result == BUSY) { /* So we can track misconfigurations */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", + printWarningOrError(sif::LogLevel::WARNING, "buildInternalCommand", HasReturnvaluesIF::RETURN_FAILED, "Busy."); /* No need to report this */ result = NOTHING_TO_SEND; @@ -1298,14 +1295,14 @@ void DeviceHandlerBase::buildInternalCommand(void) { return; } if (result == RETURN_OK) { - DeviceCommandMap::iterator iter = deviceCommandMap.find(deviceCommandId); + auto iter = deviceCommandMap.find(deviceCommandId); if (iter == deviceCommandMap.end()) { #if FSFW_VERBOSE_LEVEL >= 1 char output[36]; sprintf(output, "Command 0x%08x unknown", static_cast(deviceCommandId)); // so we can track misconfigurations - printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", - COMMAND_NOT_SUPPORTED, output); + printWarningOrError(sif::LogLevel::WARNING, "buildInternalCommand", COMMAND_NOT_SUPPORTED, + output); #endif result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { @@ -1313,7 +1310,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { char output[36]; sprintf(output, "Command 0x%08x is executing", static_cast(deviceCommandId)); // so we can track misconfigurations - printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", + printWarningOrError(sif::LogLevel::WARNING, "buildInternalCommand", HasReturnvaluesIF::RETURN_FAILED, output); #endif // this is an internal command, no need to report a failure here, @@ -1334,7 +1331,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { ReturnValue_t DeviceHandlerBase::buildChildRawCommand() { return NOTHING_TO_SEND; } uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand) { - DeviceReplyMap::iterator iter = deviceReplyMap.find(deviceCommand); + auto iter = deviceReplyMap.find(deviceCommand); if (iter == deviceReplyMap.end()) { return 0; } @@ -1442,13 +1439,13 @@ void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { } } -void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const char* functionName, +void DeviceHandlerBase::printWarningOrError(sif::LogLevel errorType, const char* functionName, ReturnValue_t errorCode, const char* errorPrint) { if (errorPrint == nullptr) { if (errorCode == ObjectManagerIF::CHILD_INIT_FAILED) { errorPrint = "Initialization error"; } else if (errorCode == HasReturnvaluesIF::RETURN_FAILED) { - if (errorType == sif::OutputTypes::OUT_WARNING) { + if (errorType == sif::LogLevel::WARNING) { errorPrint = "Generic Warning"; } else { errorPrint = "Generic Error"; @@ -1461,10 +1458,10 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch functionName = "unknown function"; } - if (errorType == sif::OutputTypes::OUT_WARNING) { + if (errorType == sif::LogLevel::WARNING) { FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), errorPrint); - } else if (errorType == sif::OutputTypes::OUT_ERROR) { + } else if (errorType == sif::LogLevel::ERROR) { FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), errorPrint); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 84dcb8dcc..8d635db34 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -19,8 +19,7 @@ #include "fsfw/parameters/ParameterHelper.h" #include "fsfw/power/PowerSwitchIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/PeriodicTaskIF.h" @@ -1282,7 +1281,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param errorCode * @param errorPrint */ - void printWarningOrError(sif::OutputTypes errorType, const char *functionName, + void printWarningOrError(sif::LogLevel errorType, const char *functionName, ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, const char *errorPrint = nullptr); }; diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index f2d642ffb..d4994fdf5 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -6,12 +6,12 @@ #include "../ipc/MessageQueueIF.h" #include "../ipc/MutexIF.h" #include "../objectmanager/SystemObject.h" -#include "../serviceinterface/ServiceInterface.h" #include "../storagemanager/LocalPool.h" #include "../tasks/ExecutableObjectIF.h" #include "EventManagerIF.h" #include "FSFWConfig.h" #include "eventmatching/EventMatchTree.h" +#include "fsfw/serviceinterface.h" #if FSFW_OBJ_EVENT_TRANSLATION == 1 // forward declaration, should be implemented by mission diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 954a1e19d..97ab62055 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -1,6 +1,6 @@ #include "fsfw/health/HealthHelper.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : objectId(objectId), owner(owner) {} diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index 86a6cde48..e71cfaa1e 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -3,7 +3,7 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/ipc/MutexFactory.h" #include "fsfw/ipc/QueueFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth) : SystemObject(setObjectId), diff --git a/src/fsfw/modes/ModeHelper.cpp b/src/fsfw/modes/ModeHelper.cpp index 2ea392abc..0fd0aba47 100644 --- a/src/fsfw/modes/ModeHelper.cpp +++ b/src/fsfw/modes/ModeHelper.cpp @@ -2,7 +2,7 @@ #include "fsfw/ipc/MessageQueueSenderIF.h" #include "fsfw/modes/HasModesIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" ModeHelper::ModeHelper(HasModesIF* owner) : commandedMode(HasModesIF::MODE_OFF), diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index ebb473988..84c62aeed 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -7,10 +7,10 @@ #include "../serialize/SerialFixedArrayListAdapter.h" #include "../serialize/SerialLinkedListAdapter.h" #include "../serialize/SerializeElement.h" -#include "../serviceinterface/ServiceInterface.h" #include "../timemanager/TimeStamperIF.h" #include "HasMonitorsIF.h" #include "MonitoringIF.h" +#include "fsfw/serviceinterface.h" #include "monitoringConf.h" namespace Factory { diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 5d3267beb..9e3d8c699 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -36,7 +36,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; #endif - return this->RETURN_OK; + return ObjectManager::RETURN_OK; } else { FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", static_cast(id)); diff --git a/src/fsfw/objectmanager/ObjectManagerIF.h b/src/fsfw/objectmanager/ObjectManagerIF.h index 32a0942fe..fc421ad3c 100644 --- a/src/fsfw/objectmanager/ObjectManagerIF.h +++ b/src/fsfw/objectmanager/ObjectManagerIF.h @@ -2,9 +2,9 @@ #define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" -#include "../serviceinterface/ServiceInterface.h" #include "SystemObjectIF.h" #include "frameworkObjects.h" +#include "fsfw/serviceinterface.h" /** * @brief This class provides an interface to the global object manager. diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index b490082e2..42823b39b 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/osal/common/TcpTmTcBridge.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #ifdef PLATFORM_WIN diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index 1c9f09ea7..b8303088a 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/osal/common/tcpipHelpers.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #ifdef PLATFORM_WIN #include diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 20888b304..b1ef63a5c 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -4,7 +4,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/platform.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #if defined(PLATFORM_WIN) #include diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index b47498527..32b5fed63 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -6,7 +6,7 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/osal/host/QueueMapManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args) : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, args), diff --git a/src/fsfw/osal/host/Mutex.cpp b/src/fsfw/osal/host/Mutex.cpp index 4b7a95828..a22c80573 100644 --- a/src/fsfw/osal/host/Mutex.cpp +++ b/src/fsfw/osal/host/Mutex.cpp @@ -1,8 +1,8 @@ #include "fsfw/osal/host/Mutex.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" -Mutex::Mutex() {} +Mutex::Mutex() = default; ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { if (timeoutType == TimeoutType::BLOCKING) { diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index 732892caf..63b10fd76 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -5,7 +5,7 @@ #include "fsfw/ipc/MessageQueueMessageIF.h" #include "fsfw/ipc/MessageQueueSenderIF.h" #include "fsfw/osal/host/MessageQueue.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" QueueFactory* QueueFactory::factoryInstance = nullptr; diff --git a/src/fsfw/osal/host/QueueMapManager.cpp b/src/fsfw/osal/host/QueueMapManager.cpp index 7b20de532..0b7a4d48d 100644 --- a/src/fsfw/osal/host/QueueMapManager.cpp +++ b/src/fsfw/osal/host/QueueMapManager.cpp @@ -2,7 +2,7 @@ #include "fsfw/ipc/MutexFactory.h" #include "fsfw/ipc/MutexGuard.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" QueueMapManager* QueueMapManager::mqManagerInstance = nullptr; diff --git a/src/fsfw/osal/linux/tcpipHelpers.cpp b/src/fsfw/osal/linux/tcpipHelpers.cpp index aee7bd798..2d20ebb0c 100644 --- a/src/fsfw/osal/linux/tcpipHelpers.cpp +++ b/src/fsfw/osal/linux/tcpipHelpers.cpp @@ -95,12 +95,7 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s } } -#if FSFW_CPP_OSTREAM_ENABLED == 1 FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString); -#else - sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(), - errorSrcString.c_str(), infoString.c_str()); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ if (sleepDuration > 0) { TaskFactory::delayTask(sleepDuration); diff --git a/src/fsfw/power/PowerSwitcher.cpp b/src/fsfw/power/PowerSwitcher.cpp index 0a3f8521d..f32d83c82 100644 --- a/src/fsfw/power/PowerSwitcher.cpp +++ b/src/fsfw/power/PowerSwitcher.cpp @@ -1,7 +1,7 @@ #include "fsfw/power/PowerSwitcher.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2, PowerSwitcher::State_t setStartState) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 41be3d135..a2030238d 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service200Packets.h" #include "fsfw/serialize/SerialLinkedListAdapter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, @@ -13,7 +13,7 @@ CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId, uint1 : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { } -CService200ModeCommanding::~CService200ModeCommanding() {} +CService200ModeCommanding::~CService200ModeCommanding() = default; ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index f784acf4b..58bfc6caa 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -2,13 +2,13 @@ #include "fsfw/FSFW.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) : PusServiceBase(objectId, apid, serviceId), packetSubCounter(0) {} -Service17Test::~Service17Test() {} +Service17Test::~Service17Test() = default; ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index d173d9b9f..a3eaadcd6 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -5,7 +5,7 @@ #include "fsfw/parameters/ParameterMessage.h" #include "fsfw/parameters/ReceivesParameterMessagesIF.h" #include "fsfw/pus/servicepackets/Service20Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId, diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index d35cd9d40..7823ab4bb 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -4,7 +4,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service5Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid, diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 86eef93a0..359a20c18 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -2,14 +2,14 @@ #include "fsfw/events/EventManagerIF.h" #include "fsfw/pus/servicepackets/Service9Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/timemanager/CCSDSTime.h" Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId) : PusServiceBase(objectId, apid, serviceId) {} -Service9TimeManagement::~Service9TimeManagement() {} +Service9TimeManagement::~Service9TimeManagement() = default; ReturnValue_t Service9TimeManagement::performService() { return RETURN_OK; } diff --git a/src/fsfw/pus/servicepackets/Service2Packets.h b/src/fsfw/pus/servicepackets/Service2Packets.h index ecef71e9c..769966873 100644 --- a/src/fsfw/pus/servicepackets/Service2Packets.h +++ b/src/fsfw/pus/servicepackets/Service2Packets.h @@ -4,7 +4,7 @@ #include "../../action/ActionMessage.h" #include "../../objectmanager/SystemObjectIF.h" #include "../../serialize/SerialLinkedListAdapter.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/serviceinterface.h" /** * @brief Subservice 128 diff --git a/src/fsfw/serviceinterface.h b/src/fsfw/serviceinterface.h index 998d3d502..2b8d6eac0 100644 --- a/src/fsfw/serviceinterface.h +++ b/src/fsfw/serviceinterface.h @@ -2,6 +2,5 @@ #define FSFW_SRC_FSFW_SERVICEINTERFACE_H_ #include "serviceinterface/fmtWrapper.h" -//#include "serviceinterface/ServiceInterface.h" #endif /* FSFW_SRC_FSFW_SERVICEINTERFACE_H_ */ diff --git a/src/fsfw/serviceinterface/CMakeLists.txt b/src/fsfw/serviceinterface/CMakeLists.txt index 052b4ac54..39597d658 100644 --- a/src/fsfw/serviceinterface/CMakeLists.txt +++ b/src/fsfw/serviceinterface/CMakeLists.txt @@ -1,6 +1,3 @@ target_sources(${LIB_FSFW_NAME} PRIVATE fmtWrapper.cpp - ServiceInterfaceStream.cpp - ServiceInterfaceBuffer.cpp - ServiceInterfacePrinter.cpp ) \ No newline at end of file diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 01706e9c8..6c2173d47 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -9,7 +9,7 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageAccessor.h" #include "fsfw/storagemanager/StorageManagerIF.h" diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 60e6e8a4d..bd802df06 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -2,7 +2,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode, uint16_t commandQueueDepth) diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 838443372..601c1baca 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -1,7 +1,7 @@ #include "fsfw/tcdistribution/TcPacketCheckPUS.h" #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h" @@ -11,8 +11,8 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { - TcPacketStoredBase* storedPacket = dynamic_cast(currentPacket); - TcPacketPusBase* tcPacketBase = dynamic_cast(currentPacket); + auto* storedPacket = dynamic_cast(currentPacket); + auto* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { return RETURN_FAILED; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index e8f717172..84805ede3 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp @@ -7,7 +7,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/timemanager/CCSDSTime.h" TmPacketPusA::TmPacketPusA(uint8_t* setData) : TmPacketBase(setData) { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index ab690414d..3396a5bc3 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -7,7 +7,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/timemanager/CCSDSTime.h" TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp index 975f3bb6c..d18028f6e 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp @@ -87,7 +87,6 @@ void TmPacketStoredBase::handleStoreFailure(const char *const packetType, Return checkAndReportLostTm(); #if FSFW_VERBOSE_LEVEL >= 1 switch (result) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 case (StorageManagerIF::DATA_STORAGE_FULL): { FSFW_LOGWT("handleStoreFailure: {} | Store full for packet with size {}\n", packetType, sizeToReserve); @@ -98,22 +97,6 @@ void TmPacketStoredBase::handleStoreFailure(const char *const packetType, Return sizeToReserve); break; } -#else - case (StorageManagerIF::DATA_STORAGE_FULL): { - sif::printWarning( - "TmPacketStoredPus%s: Store full for packet with " - "size %d\n", - packetType, sizeToReserve); - break; - } - case (StorageManagerIF::DATA_TOO_LARGE): { - sif::printWarning( - "TmPacketStoredPus%s: Data with size " - "%d too large\n", - packetType, sizeToReserve); - break; - } -#endif } #endif } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp index 37ba63f3a..bb5c47880 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress) @@ -17,10 +17,10 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t s return; } uint8_t *pData = nullptr; - size_t sizeToReserve = getPacketMinimumSize() + size + headerSize; + size_t sizeToReserve = TmPacketPusA::getPacketMinimumSize() + size + headerSize; ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { + if (returnValue != StorageManagerIF::RETURN_OK) { handleStoreFailure("A", returnValue, sizeToReserve); return; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp index 9c170aa37..9b7fdf1aa 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" TmPacketStoredPusC::TmPacketStoredPusC(store_address_t setAddress) diff --git a/tests/src/fsfw_tests/integration/controller/TestController.cpp b/tests/src/fsfw_tests/integration/controller/TestController.cpp index 03f24311c..0d2dd8082 100644 --- a/tests/src/fsfw_tests/integration/controller/TestController.cpp +++ b/tests/src/fsfw_tests/integration/controller/TestController.cpp @@ -2,12 +2,12 @@ #include #include -#include +#include TestController::TestController(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth) : ExtendedControllerBase(objectId, parentId, commandQueueDepth) {} -TestController::~TestController() {} +TestController::~TestController() = default; ReturnValue_t TestController::handleCommandMessage(CommandMessage *message) { return HasReturnvaluesIF::RETURN_OK; diff --git a/tests/src/fsfw_tests/integration/task/TestTask.cpp b/tests/src/fsfw_tests/integration/task/TestTask.cpp index 765f780e6..3de8d1edb 100644 --- a/tests/src/fsfw_tests/integration/task/TestTask.cpp +++ b/tests/src/fsfw_tests/integration/task/TestTask.cpp @@ -1,7 +1,7 @@ #include "TestTask.h" #include -#include +#include MutexIF* TestTask::testLock = nullptr; @@ -12,7 +12,7 @@ TestTask::TestTask(object_id_t objectId) : SystemObject(objectId), testMode(test IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -TestTask::~TestTask() {} +TestTask::~TestTask() = default; ReturnValue_t TestTask::performOperation(uint8_t operationCode) { ReturnValue_t result = RETURN_OK; diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.h b/tests/src/fsfw_tests/internal/UnittDefinitions.h index a361b8b16..f6acd8b9d 100644 --- a/tests/src/fsfw_tests/internal/UnittDefinitions.h +++ b/tests/src/fsfw_tests/internal/UnittDefinitions.h @@ -6,7 +6,7 @@ #include #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" namespace tv { // POD test values diff --git a/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp b/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp index a3e4c2778..2de453097 100644 --- a/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp +++ b/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/FSFW.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/SemaphoreFactory.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw_tests/internal/UnittDefinitions.h" -- 2.34.1 From e8a5f1e095f64743e388729de0c9f53ca2e1565c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 01:28:26 +0200 Subject: [PATCH 06/16] some format fixes --- .../datapoollocal/LocalPoolObjectBase.cpp | 4 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 4 +- src/fsfw/fdir/FailureIsolationBase.cpp | 7 +-- src/fsfw/health/HealthHelper.cpp | 4 +- src/fsfw/objectmanager/ObjectManager.cpp | 10 ++--- src/fsfw/osal/host/FixedTimeslotTask.cpp | 2 +- src/fsfw/pus/Service20ParameterManagement.cpp | 2 +- src/fsfw/pus/Service2DeviceAccess.cpp | 2 +- src/fsfw/serviceinterface/fmtWrapper.h | 45 ++++++++++++++----- src/fsfw/storagemanager/LocalPool.cpp | 2 +- src/fsfw/tcdistribution/TcDistributor.cpp | 2 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 4 +- .../tmtcservices/VerificationReporter.cpp | 2 +- 13 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 5d0a3068f..ea0377ce7 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -34,7 +34,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, auto* hkOwner = ObjectManager::instance()->get(poolOwner); if (hkOwner == nullptr) { FSFW_LOGWT( - "ctor: The supplied pool owner {:#08x} did not implement the correct interface " + "ctor: The supplied pool owner {:#010x} did not implement the correct interface " "HasLocalDataPoolIF\n", poolOwner); return; @@ -94,6 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return errMsg = "Unknown error code"; } - FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, + FSFW_LOGW("{}: {} call | {} | Owner: {:#010x} | LPID: \n", variablePrintout, type, errMsg, objectId, lpId); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 437e94e8e..a3c636977 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1459,10 +1459,10 @@ void DeviceHandlerBase::printWarningOrError(sif::LogLevel errorType, const char* } if (errorType == sif::LogLevel::WARNING) { - FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + FSFW_LOGWT("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(), errorPrint); } else if (errorType == sif::LogLevel::ERROR) { - FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + FSFW_LOGET("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(), errorPrint); } } diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 39fbe0221..5ba8c51b5 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -35,7 +35,7 @@ ReturnValue_t FailureIsolationBase::initialize() { owner = ObjectManager::instance()->get(ownerId); if (owner == nullptr) { FSFW_LOGE( - "FailureIsolationBase::intialize: Owner object {:#08x} invalid. " + "FailureIsolationBase::intialize: Owner object {:#010x} invalid. " "Does it implement HasHealthIF?\n", ownerId); return ObjectManagerIF::CHILD_INIT_FAILED; @@ -44,8 +44,9 @@ ReturnValue_t FailureIsolationBase::initialize() { if (faultTreeParent != objects::NO_OBJECT) { auto* parentIF = ObjectManager::instance()->get(faultTreeParent); if (parentIF == nullptr) { - FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", - faultTreeParent); + FSFW_LOGW( + "intialize: Parent object {:#010x} invalid. Does it implement ConfirmsFailuresIF?\n", + faultTreeParent); return ObjectManagerIF::CHILD_INIT_FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 97ab62055..3dec65f83 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -69,7 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); + FSFW_LOGWT("informParent: Object ID {:#010x} | Sending health reply failed\n", objectId); } } @@ -86,7 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", + FSFW_LOGWT("handleSetHealthCommand: Object ID {:#010x} | Sending health reply failed\n", objectId); } } diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 9e3d8c699..df1325a79 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -38,7 +38,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { #endif return ObjectManager::RETURN_OK; } else { - FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", + FSFW_LOGET("ObjectManager::insert: Object ID {:#010x} is already in use\nTerminating program\n", static_cast(id)); // This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); @@ -54,7 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { #endif return RETURN_OK; } else { - FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id); + FSFW_LOGW("removeObject: Requested object {:#010x} not found\n", id); return NOT_FOUND; } } @@ -78,7 +78,7 @@ void ObjectManager::initialize() { result = it.second->initialize(); if (result != RETURN_OK) { object_id_t var = it.first; - FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, + FSFW_LOGWT("initialize: Object {:#010x} failed to initialize with code {:#06x}\n", var, result); errorCount++; } @@ -91,7 +91,7 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if (result != RETURN_OK) { - FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, + FSFW_LOGE("initialize: Object {:#010x} connection check failed with code {:#06x}\n", it.first, result); errorCount++; } @@ -106,7 +106,7 @@ void ObjectManager::printList() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info("ObjectManager: Object List contains:\n"); for (auto const& it : objectList) { - sif::info("{:#08x} | {:#08x}\n", it.first, fmt::ptr(it.second)); + sif::info("{:#010x} | {:#010x}\n", it.first, fmt::ptr(it.second)); } #endif } diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 76b003688..41a168397 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -116,7 +116,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotT return HasReturnvaluesIF::RETURN_OK; } - FSFW_LOGE("addSlot: Component {:#08x} not found, not adding it to PST\n", componentId); + FSFW_LOGE("addSlot: Component {:#010x} not found, not adding it to PST\n", componentId); return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index a3eaadcd6..6192723d6 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -56,7 +56,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { FSFW_LOGE( - "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#08x}\n" + "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#010x}\n" "Does it implement ReceivesParameterMessagesIF?\n", *objectId); return CommandingServiceBase::INVALID_OBJECT; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index b38bf75b6..5a6f8fcaa 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -132,7 +132,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("sendWiretappingTm: Data Lost in handleUnrequestedReply with failure ID {:#04x}\n", + FSFW_LOGW("sendWiretappingTm: Data Lost in handleUnrequestedReply with failure ID {:#06x}\n", result); return; } diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h index d06d7d043..f39caa5e6 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.h +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -44,7 +44,7 @@ template size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed, fmt::format_string fmt, T&&... args) noexcept { if (PRINT_MUTEX == nullptr) { - fmt::print("Please call sif::initialize at program startup\n"); + fmt::print("ERRROR | {} | Please call sif::initialize at program startup\n", __FILENAME__); return 0; } try { @@ -74,7 +74,7 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed PRINT_MUTEX->unlockMutex(); return bufPos; } catch (const fmt::v8::format_error& e) { - fmt::print("Printing failed with error: {}\n", e.what()); + fmt::print("ERROR | {} | Printing failed with error: {}\n", __FILENAME__, e.what()); PRINT_MUTEX->unlockMutex(); return 0; } @@ -83,7 +83,7 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed template size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args) noexcept { if (PRINT_MUTEX == nullptr) { - fmt::print("Please call sif::initialize at program startup\n"); + fmt::print("ERROR | {} | Please call sif::initialize at program startup\n", __FILENAME__); return 0; } try { @@ -118,17 +118,30 @@ size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args } template -void debug(const char* file, unsigned int line, fmt::format_string fmt, - T&&... args) noexcept { +void debug(fmt::format_string fmt, T&&... args) noexcept { + log(LogLevel::DEBUG, false, fmt, args...); +} + +template +void debug_t(fmt::format_string fmt, T&&... args) noexcept { + log(LogLevel::DEBUG, true, fmt, args...); +} + +/** + * Debug logger with source file information + */ +template +void debug_s(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, false, fmt, args...); } /** - * Debug logger with timestamp and file/line number prefix + * Debug logger with source file information and timestamp */ template -void debug_t(const char* file, unsigned int line, fmt::format_string fmt, - T&&... args) noexcept { +void debug_st(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, true, fmt, args...); } @@ -209,17 +222,27 @@ void error_st(const char* file, unsigned int line, fmt::format_string fmt, } // namespace sif // Helper macros to simplify calling the logger functions -// The macros prefixed with F can be used to print formatted output // The macros postfixed with T are the log variant with timing information #define FSFW_LOGI(...) sif::info(__VA_ARGS__) #define FSFW_LOGIT(...) sif::info_t(__VA_ARGS__) -#define FSFW_LOGD(...) sif::debug(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_LOGDT(...) sif::debug_t(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_LOGD(...) sif::debug_s(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_LOGDT(...) sif::debug_st(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGW(...) sif::warning_s(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGWT(...) sif::warning_st(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGE(...) sif::error_s(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGET(...) sif::error_st(__FILENAME__, __LINE__, __VA_ARGS__) + +// Using those reduced binary size marginally.. + +//#define FSFW_LOGD(...) sif::debug(__VA_ARGS__) +//#define FSFW_LOGDT(...) sif::debug_t(__VA_ARGS__) + +//#define FSFW_LOGW(...) sif::warning(__VA_ARGS__) +//#define FSFW_LOGWT(...) sif::warning_t(__VA_ARGS__) + +//#define FSFW_LOGE(...) sif::error(__VA_ARGS__) +//#define FSFW_LOGET(...) sif::error(__VA_ARGS__) diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 44e8e818f..54e00e75a 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -199,7 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { - FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); + FSFW_LOGW("ID {:#010x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index b9b3a999c..7a225e90f 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -35,7 +35,7 @@ ReturnValue_t TcDistributor::handlePacket() { void TcDistributor::print() { FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); for (const auto& queueMapIter : queueMap) { - FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); + FSFW_LOGI("{} \t| {:#010x}", queueMapIter.first, queueMapIter.second); } } diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 82ab4fbf2..d61f330df 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -87,7 +87,7 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if (result != RETURN_OK) { - FSFW_LOGET("handleTm: Error handling TM queue with error code {:#04x}\n", result); + FSFW_LOGET("handleTm: Error handling TM queue with error code {:#06x}\n", result); status = result; } @@ -183,7 +183,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { result = sendTm(data, size); if (result != RETURN_OK) { - FSFW_LOGW("handleStoredTm: Could not send stored downlink data, code {:#04x}\n", result); + FSFW_LOGW("handleStoredTm: Could not send stored downlink data, code {:#06x}\n", result); status = result; } packetSentCounter++; diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 6b5ae8261..f1c625e99 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -80,7 +80,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, uint8_t ackFlags step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGE("sendFailureReport: Error writing to queue. Code {:#04x}\n", status); + FSFW_LOGE("sendFailureReport: Error writing to queue. Code {:#06x}\n", status); } } -- 2.34.1 From fb1d775b524760bb3c299b47168604bad504f1f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 02:02:13 +0200 Subject: [PATCH 07/16] fmt is publicly linked now, enable lto by default --- CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61c145ded..ab370b10f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,14 @@ set(FSFW_FMT_LIB_VERSION v${FSFW_FMT_LIB_MAJOR_VERSION}.1.1 CACHE STRING "{fmt} library exact version requirement" ) +include(CheckIPOSupported) +check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR) +if(NOT IPO_SUPPORTED) + message(STATUS "FSFW | IPO/LTO not supported: ${IPO_ERROR}") +endif() + +option(FSFW_ENABLE_IPO "Enable interprocedural optimization or link-time optimization if available" ON) + option(FSFW_GENERATE_SECTIONS "Generate function and data sections. Required to remove unused code" ON ) @@ -68,6 +76,10 @@ set(FSFW_DUMMY_TGT fsfw-dummy) project(${LIB_FSFW_NAME}) add_library(${LIB_FSFW_NAME} src/fsfw/serviceinterface/fmtWrapper.h src/fsfw/serviceinterface/fmtWrapper.cpp) +if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) + set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) +endif() + if(FSFW_BUILD_UNITTESTS) message(STATUS "Building the FSFW unittests in addition to the static library") # Check whether the user has already installed Catch2 first @@ -427,7 +439,12 @@ target_compile_options(${LIB_FSFW_NAME} PRIVATE ${COMPILER_FLAGS} ) +target_link_libraries(${LIB_FSFW_NAME} PUBLIC + ${FSFW_FMT_LINK_TARGET} + ) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE + # If any ELT headers are ever exposed inside a header or as part of the API, the ETL target needs to be linked PUBLIC ${FSFW_ETL_LINK_TARGET} ${FSFW_ADDITIONAL_LINK_LIBS} ) -- 2.34.1 From 8d85da66f2804f36b87c1b761c166e4d8324eddc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 02:20:19 +0200 Subject: [PATCH 08/16] remove double added source files --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab370b10f..979a71702 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) project(${LIB_FSFW_NAME}) -add_library(${LIB_FSFW_NAME} src/fsfw/serviceinterface/fmtWrapper.h src/fsfw/serviceinterface/fmtWrapper.cpp) +add_library(${LIB_FSFW_NAME}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) -- 2.34.1 From e2d31585065ae0a17d67dec9168725e75973cb35 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 12 May 2022 17:40:34 +0200 Subject: [PATCH 09/16] remove v prefix from fmt version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dd521e32..74e9f8b6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE set(FSFW_FMT_LIB_NAME fmt) set(FSFW_FMT_LINK_TARGET fmt::fmt) set(FSFW_FMT_LIB_MAJOR_VERSION 8 CACHE STRING "{fmt} library major version requirement") -set(FSFW_FMT_LIB_VERSION v${FSFW_FMT_LIB_MAJOR_VERSION}.1.1 CACHE STRING +set(FSFW_FMT_LIB_VERSION ${FSFW_FMT_LIB_MAJOR_VERSION}.1.1 CACHE STRING "{fmt} library exact version requirement" ) -- 2.34.1 From 7ab617accb4ff5a5bcd656b720091fc11d4ee6a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 12 May 2022 18:59:39 +0200 Subject: [PATCH 10/16] rudimentary clion support --- .gitignore | 8 ++++++++ .idea/codeStyles/Project.xml | 14 ++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 +++++ .run/fsfw-tests_coverage.run.xml | 7 +++++++ .run/fsfw.run.xml | 7 +++++++ tests/src/fsfw_tests/unit/CatchDefinitions.cpp | 5 +++-- tests/src/fsfw_tests/unit/CatchSetup.cpp | 12 +----------- tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp | 4 ++-- .../pollingsequence/PollingSequenceFactory.cpp | 12 ++++-------- 9 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .run/fsfw-tests_coverage.run.xml create mode 100644 .run/fsfw.run.xml diff --git a/.gitignore b/.gitignore index d6efb9cf7..eb4610723 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,14 @@ +# PyCharm and CLion +/.idea/* +!/.idea/runConfigurations +!/.idea/cmake.xml +!/.idea/codeStyles + +# Eclipse .cproject .project .settings .metadata /build* +/cmake-build* diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 000000000..0f3b1a4bf --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 000000000..79ee123c2 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.run/fsfw-tests_coverage.run.xml b/.run/fsfw-tests_coverage.run.xml new file mode 100644 index 000000000..49d9b1359 --- /dev/null +++ b/.run/fsfw-tests_coverage.run.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.run/fsfw.run.xml b/.run/fsfw.run.xml new file mode 100644 index 000000000..72f74939e --- /dev/null +++ b/.run/fsfw.run.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/tests/src/fsfw_tests/unit/CatchDefinitions.cpp b/tests/src/fsfw_tests/unit/CatchDefinitions.cpp index 85e3aad00..da8880166 100644 --- a/tests/src/fsfw_tests/unit/CatchDefinitions.cpp +++ b/tests/src/fsfw_tests/unit/CatchDefinitions.cpp @@ -1,7 +1,8 @@ #include "CatchDefinitions.h" #include -#include + +#include "fsfw/serviceinterface.h" StorageManagerIF* tglob::getIpcStoreHandle() { if (ObjectManager::instance() != nullptr) { @@ -10,7 +11,7 @@ StorageManagerIF* tglob::getIpcStoreHandle() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Global object manager uninitialized" << std::endl; #else - sif::printError("Global object manager uninitialized\n\r"); + FSFW_LOGE("Global object manager uninitialized\n"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return nullptr; } diff --git a/tests/src/fsfw_tests/unit/CatchSetup.cpp b/tests/src/fsfw_tests/unit/CatchSetup.cpp index 06f5190a1..f5a3cb06b 100644 --- a/tests/src/fsfw_tests/unit/CatchSetup.cpp +++ b/tests/src/fsfw_tests/unit/CatchSetup.cpp @@ -6,24 +6,14 @@ #endif #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" /* Global instantiations normally done in main.cpp */ /* Initialize Data Pool */ -#if FSFW_CPP_OSTREAM_ENABLED == 1 -namespace sif { -/* Set up output streams */ -ServiceInterfaceStream debug("DEBUG"); -ServiceInterfaceStream info("INFO"); -ServiceInterfaceStream error("ERROR"); -ServiceInterfaceStream warning("WARNING"); -} // namespace sif -#endif - int customSetup() { // global setup + sif::initialize(); ObjectManager* objMan = ObjectManager::instance(); objMan->setObjectFactoryFunction(Factory::produceFrameworkObjects, nullptr); objMan->initialize(); diff --git a/tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp b/tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp index c251fd157..10800c20c 100644 --- a/tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp +++ b/tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp @@ -17,14 +17,14 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { using namespace cfdp; int result = HasReturnvaluesIF::RETURN_OK; - std::array rawBuf; + std::array rawBuf{}; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); size_t deserSize = 0; cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); SECTION("TLV Serialization") { - std::array tlvRawBuf; + std::array tlvRawBuf{}; serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); diff --git a/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp b/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp index 0c44f6a29..10119639e 100644 --- a/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -1,9 +1,9 @@ #include "PollingSequenceFactory.h" #include -#include #include +#include "fsfw/serviceinterface.h" #include "tests/TestsConfig.h" ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) { @@ -11,8 +11,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) uint32_t length = thisSequence->getPeriodMs(); /* Add polling sequence table here */ - thisSequence->addSlot(objects::TEST_DEVICE, 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TEST_DEVICE, 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TEST_DEVICE, 0 * length, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TEST_DEVICE, 0.3 * length, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::TEST_DEVICE, 0.45 * length, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, DeviceHandlerIF::GET_READ); @@ -20,11 +20,7 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED - sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; -#else - sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); -#endif + FSFW_LOGE("pst::pollingSequenceInitDefault: Sequence invalid!\n"); return HasReturnvaluesIF::RETURN_FAILED; } } -- 2.34.1 From aea4e5d42c6a8d47572045e5e4dc0b3f6994b221 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 16 May 2022 14:47:15 +0200 Subject: [PATCH 11/16] resolve merge conflict --- src/fsfw/datapoollocal/LocalPoolVector.tpp | 308 +++++++++------------ 1 file changed, 129 insertions(+), 179 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index 9d96adfba..a058dc2b8 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -5,212 +5,162 @@ #error Include LocalPoolVector.h before LocalPoolVector.tpp! #endif -template -inline LocalPoolVector::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId, - DataSetIF* dataSet, - pool_rwm_t setReadWriteMode) - : LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {} +template +inline LocalPoolVector::LocalPoolVector( + HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet, + pool_rwm_t setReadWriteMode): + LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {} -template -inline LocalPoolVector::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId, - DataSetIF* dataSet, - pool_rwm_t setReadWriteMode) - : LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} +template +inline LocalPoolVector::LocalPoolVector(object_id_t poolOwner, + lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode): + LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} -template -inline LocalPoolVector::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet, - pool_rwm_t setReadWriteMode) - : LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet, - setReadWriteMode) {} +template +inline LocalPoolVector::LocalPoolVector(gp_id_t globalPoolId, + DataSetIF *dataSet, pool_rwm_t setReadWriteMode): + LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, + dataSet, setReadWriteMode) {} -template -inline ReturnValue_t LocalPoolVector::read(MutexIF::TimeoutType timeoutType, - uint32_t timeoutMs) { - MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); - return readWithoutLock(); +template +inline ReturnValue_t LocalPoolVector::read( + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); + return readWithoutLock(); } -template +template inline ReturnValue_t LocalPoolVector::readWithoutLock() { - if (readWriteMode == pool_rwm_t::VAR_WRITE) { - object_id_t targetObjectId = hkManager->getCreatorObjectId(); - reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, true, - targetObjectId, localPoolId); - return PoolVariableIF::INVALID_READ_WRITE_MODE; - } + if(readWriteMode == pool_rwm_t::VAR_WRITE) { + object_id_t targetObjectId = hkManager->getCreatorObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId, + localPoolId); + return PoolVariableIF::INVALID_READ_WRITE_MODE; + } - PoolEntry* poolEntry = nullptr; - ReturnValue_t result = - LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - memset(this->value, 0, vectorSize * sizeof(T)); + PoolEntry* poolEntry = nullptr; + ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, + &poolEntry); + memset(this->value, 0, vectorSize * sizeof(T)); - if (result != RETURN_OK) { - object_id_t targetObjectId = hkManager->getCreatorObjectId(); - reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId); - return result; - } - std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize()); - this->valid = poolEntry->getValid(); - return RETURN_OK; + if(result != RETURN_OK) { + object_id_t targetObjectId = hkManager->getCreatorObjectId(); + reportReadCommitError("LocalPoolVector", result, true, targetObjectId, + localPoolId); + return result; + } + std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize()); + this->valid = poolEntry->getValid(); + return RETURN_OK; } -template +template inline ReturnValue_t LocalPoolVector::commit(bool valid, - MutexIF::TimeoutType timeoutType, - uint32_t timeoutMs) { - this->setValid(valid); - return commit(timeoutType, timeoutMs); + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + this->setValid(valid); + return commit(timeoutType, timeoutMs); } -template -inline ReturnValue_t LocalPoolVector::commit(MutexIF::TimeoutType timeoutType, - uint32_t timeoutMs) { - MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); - return commitWithoutLock(); +template +inline ReturnValue_t LocalPoolVector::commit( + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs); + return commitWithoutLock(); } -template +template inline ReturnValue_t LocalPoolVector::commitWithoutLock() { - if (readWriteMode == pool_rwm_t::VAR_READ) { - object_id_t targetObjectId = hkManager->getCreatorObjectId(); - reportReadCommitError("LocalPoolVector", PoolVariableIF::INVALID_READ_WRITE_MODE, false, - targetObjectId, localPoolId); - return PoolVariableIF::INVALID_READ_WRITE_MODE; - } - PoolEntry* poolEntry = nullptr; - ReturnValue_t result = - LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { - object_id_t targetObjectId = hkManager->getCreatorObjectId(); - reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId); + if(readWriteMode == pool_rwm_t::VAR_READ) { + object_id_t targetObjectId = hkManager->getCreatorObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId, + localPoolId); + return PoolVariableIF::INVALID_READ_WRITE_MODE; + } + PoolEntry* poolEntry = nullptr; + ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, + &poolEntry); + if(result != RETURN_OK) { + object_id_t targetObjectId = hkManager->getCreatorObjectId(); + reportReadCommitError("LocalPoolVector", result, false, targetObjectId, + localPoolId); + return result; + } + std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); + poolEntry->setValid(this->valid); + return RETURN_OK; +} + +template +inline T& LocalPoolVector::operator [](size_t i) { + if(i < vectorSize) { + return value[i]; + } + // If this happens, I have to set some value. I consider this + // a configuration error, but I wont exit here. + FSFW_LOGW("LocalPoolVector: Invalid index. Setting or returning last value\n"); + return value[vectorSize - 1]; +} + +template +inline const T& LocalPoolVector::operator [](size_t i) const { + if(i < vectorSize) { + return value[i]; + } + // If this happens, I have to set some value. I consider this + // a configuration error, but I wont exit here. + FSFW_LOGW("LocalPoolVector: Invalid index. Setting or returning last value\n"); + return value[vectorSize - 1]; +} + +template +inline ReturnValue_t LocalPoolVector::serialize(uint8_t** buffer, + size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + for (uint16_t i = 0; i < vectorSize; i++) { + result = SerializeAdapter::serialize(&(value[i]), buffer, size, + maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + break; + } + } return result; - } - std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); - poolEntry->setValid(this->valid); - return RETURN_OK; } -template -inline T& LocalPoolVector::operator[](size_t i) { - if (i < vectorSize) { - return value[i]; - } - // If this happens, I have to set some value. I consider this - // a configuration error, but I wont exit here. - FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); - return value[vectorSize - 1]; -} - -template -inline const T& LocalPoolVector::operator[](size_t i) const { - if (i < vectorSize) { - return value[i]; - } - // If this happens, I have to set some value. I consider this - // a configuration error, but I wont exit here. - FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n"); - return value[vectorSize - 1]; -} - -template -inline ReturnValue_t LocalPoolVector::serialize( - uint8_t** buffer, size_t* size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - for (uint16_t i = 0; i < vectorSize; i++) { - result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - break; - } - } - return result; -} -std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); -poolEntry->setValid(this->valid); -return RETURN_OK; -} - -template -inline T& LocalPoolVector::operator[](size_t i) { - if (i < vectorSize) { - return value[i]; - } - // If this happens, I have to set some value. I consider this - // a configuration error, but I wont exit here. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid index. Setting or returning" - " last value!" - << std::endl; -#else - sif::printWarning( - "LocalPoolVector: Invalid index. Setting or returning" - " last value!\n"); -#endif - return value[vectorSize - 1]; -} - -template -inline const T& LocalPoolVector::operator[](size_t i) const { - if (i < vectorSize) { - return value[i]; - } - // If this happens, I have to set some value. I consider this - // a configuration error, but I wont exit here. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid index. Setting or returning" - " last value!" - << std::endl; -#else - sif::printWarning( - "LocalPoolVector: Invalid index. Setting or returning" - " last value!\n"); -#endif - return value[vectorSize - 1]; -} - -template -inline ReturnValue_t LocalPoolVector::serialize( - uint8_t** buffer, size_t* size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - for (uint16_t i = 0; i < vectorSize; i++) { - result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - break; - } - } - return result; -} - -template +template inline size_t LocalPoolVector::getSerializedSize() const { - return vectorSize * SerializeAdapter::getSerializedSize(value); + return vectorSize * SerializeAdapter::getSerializedSize(value); } -template +template inline ReturnValue_t LocalPoolVector::deSerialize( - const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - for (uint16_t i = 0; i < vectorSize; i++) { - result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - break; + const uint8_t** buffer, size_t* size, + SerializeIF::Endianness streamEndianness) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + for (uint16_t i = 0; i < vectorSize; i++) { + result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, + streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + break; + } } - } - return result; + return result; } #if FSFW_CPP_OSTREAM_ENABLED == 1 -template -inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector& var) { - out << "Vector: ["; - for (int i = 0; i < vectorSize; i++) { - out << var.value[i]; - if (i < vectorSize - 1) { - out << ", "; +template +inline std::ostream& operator<< (std::ostream &out, + const LocalPoolVector &var) { + out << "Vector: ["; + for(int i = 0;i < vectorSize; i++) { + out << var.value[i]; + if(i < vectorSize - 1) { + out << ", "; + } } - } - out << "]"; - return out; + out << "]"; + return out; } #endif -- 2.34.1 From 618f76ae7890a3a74a741392ca7328875a15bc05 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 May 2022 10:14:34 +0200 Subject: [PATCH 12/16] improved TcPacketPus API --- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 12 ++++++++ src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 32 ++++++++++++++-------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index f5ebe38c3..a38b24c04 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -97,3 +97,15 @@ ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) tcData = reinterpret_cast(const_cast(dataPtr)); return HasReturnvaluesIF::RETURN_OK; } + +void TcPacketPus::setApplicationData(const uint8_t *data, size_t len, bool updateSpLenField) { + if(data == nullptr) { + len = 0; + } + if(data != nullptr) { + std::memcpy(&tcData->appData, data, len); + } + if(updateSpLenField) { + setPacketDataLength(calculateFullPacketLength(len) - sizeof(CCSDSPrimaryHeader) - 1); + } +} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index 47173dad7..543f10303 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -49,6 +49,27 @@ class TcPacketPus : public TcPacketPusBase { */ TcPacketPus(const uint8_t* setData); + /** + * Initializes the Tc Packet header. + * @param apid APID used. + * @param sequenceCount Sequence Count in the primary header. + * @param ack Which acknowledeges are expected from the receiver. + * @param service PUS Service + * @param subservice PUS Subservice + */ + void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, + uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0); + /** + * Set the application data field by copying the provided data to the application data field. + * This function can also update the space packet length + * field. To only update the SP length field with empty application data, simply pass 0 as + * length of nullptr as data. + * @param data + * @param len + * @param updateSpLenField + */ + void setApplicationData(const uint8_t* data, size_t len, bool updateSpLenField); + // Base class overrides uint8_t getSecondaryHeaderFlag() const override; uint8_t getPusVersionNumber() const override; @@ -65,17 +86,6 @@ class TcPacketPus : public TcPacketPusBase { protected: ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override; - /** - * Initializes the Tc Packet header. - * @param apid APID used. - * @param sequenceCount Sequence Count in the primary header. - * @param ack Which acknowledeges are expected from the receiver. - * @param service PUS Service - * @param subservice PUS Subservice - */ - void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, - uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0); - /** * A pointer to a structure which defines the data structure of * the packet's data. -- 2.34.1 From a3b9937f32c23920431407f1ceb53105156aca81 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 May 2022 10:51:38 +0200 Subject: [PATCH 13/16] freertos and dll replacements --- src/fsfw/datalinklayer/Clcw.cpp | 2 +- src/fsfw/datalinklayer/DataLinkLayer.cpp | 2 +- src/fsfw/datalinklayer/MapPacketExtraction.cpp | 2 +- src/fsfw/datalinklayer/TcTransferFrame.cpp | 2 +- src/fsfw/datalinklayer/TcTransferFrameLocal.cpp | 2 +- src/fsfw/datalinklayer/VirtualChannelReception.cpp | 2 +- src/fsfw/osal/freertos/BinSemaphUsingTask.cpp | 2 +- src/fsfw/osal/freertos/BinarySemaphore.cpp | 2 +- src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp | 2 +- src/fsfw/osal/freertos/CountingSemaphore.cpp | 2 +- src/fsfw/osal/freertos/FixedTimeslotTask.cpp | 2 +- src/fsfw/osal/freertos/MessageQueue.cpp | 9 +++++---- src/fsfw/osal/freertos/Mutex.cpp | 2 +- src/fsfw/osal/freertos/PeriodicTask.cpp | 2 +- src/fsfw/osal/freertos/QueueMapManager.cpp | 12 +++++++----- src/fsfw/osal/freertos/SemaphoreFactory.cpp | 2 +- 16 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/fsfw/datalinklayer/Clcw.cpp b/src/fsfw/datalinklayer/Clcw.cpp index 6e40df129..4e3dd2e18 100644 --- a/src/fsfw/datalinklayer/Clcw.cpp +++ b/src/fsfw/datalinklayer/Clcw.cpp @@ -1,6 +1,6 @@ #include "fsfw/datalinklayer/Clcw.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" Clcw::Clcw() { content.raw = 0; diff --git a/src/fsfw/datalinklayer/DataLinkLayer.cpp b/src/fsfw/datalinklayer/DataLinkLayer.cpp index ca6074781..3aa9ee39e 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.cpp +++ b/src/fsfw/datalinklayer/DataLinkLayer.cpp @@ -1,7 +1,7 @@ #include "fsfw/datalinklayer/DataLinkLayer.h" #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw, uint8_t set_start_sequence_length, uint16_t set_scid) diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 57aa2f087..fcf5a9fed 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -4,7 +4,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tmtcpacket/SpacePacketBase.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" diff --git a/src/fsfw/datalinklayer/TcTransferFrame.cpp b/src/fsfw/datalinklayer/TcTransferFrame.cpp index ebf0f38c0..6677e2ce2 100644 --- a/src/fsfw/datalinklayer/TcTransferFrame.cpp +++ b/src/fsfw/datalinklayer/TcTransferFrame.cpp @@ -1,6 +1,6 @@ #include "fsfw/datalinklayer/TcTransferFrame.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" TcTransferFrame::TcTransferFrame() { frame = nullptr; } diff --git a/src/fsfw/datalinklayer/TcTransferFrameLocal.cpp b/src/fsfw/datalinklayer/TcTransferFrameLocal.cpp index 572f27fdf..51aef0e07 100644 --- a/src/fsfw/datalinklayer/TcTransferFrameLocal.cpp +++ b/src/fsfw/datalinklayer/TcTransferFrameLocal.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uint16_t scid, uint8_t vcId, uint8_t sequenceNumber, diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.cpp b/src/fsfw/datalinklayer/VirtualChannelReception.cpp index 258bc1e64..3a8da2289 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.cpp +++ b/src/fsfw/datalinklayer/VirtualChannelReception.cpp @@ -8,7 +8,7 @@ #include "fsfw/datalinklayer/VirtualChannelReception.h" #include "fsfw/datalinklayer/BCFrame.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" VirtualChannelReception::VirtualChannelReception(uint8_t setChannelId, uint8_t setSlidingWindowWidth) diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp index 7ffd61d3a..b98a0a309 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/freertos/BinSemaphUsingTask.h" #include "fsfw/osal/freertos/TaskManagement.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #if (tskKERNEL_VERSION_MAJOR == 8 && tskKERNEL_VERSION_MINOR > 2) || tskKERNEL_VERSION_MAJOR > 8 diff --git a/src/fsfw/osal/freertos/BinarySemaphore.cpp b/src/fsfw/osal/freertos/BinarySemaphore.cpp index 6e53380cc..c4e12efc6 100644 --- a/src/fsfw/osal/freertos/BinarySemaphore.cpp +++ b/src/fsfw/osal/freertos/BinarySemaphore.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/freertos/BinarySemaphore.h" #include "fsfw/osal/freertos/TaskManagement.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" BinarySemaphore::BinarySemaphore() { handle = xSemaphoreCreateBinary(); diff --git a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp index 0e4d967dc..28d4f7030 100644 --- a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/freertos/CountingSemaphUsingTask.h" #include "fsfw/osal/freertos/TaskManagement.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #if (tskKERNEL_VERSION_MAJOR == 8 && tskKERNEL_VERSION_MINOR > 2) || tskKERNEL_VERSION_MAJOR > 8 diff --git a/src/fsfw/osal/freertos/CountingSemaphore.cpp b/src/fsfw/osal/freertos/CountingSemaphore.cpp index 3137166a9..c0c35970d 100644 --- a/src/fsfw/osal/freertos/CountingSemaphore.cpp +++ b/src/fsfw/osal/freertos/CountingSemaphore.cpp @@ -2,7 +2,7 @@ #include "FreeRTOS.h" #include "fsfw/osal/freertos/TaskManagement.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "semphr.h" // Make sure #define configUSE_COUNTING_SEMAPHORES 1 is set in diff --git a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp index e0e3779e1..86cb2734f 100644 --- a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/freertos/FixedTimeslotTask.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" uint32_t FixedTimeslotTask::deadlineMissedCount = 0; const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE; diff --git a/src/fsfw/osal/freertos/MessageQueue.cpp b/src/fsfw/osal/freertos/MessageQueue.cpp index d1a7f691c..5489f9ca5 100644 --- a/src/fsfw/osal/freertos/MessageQueue.cpp +++ b/src/fsfw/osal/freertos/MessageQueue.cpp @@ -2,7 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/osal/freertos/QueueMapManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args) : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, args), @@ -14,9 +14,10 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* a sif::error << "Specified Message Depth: " << messageDepth << std::endl; sif::error << "Specified Maximum Message Size: " << maxMessageSize << std::endl; #else - sif::printError("MessageQueue::MessageQueue: Creation failed\n"); - sif::printError("Specified Message Depth: %d\n", messageDepth); - sif::printError("Specified Maximum Message Size: %d\n", maxMessageSize); + // TODO: FMTLOG +// sif::printError("MessageQueue::MessageQueue: Creation failed\n"); +// sif::printError("Specified Message Depth: %d\n", messageDepth); +// sif::printError("Specified Maximum Message Size: %d\n", maxMessageSize); #endif } QueueMapManager::instance()->addMessageQueue(handle, &id); diff --git a/src/fsfw/osal/freertos/Mutex.cpp b/src/fsfw/osal/freertos/Mutex.cpp index 1995e1ea9..6e8aa56ed 100644 --- a/src/fsfw/osal/freertos/Mutex.cpp +++ b/src/fsfw/osal/freertos/Mutex.cpp @@ -1,6 +1,6 @@ #include "fsfw/osal/freertos/Mutex.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" Mutex::Mutex() { handle = xSemaphoreCreateMutex(); diff --git a/src/fsfw/osal/freertos/PeriodicTask.cpp b/src/fsfw/osal/freertos/PeriodicTask.cpp index d2c46ea8d..8fde9fc55 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.cpp +++ b/src/fsfw/osal/freertos/PeriodicTask.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/freertos/PeriodicTask.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" #include "fsfw/tasks/ExecutableObjectIF.h" PeriodicTask::PeriodicTask(const char* name, TaskPriority setPriority, TaskStackSize setStack, diff --git a/src/fsfw/osal/freertos/QueueMapManager.cpp b/src/fsfw/osal/freertos/QueueMapManager.cpp index cb3afb1cd..cb601a277 100644 --- a/src/fsfw/osal/freertos/QueueMapManager.cpp +++ b/src/fsfw/osal/freertos/QueueMapManager.cpp @@ -30,9 +30,10 @@ ReturnValue_t QueueMapManager::addMessageQueue(QueueHandle_t queue, MessageQueue "inside the map!" << std::endl; #else - sif::printError( - "QueueMapManager::addMessageQueue This ID is already " - "inside the map!\n"); + // TODO: FMTLOG +// sif::printError( +// "QueueMapManager::addMessageQueue This ID is already " +// "inside the map!\n"); #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -51,8 +52,9 @@ QueueHandle_t QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId << " does not exists in the map!" << std::endl; #else - sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n", - messageQueueId); + // TODO: FMTLOG +// sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n", +// messageQueueId); #endif } return nullptr; diff --git a/src/fsfw/osal/freertos/SemaphoreFactory.cpp b/src/fsfw/osal/freertos/SemaphoreFactory.cpp index 4224386e0..e74fc4b6b 100644 --- a/src/fsfw/osal/freertos/SemaphoreFactory.cpp +++ b/src/fsfw/osal/freertos/SemaphoreFactory.cpp @@ -4,7 +4,7 @@ #include "fsfw/osal/freertos/BinarySemaphore.h" #include "fsfw/osal/freertos/CountingSemaphUsingTask.h" #include "fsfw/osal/freertos/CountingSemaphore.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; -- 2.34.1 From 16f8262a79cea07bd8c2bd0867f96928459fabeb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 May 2022 11:35:17 +0200 Subject: [PATCH 14/16] starting a bit with event manage replacements --- src/fsfw/events/EventManager.cpp | 6 +++--- src/fsfw/events/EventManager.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index aaa7d6c52..1559f34cd 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -119,17 +119,17 @@ void EventManager::printEvent(EventMessage* message) { switch (message->getSeverity()) { case severity::INFO: { #if FSFW_DEBUG_INFO == 1 - printUtility(sif::OutputTypes::OUT_INFO, message); + printUtility(sif::LogLevel::INFO, message); #endif /* DEBUG_INFO_EVENT == 1 */ break; } default: - printUtility(sif::OutputTypes::OUT_DEBUG, message); + printUtility(sif::LogLevel::DEBUG, message); break; } } -void EventManager::printUtility(sif::OutputTypes printType, EventMessage* message) { +void EventManager::printUtility(sif::LogLevel printType, EventMessage* message) { const char* string = 0; if (printType == sif::OutputTypes::OUT_INFO) { string = translateObject(message->getReporter()); diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index d4994fdf5..59fed8367 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -63,7 +63,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy #if FSFW_OBJ_EVENT_TRANSLATION == 1 void printEvent(EventMessage* message); - void printUtility(sif::OutputTypes printType, EventMessage* message); + void printUtility(sif::LogLevel printType, EventMessage* message); #endif void lockMutex(); -- 2.34.1 From 67b67de753da2d6de3e940bb89f20301d5e29771 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Jun 2022 11:03:36 +0200 Subject: [PATCH 15/16] remove fsfw-test run files --- .run/fsfw-tests_coverage.run.xml | 7 ------- .run/fsfw.run.xml | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 .run/fsfw-tests_coverage.run.xml delete mode 100644 .run/fsfw.run.xml diff --git a/.run/fsfw-tests_coverage.run.xml b/.run/fsfw-tests_coverage.run.xml deleted file mode 100644 index 49d9b1359..000000000 --- a/.run/fsfw-tests_coverage.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.run/fsfw.run.xml b/.run/fsfw.run.xml deleted file mode 100644 index 72f74939e..000000000 --- a/.run/fsfw.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file -- 2.34.1 From 42a1e784c09c554d20cb30e3c9965f4722fb4ef2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Jun 2022 11:15:00 +0200 Subject: [PATCH 16/16] logging fixes --- src/fsfw/osal/host/FixedTimeslotTask.cpp | 19 --- .../pus/Service11TelecommandScheduling.tpp | 145 +++--------------- src/fsfw/tasks/FixedTimeslotTaskBase.cpp | 8 +- src/fsfw/tasks/PeriodicTaskBase.cpp | 13 +- 4 files changed, 28 insertions(+), 157 deletions(-) diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 26123763e..a020828f4 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -107,25 +107,6 @@ void FixedTimeslotTask::taskFunctionality() { } } -<<<<<<< HEAD -ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, - int8_t executionStep) { - auto* executableObject = ObjectManager::instance()->get(componentId); - if (executableObject != nullptr) { - pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, executableObject, this); - return HasReturnvaluesIF::RETURN_OK; - } - - FSFW_LOGE("addSlot: Component {:#010x} not found, not adding it to PST\n", componentId); - return HasReturnvaluesIF::RETURN_FAILED; -} - -ReturnValue_t FixedTimeslotTask::checkSequence() const { return pollingSeqTable.checkSequence(); } - -uint32_t FixedTimeslotTask::getPeriodMs() const { return period * 1000; } - -======= ->>>>>>> origin/development bool FixedTimeslotTask::delayForInterval(chron_ms* previousWakeTimeMs, const chron_ms interval) { bool shouldDelay = false; // Get current wakeup time diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 968a59ffa..1fbad3d62 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -25,11 +25,7 @@ template inline ReturnValue_t Service11TelecommandScheduling::handleRequest( uint8_t subservice) { if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::handleRequest: Handling request " << static_cast(subservice); -#else - sif::printInfo("PUS11::handleRequest: Handling request %d\n", subservice); -#endif + FSFW_LOGI("PUS11::handleRequest: Handling request {}\n", static_cast(subservice)); } // Get de-serialized Timestamp const uint8_t *data = currentPacket.getApplicationData(); @@ -88,11 +84,7 @@ inline ReturnValue_t Service11TelecommandScheduling::performService return sendRet; } if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Released TC & erased it from TC map" << std::endl; -#else - sif::printInfo("Released TC & erased it from TC map\n"); -#endif + FSFW_LOGIT("Released TC & erased it from TC map\n"); } telecommandMap.erase(it++); } else if (deleteExpiredTcWhenDisabled) { @@ -131,13 +123,8 @@ inline ReturnValue_t Service11TelecommandScheduling::handleResetCom for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) { ReturnValue_t result = tcStore->deleteData(it->second.storeAddr); if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 // This should not happen - sif::warning << "Service11TelecommandScheduling::handleRequestDeleting: Deletion failed" - << std::endl; -#else - sif::printWarning("Service11TelecommandScheduling::handleRequestDeleting: Deletion failed\n"); -#endif + FSFW_LOGW("Service11TelecommandScheduling::handleRequestDeleting: Deletion failed\n"); triggerEvent(TC_DELETION_FAILED, (it->second.requestId >> 32) & 0xffffffff, it->second.requestId & 0xffffffff); } @@ -160,15 +147,8 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi timeval tNow = {}; Clock::getClock_timeval(&tNow); if (timestamp - tNow.tv_sec <= RELEASE_TIME_MARGIN_SECONDS) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service11TelecommandScheduling::doInsertActivity: Release time too close to " - "current time" - << std::endl; -#else - sif::printWarning( - "Service11TelecommandScheduling::doInsertActivity: Release time too close to current " - "time\n"); -#endif + FSFW_LOGW("Service11TelecommandScheduling::doInsertActivity: " + "Release time too close to current time\n"); return RETURN_FAILED; } @@ -176,13 +156,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi store_address_t addr{}; if (tcStore->addData(&addr, data, size) != RETURN_OK || addr.raw == storeId::INVALID_STORE_ADDRESS) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed" - << std::endl; -#else - sif::printError( - "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed\n"); -#endif + FSFW_LOGET("Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed\n"); return RETURN_FAILED; } @@ -199,11 +173,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi } if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doInsertActivity: Inserted into Multimap:" << std::endl; -#else - sif::printInfo("PUS11::doInsertActivity: Inserted into Multimap:\n"); -#endif + FSFW_LOGI("PUS11::doInsertActivity: Inserted into Multimap:\n"); debugPrintMultimapContent(); } return HasReturnvaluesIF::RETURN_OK; @@ -221,11 +191,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi // DEBUG if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doDeleteActivity: requestId: " << requestId << std::endl; -#else - sif::printInfo("PUS11::doDeleteActivity: requestId: %d\n", requestId); -#endif + FSFW_LOGI("PUS11::doDeleteActivity: requestId: {}\n", requestId); } TcMapIter tcToDelete; // handle to the TC to be deleted, can be used if counter is valid @@ -240,37 +206,20 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi // check if 1 explicit TC is found via request ID if (tcToDeleteCount == 0 || tcToDeleteCount > 1) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. " - "Cannot explicitly delete TC" - << std::endl; -#else - sif::printWarning( - "Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. " - "Cannot explicitly delete TC"); -#endif + FSFW_LOGW("Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. " + "Cannot explicitly delete TC\n"); return RETURN_FAILED; } // delete packet from store if (tcStore->deleteData(tcToDelete->second.storeAddr) != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store" - << std::endl; -#else - sif::printError( - "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store\n"); -#endif + FSFW_LOGET("Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store\n"); return RETURN_FAILED; } telecommandMap.erase(tcToDelete); if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doDeleteActivity: Deleted TC from map" << std::endl; -#else - sif::printInfo("PUS11::doDeleteActivity: Deleted TC from map\n"); -#endif + FSFW_LOGI("PUS11::doDeleteActivity: Deleted TC from map\n"); } return RETURN_OK; @@ -292,15 +241,8 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete for (TcMapIter it = itBegin; it != itEnd; it++) { // delete packet from store if (tcStore->deleteData(it->second.storeAddr) != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC " - "from Store" - << std::endl; -#else - sif::printError( - "Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC from " - "Store\n"); -#endif + FSFW_LOGET("Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC " + "from Store\n"); continue; } deletedTCs++; @@ -316,11 +258,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete telecommandMap.erase(itBegin, itEnd); if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doFilterDeleteActivity: Deleted " << deletedTCs << " TCs" << std::endl; -#else - sif::printInfo("PUS11::doFilterDeleteActivity: Deleted %d TCs\n", deletedTCs); -#endif + FSFW_LOGI("PUS11::doFilterDeleteActivity: Deleted {} TCs\n", deletedTCs); } return RETURN_OK; } @@ -347,11 +285,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct } if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doTimeshiftActivity: requestId: " << requestId << std::endl; -#else - sif::printInfo("PUS11::doTimeshiftActivity: requestId: %d\n", requestId); -#endif + FSFW_LOGI("PUS11::doTimeshiftActivity: requestId: {}\n", requestId); } // NOTE: Despite having C++17 ETL multimap has no member function extract :( @@ -367,17 +301,9 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct } if (tcToTimeshiftCount == 0 || tcToTimeshiftCount > 1) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service11TelecommandScheduling::doTimeshiftActivity: Either 0 or more than 1 " + FSFW_LOGW("Service11TelecommandScheduling::doTimeshiftActivity: Either 0 or more than 1 " "TCs found. No explicit timeshifting " - "possible" - << std::endl; - -#else - sif::printWarning( - "Service11TelecommandScheduling::doTimeshiftActivity: Either 0 or more than 1 TCs found. " - "No explicit timeshifting possible\n"); -#endif + "possible\n"); return TIMESHIFTING_NOT_POSSIBLE; } @@ -392,11 +318,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct telecommandMap.insert(std::make_pair(tempKey, tempTc)); if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doTimeshiftActivity: Shifted TC" << std::endl; -#else - sif::printDebug("PUS11::doTimeshiftActivity: Shifted TC\n"); -#endif + FSFW_LOGI("PUS11::doTimeshiftActivity: Shifted TC\n"); debugPrintMultimapContent(); } @@ -439,12 +361,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh } if (debugMode) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "PUS11::doFilterTimeshiftActivity: shiftedItemsCount: " << shiftedItemsCount - << std::endl; -#else - sif::printInfo("PUS11::doFilterTimeshiftActivity: shiftedItemsCount: %d\n", shiftedItemsCount); -#endif + FSFW_LOGI("PUS11::doFilterTimeshiftActivity: shiftedItemsCount: {}\n", shiftedItemsCount); debugPrintMultimapContent(); } @@ -604,11 +521,7 @@ template inline ReturnValue_t Service11TelecommandScheduling::handleInvalidData( const char *ctx) { #if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Service11TelecommandScheduling:: " << ctx << ": Invalid buffer" << std::endl; -#else - sif::printWarning("Service11TelecommandScheduling::%s: Invalid buffer\n", ctx); -#endif + FSFW_LOGW("Service11TelecommandScheduling::{}: Invalid buffer\n", ctx); #endif return RETURN_FAILED; } @@ -616,20 +529,10 @@ inline ReturnValue_t Service11TelecommandScheduling::handleInvalidD template inline void Service11TelecommandScheduling::debugPrintMultimapContent() const { #if FSFW_DISABLE_PRINTOUT == 0 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content" - << std::endl; -#else - sif::printDebug("Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content\n"); -#endif + FSFW_LOGD("Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content\n"); for (const auto &dit : telecommandMap) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "[" << dit.first << "]: Request ID: " << dit.second.requestId << " | " - << "Store Address: " << dit.second.storeAddr.raw << std::endl; -#else - sif::printDebug("[%d]: Request ID: %d | Store Address: %d\n", dit.first, dit.second.requestId, - dit.second.storeAddr); -#endif + FSFW_LOGD("[{}]: Request ID: {} | Store Address: {}\n", dit.first, dit.second.requestId, + dit.second.storeAddr.raw); } #endif } diff --git a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp index 5d12d5657..0a4da161a 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp +++ b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp @@ -14,12 +14,8 @@ ReturnValue_t FixedTimeslotTaskBase::checkSequence() { return pollingSeqTable.ch ReturnValue_t FixedTimeslotTaskBase::addSlot(object_id_t execId, ExecutableObjectIF* execObj, uint32_t slotTimeMs, int8_t executionStep) { if (execObj == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Component 0x" << std::hex << std::setw(8) << std::setfill('0') << execObj - << std::setfill(' ') << " not found, not adding it to PST" << std::dec << std::endl; -#else - sif::printError("Component 0x%08x not found, not adding it to PST\n"); -#endif + // TODO: Hex formatting + FSFW_LOGE("Component {} not found, not adding it to PST\n"); return HasReturnvaluesIF::RETURN_FAILED; } pollingSeqTable.addSlot(execId, slotTimeMs, executionStep, execObj, this); diff --git a/src/fsfw/tasks/PeriodicTaskBase.cpp b/src/fsfw/tasks/PeriodicTaskBase.cpp index ce925a458..a36f49c6e 100644 --- a/src/fsfw/tasks/PeriodicTaskBase.cpp +++ b/src/fsfw/tasks/PeriodicTaskBase.cpp @@ -9,11 +9,7 @@ PeriodicTaskBase::PeriodicTaskBase(TaskPeriod period_, TaskDeadlineMissedFunctio : period(period_), dlmFunc(dlmFunc_) { // Hints at configuration error if (PeriodicTaskBase::getPeriodMs() <= 1) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Passed task period 0 or smaller than 1 ms" << std::endl; -#else - sif::printWarning("Passed task period 0 or smaller than 1ms\n"); -#endif + FSFW_LOGW("Passed task period 0 or smaller than 1ms\n"); } } @@ -54,14 +50,9 @@ ReturnValue_t PeriodicTaskBase::addComponent(object_id_t object, uint8_t opCode) ReturnValue_t PeriodicTaskBase::addComponent(ExecutableObjectIF* object, uint8_t opCode) { if (object == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" - << " it implements ExecutableObjectIF!" << std::endl; -#else - sif::printError( + FSFW_LOGE( "PeriodicTask::addComponent: Invalid object. Make sure it " "implements ExecutableObjectIF!\n"); -#endif return HasReturnvaluesIF::RETURN_FAILED; } objectList.push_back({object, opCode}); -- 2.34.1