Compare commits
22 Commits
main
...
mueller/re
Author | SHA1 | Date | |
---|---|---|---|
16f8262a79 | |||
1a41d37f20 | |||
a3b9937f32 | |||
b11ae1c11d | |||
aea4e5d42c | |||
8d966de735 | |||
842f1b22af | |||
cb9c1806ef | |||
cdc431ebc5 | |||
7ab617accb | |||
e2d3158506 | |||
23c6145971 | |||
eafbab9c65 | |||
16bbc0f597 | |||
8d85da66f2 | |||
fb1d775b52 | |||
e8a5f1e095 | |||
f518bc53db | |||
b45b6b3758 | |||
83a2882f9d | |||
1b34b90ae0 | |||
77055a1579 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,6 +1,14 @@
|
||||
# PyCharm and CLion
|
||||
/.idea/*
|
||||
!/.idea/runConfigurations
|
||||
!/.idea/cmake.xml
|
||||
!/.idea/codeStyles
|
||||
|
||||
# Eclipse
|
||||
.cproject
|
||||
.project
|
||||
.settings
|
||||
.metadata
|
||||
|
||||
/build*
|
||||
/cmake-build*
|
||||
|
14
.idea/codeStyles/Project.xml
Normal file
14
.idea/codeStyles/Project.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<clangFormatSettings>
|
||||
<option name="ENABLED" value="true" />
|
||||
</clangFormatSettings>
|
||||
<codeStyleSettings language="CMake">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="0" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
7
.run/fsfw-tests_coverage.run.xml
Normal file
7
.run/fsfw-tests_coverage.run.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="fsfw-tests_coverage" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw-tests_coverage" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
7
.run/fsfw.run.xml
Normal file
7
.run/fsfw.run.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="fsfw" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="fsfw-tests" TARGET_NAME="fsfw" CONFIG_NAME="Debug Unittest" RUN_TARGET_PROJECT_NAME="fsfw-tests" RUN_TARGET_NAME="fsfw-tests">
|
||||
<method v="2">
|
||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -67,13 +67,13 @@ endif()
|
||||
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
|
||||
|
||||
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_ETL_LINK_TARGET etl::etl)
|
||||
|
||||
set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
||||
3
|
||||
@ -82,6 +82,15 @@ set(FSFW_CATCH2_LIB_VERSION
|
||||
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
|
||||
CACHE STRING "Catch2 library exact version requirement")
|
||||
|
||||
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
|
||||
${FSFW_FMT_LIB_MAJOR_VERSION}.1.1
|
||||
CACHE STRING "{fmt} library exact version requirement")
|
||||
|
||||
# Keep this off by default for now. See PR:
|
||||
# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
|
||||
# keeping this on by default is problematic
|
||||
@ -168,11 +177,11 @@ if(FSFW_BUILD_UNITTESTS)
|
||||
|
||||
project(${FSFW_TEST_TGT} CXX C)
|
||||
add_executable(${FSFW_TEST_TGT})
|
||||
|
||||
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
||||
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
||||
TRUE)
|
||||
endif()
|
||||
|
||||
if(FSFW_TESTS_GEN_COV)
|
||||
message(STATUS "${MSG_PREFIX} Generating coverage data for the library")
|
||||
message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} "
|
||||
@ -182,7 +191,7 @@ if(FSFW_BUILD_UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library")
|
||||
message(STATUS "${MSG_PREFIX} Finding and/or 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)
|
||||
@ -202,6 +211,26 @@ if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
|
||||
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)
|
||||
|
||||
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
|
||||
@ -211,7 +240,7 @@ if(FSFW_FETCH_CONTENT_TARGETS)
|
||||
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
|
||||
# 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()
|
||||
@ -446,8 +475,13 @@ target_include_directories(
|
||||
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
|
||||
${COMPILER_FLAGS})
|
||||
|
||||
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET}
|
||||
${FSFW_ADDITIONAL_LINK_LIBS})
|
||||
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})
|
||||
|
||||
string(
|
||||
CONCAT
|
||||
@ -457,6 +491,13 @@ string(
|
||||
"Target OSAL: ${FSFW_OS_NAME}\n"
|
||||
"######################################################################\n")
|
||||
|
||||
# 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}/" FSFW_SOURCE_PATH_SIZE)
|
||||
target_compile_definitions(
|
||||
${LIB_FSFW_NAME} PRIVATE "-DFSFW_SOURCE_PATH_SIZE=${FSFW_SOURCE_PATH_SIZE}")
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${LIB_FSFW_NAME}
|
||||
POST_BUILD
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_LOGW(
|
||||
"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<int16_t>((packet[2] << 8) | packet[1]);
|
||||
float tempValue = 25.0 + ((static_cast<float>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_LOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer,
|
||||
DynamicFIFO<uint16_t>* sizesFifo) {
|
||||
this->ringBuffer = ringBuffer;
|
||||
this->sizesFifo = sizesFifo;
|
||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer_,
|
||||
DynamicFIFO<uint16_t>* 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<const uint8_t*>(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<const uint8_t*>(output.data()), output.size());
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<I2cCookie*>(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<I2cCookie*>(cookie);
|
||||
i2cAddress = i2cCookie->getAddress();
|
||||
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
@ -47,20 +38,14 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
||||
I2cInstance i2cInstance = {std::vector<uint8_t>(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<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(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<int>(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<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(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<int>(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<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(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;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#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<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(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<unsigned long>(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<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(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<unsigned long>(sendLen),
|
||||
static_cast<unsigned long>(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<ssize_t>(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<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(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<ssize_t>(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<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(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<uint8_t*>(spiCookie->getTransferStructHandle()->tx_buf);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Sent SPI data: " << std::endl;
|
||||
auto* dataPtr = reinterpret_cast<uint8_t*>(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<uint8_t*>(spiCookie->getTransferStructHandle()->rx_buf);
|
||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "UartComIF.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
@ -23,11 +23,9 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<uint8_t>(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<unsigned int>(uartCookie->getBitsPerWord()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -316,9 +300,7 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
|
||||
break;
|
||||
#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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<int>(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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<int>(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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -3,21 +3,11 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#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));
|
||||
}
|
||||
|
@ -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 */
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <fsfw/cfdp/tlv/Tlv.h>
|
||||
#include <fsfw/cfdp/tlv/TlvIF.h>
|
||||
#include <fsfw/serialize/SerializeIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -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; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "fsfw/datalinklayer/Clcw.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
Clcw::Clcw() {
|
||||
content.raw = 0;
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "fsfw/datalinklayer/TcTransferFrame.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
TcTransferFrame::TcTransferFrame() { frame = nullptr; }
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#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,
|
||||
|
@ -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)
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
template <typename T>
|
||||
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid)
|
||||
@ -68,13 +68,7 @@ void PoolEntry<T>::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<uint8_t*>(address), getByteSize());
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef FSFW_DATAPOOL_POOLREADHELPER_H_
|
||||
#define FSFW_DATAPOOL_POOLREADHELPER_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
#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<StorageManagerIF>(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<AcceptsHkPacketsIF>(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<uint8_t*>(&cds), sizeof(cds),
|
||||
@ -342,7 +340,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e
|
||||
AcceptsHkPacketsIF* hkReceiverObject =
|
||||
ObjectManager::instance()->get<AcceptsHkPacketsIF>(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<AcceptsHkPacketsIF>(packetDestination);
|
||||
auto* hkReceiverObject = ObjectManager::instance()->get<AcceptsHkPacketsIF>(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;
|
||||
}
|
||||
|
||||
@ -695,11 +688,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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,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;
|
||||
}
|
||||
|
||||
@ -730,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;
|
||||
}
|
||||
|
||||
@ -756,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;
|
||||
}
|
||||
|
||||
@ -778,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;
|
||||
@ -792,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");
|
||||
}
|
||||
@ -825,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) {
|
||||
@ -835,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";
|
||||
@ -855,24 +840,10 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
|
||||
objectId = owner->getObjectId();
|
||||
}
|
||||
|
||||
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 */
|
||||
} 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 */
|
||||
if (outputType == sif::LogLevel::WARNING) {
|
||||
FSFW_LOGWT("{} | Object ID {} | {}\n", functionName, objectId, errorPrint);
|
||||
} else if (outputType == sif::LogLevel::ERROR) {
|
||||
FSFW_LOGET("{} | Object ID {} | {}\n", functionName, objectId, errorPrint);
|
||||
}
|
||||
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
|
||||
}
|
||||
|
@ -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<PoolEntry<T>*>(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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<T>::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<T>::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<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
"which is the NO_PARAMETER value!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"LocalPoolVar<T>::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<HasLocalDataPoolIF>(poolOwner);
|
||||
auto* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(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 {:#010x} 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: {:#010x} | LPID: \n", variablePrintout, type, errMsg,
|
||||
objectId, lpId);
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
/**
|
||||
|
@ -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"
|
||||
|
||||
/**
|
||||
|
@ -5,172 +5,162 @@
|
||||
#error Include LocalPoolVector.h before LocalPoolVector.tpp!
|
||||
#endif
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
|
||||
HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(object_id_t poolOwner,
|
||||
lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, dataSet,
|
||||
setReadWriteMode) {}
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
|
||||
DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
|
||||
dataSet, setReadWriteMode) {}
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return readWithoutLock();
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return readWithoutLock();
|
||||
}
|
||||
template <typename T, uint16_t vectorSize>
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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<T>* poolEntry = nullptr;
|
||||
ReturnValue_t result =
|
||||
LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry);
|
||||
memset(this->value, 0, vectorSize * sizeof(T));
|
||||
PoolEntry<T>* 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 <typename T, uint16_t vectorSize>
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(MutexIF::TimeoutType timeoutType,
|
||||
uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return commitWithoutLock();
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
MutexGuard(LocalDpManagerAttorney::getMutexHandle(*hkManager), timeoutType, timeoutMs);
|
||||
return commitWithoutLock();
|
||||
}
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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<T>* 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<T>* 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<typename T, uint16_t vectorSize>
|
||||
inline T& LocalPoolVector<T, vectorSize>::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<typename T, uint16_t vectorSize>
|
||||
inline const T& LocalPoolVector<T, vectorSize>::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<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
inline T& LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
inline const T& LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline size_t LocalPoolVector<T, vectorSize>::getSerializedSize() const {
|
||||
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
||||
return vectorSize * SerializeAdapter::getSerializedSize(value);
|
||||
}
|
||||
|
||||
template <typename T, uint16_t vectorSize>
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::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 <typename T, uint16_t vectorSize>
|
||||
inline std::ostream& operator<<(std::ostream& out, const LocalPoolVector<T, vectorSize>& var) {
|
||||
out << "Vector: [";
|
||||
for (int i = 0; i < vectorSize; i++) {
|
||||
out << var.value[i];
|
||||
if (i < vectorSize - 1) {
|
||||
out << ", ";
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline std::ostream& operator<< (std::ostream &out,
|
||||
const LocalPoolVector<T, vectorSize> &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
|
||||
|
||||
|
@ -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,42 +130,34 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
communicationInterface =
|
||||
ObjectManager::instance()->get<DeviceCommunicationIF>(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<StorageManagerIF>(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;
|
||||
}
|
||||
|
||||
if (rawDataReceiverId != objects::NO_OBJECT) {
|
||||
AcceptsDeviceResponsesIF* rawReceiver =
|
||||
ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||
auto* rawReceiver = ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(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.");
|
||||
#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();
|
||||
@ -174,17 +166,11 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
if (powerSwitcherId != objects::NO_OBJECT) {
|
||||
powerSwitcher = ObjectManager::instance()->get<PowerSwitchIF>(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.");
|
||||
#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;
|
||||
}
|
||||
}
|
||||
@ -317,8 +303,7 @@ void DeviceHandlerBase::doStateMachine() {
|
||||
sprintf(printout, "Transition timeout (%lu) occured !",
|
||||
static_cast<unsigned long>(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);
|
||||
@ -610,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;
|
||||
}
|
||||
|
||||
@ -752,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");
|
||||
}
|
||||
@ -764,14 +749,12 @@ 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.");
|
||||
#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;
|
||||
}
|
||||
@ -1286,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;
|
||||
@ -1294,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;
|
||||
@ -1312,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<unsigned int>(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) {
|
||||
@ -1327,7 +1310,7 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
||||
char output[36];
|
||||
sprintf(output, "Command 0x%08x is executing", static_cast<unsigned int>(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,
|
||||
@ -1348,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;
|
||||
}
|
||||
@ -1456,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";
|
||||
@ -1475,24 +1458,12 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch
|
||||
functionName = "unknown function";
|
||||
}
|
||||
|
||||
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
|
||||
} 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
|
||||
if (errorType == sif::LogLevel::WARNING) {
|
||||
FSFW_LOGWT("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(),
|
||||
errorPrint);
|
||||
} else if (errorType == sif::LogLevel::ERROR) {
|
||||
FSFW_LOGET("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(),
|
||||
errorPrint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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<ConfirmsFailuresIF>(powerConfirmationId);
|
||||
auto* power = ObjectManager::instance()->get<ConfirmsFailuresIF>(powerConfirmationId);
|
||||
if (power != nullptr) {
|
||||
powerConfirmation = power->getEventReceptionQueue();
|
||||
}
|
||||
@ -244,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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
@ -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();
|
||||
|
@ -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<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
auto* eventmanager = ObjectManager::instance()->get<EventManagerIF>(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();
|
||||
|
@ -18,13 +18,9 @@ FailureIsolationBase::~FailureIsolationBase() {
|
||||
}
|
||||
|
||||
ReturnValue_t FailureIsolationBase::initialize() {
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
auto* manager = ObjectManager::instance()->get<EventManagerIF>(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,20 @@ ReturnValue_t FailureIsolationBase::initialize() {
|
||||
}
|
||||
owner = ObjectManager::instance()->get<HasHealthIF>(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 {:#010x} invalid. "
|
||||
"Does it implement HasHealthIF?\n",
|
||||
ownerId);
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
if (faultTreeParent != objects::NO_OBJECT) {
|
||||
ConfirmsFailuresIF* parentIF =
|
||||
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
|
||||
auto* parentIF = ObjectManager::instance()->get<ConfirmsFailuresIF>(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 {:#010x} invalid. Does it implement ConfirmsFailuresIF?\n",
|
||||
faultTreeParent);
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());
|
||||
}
|
||||
|
@ -3,31 +3,16 @@
|
||||
#include <bitset>
|
||||
#include <cmath>
|
||||
|
||||
#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<unsigned long>(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<int>(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<int>(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<int>(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<int>(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
|
||||
}
|
||||
|
@ -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) {}
|
||||
@ -35,20 +35,12 @@ ReturnValue_t HealthHelper::initialize() {
|
||||
eventSender = ObjectManager::instance()->get<EventReportingProxyIF>(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 {:#010x} | 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 {:#010x} | Sending health reply failed\n",
|
||||
objectId);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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),
|
||||
@ -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<unsigned int>(newQueueHits));
|
||||
sif::printDebug("TM errors: %lu\n", static_cast<unsigned int>(newTmHits));
|
||||
sif::printDebug("Store errors: %lu\n", static_cast<unsigned int>(newStoreHits));
|
||||
#endif
|
||||
FSFW_LOGW("performOperation: Errors occured\nQueue {} | TM {} | Store {}\n", newQueueHits,
|
||||
newTmHits, newStoreHits);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
#define FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "MutexFactory.h"
|
||||
#include <fmt/core.h>
|
||||
|
||||
#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; }
|
||||
|
@ -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:
|
||||
|
@ -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),
|
||||
|
@ -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 {
|
||||
@ -81,11 +81,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(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;
|
||||
}
|
||||
}
|
||||
|
@ -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 <iomanip>
|
||||
@ -36,17 +36,10 @@ 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 {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast<uint32_t>(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<unsigned int>(id));
|
||||
sif::printError("Terminating program");
|
||||
#endif
|
||||
FSFW_LOGET("ObjectManager::insert: Object ID {:#010x} is already in use\nTerminating program\n",
|
||||
static_cast<uint32_t>(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 {:#010x} 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 {:#010x} failed to initialize with code {:#06x}\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 {:#010x} connection check failed with code {:#06x}\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("{:#010x} | {:#010x}\n", it.first, fmt::ptr(it.second));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
@ -56,11 +56,7 @@ ReturnValue_t TcpTmTcServer::initialize() {
|
||||
}
|
||||
tcStore = ObjectManager::instance()->get<StorageManagerIF>(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;
|
||||
}
|
||||
|
||||
@ -205,11 +201,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);
|
||||
}
|
||||
|
||||
@ -219,17 +211,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_LOGWT("handleTcReception: Data storage with packet size {} failed\n", packetSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -237,17 +219,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;
|
||||
@ -277,11 +249,7 @@ 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());
|
||||
}
|
||||
ssize_t retval = send(connSocket, reinterpret_cast<const char*>(storeAccessor.data()),
|
||||
@ -306,31 +274,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);
|
||||
|
@ -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 <winsock2.h>
|
||||
@ -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<StorageManagerIF>(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<UdpTmTcBridge>(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
|
||||
}
|
||||
|
@ -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 <ws2tcpip.h>
|
||||
@ -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<const char *>(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
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "fsfw/osal/common/tcpipCommon.h"
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
#include "fsfw/platform.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
#include <ws2tcpip.h>
|
||||
@ -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<struct sockaddr_in *>(addr);
|
||||
auto *addrIn = reinterpret_cast<struct sockaddr_in *>(addr);
|
||||
stringPtr = inet_ntop(AF_INET, &(addrIn->sin_addr), ipAddress, INET_ADDRSTRLEN);
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *addrIn = reinterpret_cast<struct sockaddr_in6 *>(addr);
|
||||
auto *addrIn = reinterpret_cast<struct sockaddr_in6 *>(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_LOGDT("Could not convert IP address to text representation, error code {} | {}", errno,
|
||||
strerror(errno));
|
||||
} else {
|
||||
sif::debug << "IP Address Sender: " << ipAddress << std::endl;
|
||||
FSFW_LOGDT("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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "fsfw/osal/freertos/Mutex.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
Mutex::Mutex() {
|
||||
handle = xSemaphoreCreateMutex();
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <sysinfoapi.h>
|
||||
@ -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) {
|
||||
|
@ -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<FixedTimeslotTask*>(argument));
|
||||
auto* originalTask(reinterpret_cast<FixedTimeslotTask*>(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<ExecutableObjectIF>(componentId);
|
||||
auto* executableObject = ObjectManager::instance()->get<ExecutableObjectIF>(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<unsigned int>(componentId));
|
||||
#endif
|
||||
FSFW_LOGE("addSlot: Component {:#010x} not found, not adding it to PST\n", componentId);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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<PeriodicTask*>(argument));
|
||||
auto* originalTask(reinterpret_cast<PeriodicTask*>(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() {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "fsfw/osal/common/tcpipHelpers.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <string>
|
||||
|
||||
#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) {
|
||||
@ -96,15 +95,9 @@ 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;
|
||||
#else
|
||||
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(),
|
||||
errorSrcString.c_str(), infoString.c_str());
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString);
|
||||
|
||||
if (sleepDuration > 0) {
|
||||
TaskFactory::instance()->delayTask(sleepDuration);
|
||||
TaskFactory::delayTask(sleepDuration);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "definitions.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
PowerSwitcher::PowerSwitcher(PowerSwitchIF* switcher, power::Switch_t setSwitch1,
|
||||
power::Switch_t setSwitch2, PowerSwitcher::State_t setStartState)
|
||||
|
@ -3,9 +3,12 @@
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
|
||||
PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF* pwrSwitcher, power::Switch_t pwrSwitch)
|
||||
: SystemObject(objectId), switcher(pwrSwitcher, pwrSwitch), modeHelper(this),
|
||||
healthHelper(this, objectId) {
|
||||
PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
|
||||
power::Switch_t pwrSwitch)
|
||||
: SystemObject(objectId),
|
||||
switcher(pwrSwitcher, pwrSwitch),
|
||||
modeHelper(this),
|
||||
healthHelper(this, objectId) {
|
||||
queue = QueueFactory::instance()->createMessageQueue();
|
||||
}
|
||||
|
||||
@ -25,12 +28,12 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(switcher.active()) {
|
||||
if (switcher.active()) {
|
||||
switcher.doStateMachine();
|
||||
auto currState = switcher.getState();
|
||||
if (currState == PowerSwitcher::SWITCH_IS_OFF) {
|
||||
setMode(MODE_OFF, 0);
|
||||
} else if(currState == PowerSwitcher::SWITCH_IS_ON) {
|
||||
} else if (currState == PowerSwitcher::SWITCH_IS_ON) {
|
||||
setMode(MODE_ON, 0);
|
||||
}
|
||||
}
|
||||
@ -39,19 +42,17 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) {
|
||||
|
||||
ReturnValue_t PowerSwitcherComponent::initialize() {
|
||||
ReturnValue_t result = modeHelper.initialize();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = healthHelper.initialize();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SystemObject::initialize();
|
||||
}
|
||||
|
||||
MessageQueueId_t PowerSwitcherComponent::getCommandQueue() const {
|
||||
return queue->getId();
|
||||
}
|
||||
MessageQueueId_t PowerSwitcherComponent::getCommandQueue() const { return queue->getId(); }
|
||||
|
||||
void PowerSwitcherComponent::getMode(Mode_t *mode, Submode_t *submode) {
|
||||
*mode = this->mode;
|
||||
@ -64,25 +65,25 @@ ReturnValue_t PowerSwitcherComponent::setHealth(HealthState health) {
|
||||
}
|
||||
|
||||
ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) {
|
||||
uint32_t *msToReachTheMode) {
|
||||
*msToReachTheMode = 5000;
|
||||
if(mode != MODE_ON and mode != MODE_OFF) {
|
||||
if (mode != MODE_ON and mode != MODE_OFF) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PowerSwitcherComponent::startTransition(Mode_t mode, Submode_t submode) {
|
||||
if(mode == MODE_OFF) {
|
||||
if (mode == MODE_OFF) {
|
||||
switcher.turnOff(true);
|
||||
switcher.doStateMachine();
|
||||
if(switcher.getState() == PowerSwitcher::SWITCH_IS_OFF) {
|
||||
if (switcher.getState() == PowerSwitcher::SWITCH_IS_OFF) {
|
||||
setMode(MODE_OFF, 0);
|
||||
}
|
||||
} else if (mode == MODE_ON) {
|
||||
switcher.turnOn(true);
|
||||
switcher.doStateMachine();
|
||||
if(switcher.getState() == PowerSwitcher::SWITCH_IS_ON) {
|
||||
if (switcher.getState() == PowerSwitcher::SWITCH_IS_ON) {
|
||||
setMode(MODE_ON, 0);
|
||||
}
|
||||
}
|
||||
@ -103,6 +104,4 @@ void PowerSwitcherComponent::setMode(Mode_t newMode, Submode_t newSubmode) {
|
||||
announceMode(false);
|
||||
}
|
||||
|
||||
HasHealthIF::HealthState PowerSwitcherComponent::getHealth() {
|
||||
return healthHelper.getHealth();
|
||||
}
|
||||
HasHealthIF::HealthState PowerSwitcherComponent::getHealth() { return healthHelper.getHealth(); }
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <fsfw/modes/HasModesIF.h>
|
||||
#include <fsfw/modes/ModeHelper.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/power/definitions.h>
|
||||
#include <fsfw/power/PowerSwitcher.h>
|
||||
#include <fsfw/power/definitions.h>
|
||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||
|
||||
class PowerSwitchIF;
|
||||
@ -22,19 +22,17 @@ class PowerSwitchIF;
|
||||
* Commanding this component to MODE_OFF will cause the switcher to turn the switch off while
|
||||
* commanding in to MODE_ON will cause the switcher to turn the switch on.
|
||||
*/
|
||||
class PowerSwitcherComponent:
|
||||
public SystemObject,
|
||||
public HasReturnvaluesIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasModesIF,
|
||||
public HasHealthIF {
|
||||
public:
|
||||
PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF* pwrSwitcher,
|
||||
power::Switch_t pwrSwitch);
|
||||
class PowerSwitcherComponent : public SystemObject,
|
||||
public HasReturnvaluesIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasModesIF,
|
||||
public HasHealthIF {
|
||||
public:
|
||||
PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
|
||||
power::Switch_t pwrSwitch);
|
||||
|
||||
private:
|
||||
|
||||
MessageQueueIF* queue = nullptr;
|
||||
private:
|
||||
MessageQueueIF *queue = nullptr;
|
||||
PowerSwitcher switcher;
|
||||
|
||||
Mode_t mode = MODE_OFF;
|
||||
@ -52,7 +50,7 @@ private:
|
||||
MessageQueueId_t getCommandQueue() const override;
|
||||
void getMode(Mode_t *mode, Submode_t *submode) override;
|
||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) override;
|
||||
uint32_t *msToReachTheMode) override;
|
||||
void startTransition(Mode_t mode, Submode_t submode) override;
|
||||
void setToExternalControl() override;
|
||||
void announceMode(bool recursive) override;
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
@ -20,9 +20,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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user