From 692be9df8d06beb3bfc83aad77cefd727d8f7c35 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 6 Oct 2022 16:57:47 +0200 Subject: [PATCH] DHB bugfix and addition --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 13 ++++++++++++- src/fsfw/devicehandlers/DeviceHandlerBase.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 8f23b112..c641eb58 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -467,7 +467,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm info.expectedReplies = 0; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; - info.useAlternativeReplyId = alternativeReplyId; + info.useAlternativeReplyId = useAlternativeReply; info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { @@ -1601,3 +1601,14 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } } } + +ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t action, + ReturnValue_t result) { + auto commandIter = deviceCommandMap.find(action); + if (commandIter == deviceCommandMap.end()) { + return MessageQueueIF::NO_QUEUE; + } + commandIter->second.isExecuting = false; + actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); + return returnvalue::OK; +} diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 7c93e921..0efecbd5 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -399,6 +399,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) = 0; MessageQueueId_t getCommanderQueueId(DeviceCommandId_t replyId) const; + ReturnValue_t finishAction(bool success, DeviceCommandId_t action, ReturnValue_t result); + /** * Helper function to get pending command. This is useful for devices * like SPI sensors to identify the last sent command.