WIP: Update DHB command and reply map helpers #103

Closed
muellerr wants to merge 7 commits from mueller/update-cmd-reply-maps-refactoring into develop
4 changed files with 78 additions and 21 deletions

View File

@ -19,12 +19,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bump C++ required version to C++17. Every project which uses the FSFW and every modern - Bump C++ required version to C++17. Every project which uses the FSFW and every modern
compiler supports it compiler supports it
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622
- HAL Linux SPI: Set the Clock Default State when setting new SPI speed
and mode
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573
- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents
name clashes with Windows defines.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. - New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- HAL Devicehandlers: Periodic printout is run-time configurable now - HAL Devicehandlers: Periodic printout is run-time configurable now
@ -91,6 +85,7 @@ PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/636
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572
- HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations - HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585
- Linux HAL: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1
### Time ### Time
@ -153,17 +148,6 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590 PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590
- `Subsystem`: New API to add table and sequence entries - `Subsystem`: New API to add table and sequence entries
## HAL
- SPI: Cache the SPI device in the communication interface. Architecturally, this makes a
lot more sense because each ComIF should be responsible for one SPI bus.
- SPI: Move the empty transfer to update the line polarity to separate function. This means
it is not automatically called when calling the setter function for SPI speed and mode.
The user should call this function after locking the CS mutex if multiple SPI devices with
differing speeds and modes are attached to one bus.
- SPI: Getter functions for SPI speed and mode.
- I2C: Add wiretapping option for I2C. Enabled with `FSFW_HAL_I2C_WIRETAPPING` defined to 1.
## Fixed ## Fixed
- TCP TMTC Server: `MutexGuard` was not created properly in - TCP TMTC Server: `MutexGuard` was not created properly in

View File

@ -189,7 +189,7 @@ message(
) )
# Check whether the user has already installed ETL first # Check whether the user has already installed ETL first
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
# Not installed, so use FetchContent to download and provide etl # Not installed, so use FetchContent to download and provide etl
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
message( message(

View File

@ -7,6 +7,7 @@
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"
#include "DeviceHandlerIF.h" #include "DeviceHandlerIF.h"
#include "DeviceHandlerThermalSet.h" #include "DeviceHandlerThermalSet.h"
#include "DhbCfgHelpers.h"
#include "fsfw/action/ActionHelper.h" #include "fsfw/action/ActionHelper.h"
#include "fsfw/action/HasActionsIF.h" #include "fsfw/action/HasActionsIF.h"
#include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/datapool/PoolVariableIF.h"
@ -488,9 +489,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* @return - @c RETURN_OK when the command was successfully inserted, * @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInCommandMap(
bool useAlternativeReply = false, DeviceCommandId_t deviceCommand, bool useAlternativeReply = false,
DeviceCommandId_t alternativeReplyId = 0); DeviceCommandId_t alternativeReplyId = DeviceHandlerIF::NO_COMMAND_ID);
/** /**
* Enables a periodic reply for a given command. It sets to delay cycles to the specified * Enables a periodic reply for a given command. It sets to delay cycles to the specified

View File

@ -0,0 +1,72 @@
#ifndef FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
#define FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_
/**
* @brief This is the base class for configuration related to both DHB commands, replies and their
* combination
*/
struct CfgBase {
public:
explicit CfgBase(DeviceCommandId_t cmdAndOrReplyId) : cmdAndOrReplyId(cmdAndOrReplyId){};
DeviceCommandId_t cmdAndOrReplyId;
};
/**
* @brief Configuration class for commands
*/
struct CmdCfg {
public:
explicit CmdCfg(DeviceCommandId_t cmdId) : baseCfg(cmdId){};
CfgBase baseCfg;
//! This can be used if a command can trigger multiple replies
std::pair<bool, DeviceCommandId_t> alternativeReply = {false, DeviceHandlerIF::NO_COMMAND_ID};
};
/**
* @brief Configuration class for replies
*/
struct ReplyCfg {
public:
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles)
: baseCfg(replyId), maxDelayCycles(maxDelayCycles){};
ReplyCfg(DeviceCommandId_t replyId, uint16_t maxDelayCycles, LocalPoolDataSetBase* set)
: ReplyCfg(replyId, maxDelayCycles) {
dataSet = set;
};
CfgBase baseCfg;
//! A data set can be mapped to a reply ID. This allows to omit the #getDataSetHandle
//! override in a user device handler as this pointer will be passed as long as the device
//! command ID is equal to the set ID.
LocalPoolDataSetBase* dataSet = nullptr;
//! For Command-Reply combinations:
//! The maximum number of cycles the handler should wait for a reply
//! to this command.
//!
//! Reply Only:
//! For periodic replies, this variable will be the number of delay cycles between the replies.
//! For the non-periodic variant, this variable is not used as there is no meaningful
//! definition for delay
uint16_t maxDelayCycles = 0;
//! First parameter: Specify whether reply is arriving periodically
//! Second parameter: Specify whether periodic reply should be enabled immediately
std::pair<bool, bool> periodicCfg = {false, false};
//! If a reply needs to be requested with a specific length, the length can be specified here
size_t replyLen = 0;
//! It is also possible to use a time based instead of a cycle based mechanism to specify
//! how long a reply takes. For non-periodic replies without a command, this variable is not used.
Countdown* countdown = nullptr;
};
/**
* @brief Configuration class for commands and replies
*/
struct CmdReplyCfg {
public:
CmdReplyCfg(CmdCfg cmdCfg, ReplyCfg replyCfg) : cmdCfg(cmdCfg), replyCfg(replyCfg) {}
CmdCfg cmdCfg;
ReplyCfg replyCfg;
};
#endif /* FSFW_SRC_FSFW_DEVICEHANDLERS_DHBCFGHELPERS_H_ */