From a6d744c9c8df4e2cd69c170a4bd6806f54b835f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Sep 2021 12:05:30 +0200 Subject: [PATCH 1/4] Possible bugfix in DHB The delayCycles variables needs to be initialized differently for periodic replies. It is initialized to the maxDelayCycles value now --- devicehandlers/DeviceHandlerBase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 5665b101b..733701b27 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -430,7 +430,12 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, DeviceReplyInfo info; info.maxDelayCycles = maxDelayCycles; info.periodic = periodic; - info.delayCycles = 0; + if(info.periodic) { + info.delayCycles = info.maxDelayCycles; + } + else { + info.delayCycles = 0; + } info.replyLen = replyLen; info.dataSet = dataSet; info.command = deviceCommandMap.end(); -- 2.34.1 From c9bfc8464aede0f79c167e18c5c0c79ded2444ce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 11 Sep 2021 17:39:42 +0200 Subject: [PATCH 2/4] added function to enable periodic reply --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 23 +++++++++++------ src/fsfw/devicehandlers/DeviceHandlerBase.h | 25 +++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 1a7fbc911..95e25b74a 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -430,12 +430,7 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, DeviceReplyInfo info; info.maxDelayCycles = maxDelayCycles; info.periodic = periodic; - if(info.periodic) { - info.delayCycles = info.maxDelayCycles; - } - else { - info.delayCycles = 0; - } + info.delayCycles = 0; info.replyLen = replyLen; info.dataSet = dataSet; info.command = deviceCommandMap.end(); @@ -474,7 +469,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep auto replyIter = deviceReplyMap.find(deviceReply); if (replyIter == deviceReplyMap.end()) { triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); - return RETURN_FAILED; + return COMMAND_NOT_SUPPORTED; } else { DeviceReplyInfo *info = &(replyIter->second); if (maxDelayCycles != 0) { @@ -486,6 +481,20 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep } } +ReturnValue_t DeviceHandlerBase::enablePeriodicReply(DeviceCommandId_t deviceReply) { + auto replyIter = deviceReplyMap.find(deviceReply); + if (replyIter == deviceReplyMap.end()) { + triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); + return COMMAND_NOT_SUPPORTED; + } else { + DeviceReplyInfo *info = &(replyIter->second); + if(not info->periodic) { + return COMMAND_NOT_SUPPORTED; + } + info->delayCycles = info->maxDelayCycles; + } + return HasReturnvaluesIF::RETURN_OK; +} ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, LocalPoolDataSetBase *dataSet) { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 53bd1e653..d478b0fa7 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -449,7 +449,9 @@ protected: * @param replyLen Will be supplied to the requestReceiveMessage call of * the communication interface. * @param periodic Indicates if the command is periodic (i.e. it is sent - * by the device repeatedly without request) or not. Default is aperiodic (0) + * by the device repeatedly without request) or not. Default is aperiodic (0). + * Please note that periodic replies are disabled by default. You can enable them with + * #enablePeriodicReplies * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ @@ -464,7 +466,9 @@ protected: * @param maxDelayCycles The maximum number of delay cycles the reply waits * until it times out. * @param periodic Indicates if the command is periodic (i.e. it is sent - * by the device repeatedly without request) or not. Default is aperiodic (0) + * by the device repeatedly without request) or not. Default is aperiodic (0). + * Please note that periodic replies are disabled by default. You can enable them with + * #enablePeriodicReplies * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ @@ -480,6 +484,13 @@ protected: */ ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand); + /** + * Enables a periodic reply for a given command. It sets to delay cycles to the specified + * maximum delay cycles for a given reply ID. + * @return + */ + ReturnValue_t enablePeriodicReply(DeviceCommandId_t deviceReply); + /** * @brief This function returns the reply length of the next reply to read. * @@ -493,16 +504,14 @@ protected: virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand); /** - * @brief This is a helper method to facilitate updating entries - * in the reply map. + * @brief This is a helper method to facilitate updating entries in the reply map. * @param deviceCommand Identifier of the reply to update. - * @param delayCycles The current number of delay cycles to wait. - * As stated in #fillCommandAndCookieMap, to disable periodic commands, - * this is set to zero. + * @param delayCycles The current number of delay cycles to wait. As stated in + * #fillCommandAndReplyMap, to disable periodic commands, this is set to zero. * @param maxDelayCycles The maximum number of delay cycles the reply waits * until it times out. By passing 0 the entry remains untouched. * @param periodic Indicates if the command is periodic (i.e. it is sent - * by the device repeatedly without request) or not.Default is aperiodic (0). + * by the device repeatedly without request) or not. Default is aperiodic (0). * Warning: The setting always overrides the value that was entered in the map. * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. -- 2.34.1 From 11a3c8c21f8a80d5c0872e99e39bd655f18acfa7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 11 Sep 2021 17:42:29 +0200 Subject: [PATCH 3/4] added option to disable it as well --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 9 +++++++-- src/fsfw/devicehandlers/DeviceHandlerBase.h | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 95e25b74a..aab3aa16c 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -481,7 +481,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep } } -ReturnValue_t DeviceHandlerBase::enablePeriodicReply(DeviceCommandId_t deviceReply) { +ReturnValue_t DeviceHandlerBase::enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply) { auto replyIter = deviceReplyMap.find(deviceReply); if (replyIter == deviceReplyMap.end()) { triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); @@ -491,7 +491,12 @@ ReturnValue_t DeviceHandlerBase::enablePeriodicReply(DeviceCommandId_t deviceRep if(not info->periodic) { return COMMAND_NOT_SUPPORTED; } - info->delayCycles = info->maxDelayCycles; + if(enable) { + info->delayCycles = info->maxDelayCycles; + } + else { + info->delayCycles = 0; + } } return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index d478b0fa7..138b429eb 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -486,10 +486,11 @@ protected: /** * Enables a periodic reply for a given command. It sets to delay cycles to the specified - * maximum delay cycles for a given reply ID. + * maximum delay cycles for a given reply ID if enabled or to 0 if disabled. + * @param enable Specify whether to enable or disable a given periodic reply * @return */ - ReturnValue_t enablePeriodicReply(DeviceCommandId_t deviceReply); + ReturnValue_t enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply); /** * @brief This function returns the reply length of the next reply to read. -- 2.34.1 From 134deb3f433988513617a0d510fbbf8629b34fbc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 11 Sep 2021 17:43:58 +0200 Subject: [PATCH 4/4] renamed function --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index aab3aa16c..c3fc023e9 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -481,7 +481,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep } } -ReturnValue_t DeviceHandlerBase::enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply) { +ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandId_t deviceReply) { auto replyIter = deviceReplyMap.find(deviceReply); if (replyIter == deviceReplyMap.end()) { triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 138b429eb..30d36ef0a 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -451,7 +451,7 @@ protected: * @param periodic Indicates if the command is periodic (i.e. it is sent * by the device repeatedly without request) or not. Default is aperiodic (0). * Please note that periodic replies are disabled by default. You can enable them with - * #enablePeriodicReplies + * #updatePeriodicReply * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ @@ -468,7 +468,7 @@ protected: * @param periodic Indicates if the command is periodic (i.e. it is sent * by the device repeatedly without request) or not. Default is aperiodic (0). * Please note that periodic replies are disabled by default. You can enable them with - * #enablePeriodicReplies + * #updatePeriodicReply * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ @@ -490,7 +490,7 @@ protected: * @param enable Specify whether to enable or disable a given periodic reply * @return */ - ReturnValue_t enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply); + ReturnValue_t updatePeriodicReply(bool enable, DeviceCommandId_t deviceReply); /** * @brief This function returns the reply length of the next reply to read. -- 2.34.1