assuming that a default value of 0 for expectedReplies is needed, I introduced a new variable into DeviceCommandInfo, which stores another number of replies expected. this value is assigned in enableReplyInReplyMap. That way, the initial value of 0 remains the same (if it was needed), and is only set to another desired value if a write was sent

This commit is contained in:
Robin Müller 2019-11-04 01:55:40 +01:00
parent 12f51575eb
commit cb919ada2a
2 changed files with 10 additions and 4 deletions

View File

@ -285,7 +285,8 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
ReturnValue_t DeviceHandlerBase::insertInCommandMap(
DeviceCommandId_t deviceCommand, uint8_t expectedReplies) {
DeviceCommandInfo info;
info.expectedReplies = expectedReplies;
info.expectedReplies = 0;
info.expectedRepliesWhenEnablingReplyMap = expectedReplies;
info.isExecuting = false;
info.sendReplyTo = NO_COMMANDER;
std::pair<std::map<DeviceCommandId_t, DeviceCommandInfo>::iterator, bool> returnValue;
@ -821,7 +822,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = info->maxDelayCycles;
info->command = command;
// command->second.expectedReplies = expectedReplies;
command->second.expectedReplies = command->second.expectedRepliesWhenEnablingReplyMap;
return RETURN_OK;
} else {
return NO_REPLY_EXPECTED;

View File

@ -704,7 +704,8 @@ protected:
struct DeviceCommandInfo {
bool isExecuting; //!< Indicates if the command is already executing.
uint8_t expectedReplies; //!< Dynamic value to indicate how many replies are expected.
uint8_t expectedReplies; //!< Dynamic value to indicate how many replies are expected. Inititated with 0.
uint8_t expectedRepliesWhenEnablingReplyMap; //!< Constant value which specifies expected replies when enabling reply map. Inititated in insertInCommandAndReplyMap()
MessageQueueId_t sendReplyTo; //!< if this is != NO_COMMANDER, DHB was commanded externally and shall report everything to commander.
};
@ -732,8 +733,12 @@ protected:
* do not expect a reply.
*/
// Proposal: Set expected replies in insertInCommandAndReplyMap so we don't have to overwrite that function anymore.
// Replies are only checked when a write was issued and the default value here was one, so
// it should be possible to set this in the DeviceCommandMap with default value one.
// UPDATE: The default value of 0 when inserting into command and reply map is retained now by introducing a new
// variable in the DeviceCommandInfo which specifies expected replies if this function is called.
virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd,
/* uint8_t expectedReplies = 0 */ bool useAlternateId = false,
/* uint8_t expectedReplies = 1, */ bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0);
/**