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:
parent
12f51575eb
commit
cb919ada2a
@ -285,7 +285,8 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
|
|||||||
ReturnValue_t DeviceHandlerBase::insertInCommandMap(
|
ReturnValue_t DeviceHandlerBase::insertInCommandMap(
|
||||||
DeviceCommandId_t deviceCommand, uint8_t expectedReplies) {
|
DeviceCommandId_t deviceCommand, uint8_t expectedReplies) {
|
||||||
DeviceCommandInfo info;
|
DeviceCommandInfo info;
|
||||||
info.expectedReplies = expectedReplies;
|
info.expectedReplies = 0;
|
||||||
|
info.expectedRepliesWhenEnablingReplyMap = expectedReplies;
|
||||||
info.isExecuting = false;
|
info.isExecuting = false;
|
||||||
info.sendReplyTo = NO_COMMANDER;
|
info.sendReplyTo = NO_COMMANDER;
|
||||||
std::pair<std::map<DeviceCommandId_t, DeviceCommandInfo>::iterator, bool> returnValue;
|
std::pair<std::map<DeviceCommandId_t, DeviceCommandInfo>::iterator, bool> returnValue;
|
||||||
@ -821,7 +822,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
|
|||||||
DeviceReplyInfo *info = &(iter->second);
|
DeviceReplyInfo *info = &(iter->second);
|
||||||
info->delayCycles = info->maxDelayCycles;
|
info->delayCycles = info->maxDelayCycles;
|
||||||
info->command = command;
|
info->command = command;
|
||||||
// command->second.expectedReplies = expectedReplies;
|
command->second.expectedReplies = command->second.expectedRepliesWhenEnablingReplyMap;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
return NO_REPLY_EXPECTED;
|
return NO_REPLY_EXPECTED;
|
||||||
|
@ -704,7 +704,8 @@ protected:
|
|||||||
|
|
||||||
struct DeviceCommandInfo {
|
struct DeviceCommandInfo {
|
||||||
bool isExecuting; //!< Indicates if the command is already executing.
|
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.
|
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.
|
* do not expect a reply.
|
||||||
*/
|
*/
|
||||||
// Proposal: Set expected replies in insertInCommandAndReplyMap so we don't have to overwrite that function anymore.
|
// 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,
|
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);
|
DeviceCommandId_t alternateReplyID = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user