added multiple reply support
This commit is contained in:
parent
42720e6f7d
commit
18a9729c75
@ -456,6 +456,15 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t DeviceHandlerBase::getNextReplyLength(DeviceCommandId_t commandId){
|
||||||
|
DeviceReplyIter iter = deviceReplyMap.find(commandId);
|
||||||
|
if(iter != deviceReplyMap.end()) {
|
||||||
|
return iter->second.replyLen;
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply,
|
ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply,
|
||||||
uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) {
|
uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) {
|
||||||
auto replyIter = deviceReplyMap.find(deviceReply);
|
auto replyIter = deviceReplyMap.find(deviceReply);
|
||||||
@ -646,16 +655,12 @@ void DeviceHandlerBase::doGetWrite() {
|
|||||||
void DeviceHandlerBase::doSendRead() {
|
void DeviceHandlerBase::doSendRead() {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
|
|
||||||
size_t requestLen = 0;
|
size_t replyLen = 0;
|
||||||
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
||||||
DeviceReplyIter iter = deviceReplyMap.find(
|
replyLen = getNextReplyLength(cookieInfo.pendingCommand->first);
|
||||||
cookieInfo.pendingCommand->first);
|
|
||||||
if(iter != deviceReplyMap.end()) {
|
|
||||||
requestLen = iter->second.replyLen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = communicationInterface->requestReceiveMessage(comCookie, requestLen);
|
result = communicationInterface->requestReceiveMessage(comCookie, replyLen);
|
||||||
|
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
cookieInfo.state = COOKIE_READ_SENT;
|
cookieInfo.state = COOKIE_READ_SENT;
|
||||||
|
@ -471,6 +471,7 @@ protected:
|
|||||||
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand,
|
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand,
|
||||||
uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr,
|
uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr,
|
||||||
size_t replyLen = 0, bool periodic = false);
|
size_t replyLen = 0, bool periodic = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A simple command to add a command to the commandList.
|
* @brief A simple command to add a command to the commandList.
|
||||||
* @param deviceCommand The command to add
|
* @param deviceCommand The command to add
|
||||||
@ -478,6 +479,19 @@ protected:
|
|||||||
* - @c RETURN_FAILED else.
|
* - @c RETURN_FAILED else.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand);
|
ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function returns the reply length of the next reply to read.
|
||||||
|
*
|
||||||
|
* @param deviceCommand The command which triggered the device reply.
|
||||||
|
*
|
||||||
|
* @details The default implementation assumes only one reply is triggered by the command. In
|
||||||
|
* case the command triggers multiple replies (e.g. one acknowledgment, one data,
|
||||||
|
* and one execution status reply), this function can be overwritten to get the
|
||||||
|
* reply length of the next reply to read.
|
||||||
|
*/
|
||||||
|
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is a helper method to facilitate updating entries
|
* @brief This is a helper method to facilitate updating entries
|
||||||
* in the reply map.
|
* in the reply map.
|
||||||
@ -953,7 +967,7 @@ protected:
|
|||||||
* - NO_REPLY_EXPECTED if there was no reply found. This is not an
|
* - NO_REPLY_EXPECTED if there was no reply found. This is not an
|
||||||
* error case as many commands do not expect a reply.
|
* error case as many commands do not expect a reply.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator cmd,
|
virtual ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||||
uint8_t expectedReplies = 1, 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