moved activation of periodic replies to updatePeriodicReply
This commit is contained in:
parent
3e9ae62b28
commit
2d2f65bf89
@ -446,9 +446,6 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
|
|||||||
info.dataSet = dataSet;
|
info.dataSet = dataSet;
|
||||||
info.command = deviceCommandMap.end();
|
info.command = deviceCommandMap.end();
|
||||||
info.countdown = countdown;
|
info.countdown = countdown;
|
||||||
if (info.periodic) {
|
|
||||||
info.active = true;
|
|
||||||
}
|
|
||||||
auto resultPair = deviceReplyMap.emplace(replyId, info);
|
auto resultPair = deviceReplyMap.emplace(replyId, info);
|
||||||
if (resultPair.second) {
|
if (resultPair.second) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
@ -522,8 +519,10 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI
|
|||||||
}
|
}
|
||||||
if (enable) {
|
if (enable) {
|
||||||
info->delayCycles = info->maxDelayCycles;
|
info->delayCycles = info->maxDelayCycles;
|
||||||
|
info->active = true;
|
||||||
} else {
|
} else {
|
||||||
info->delayCycles = 0;
|
info->delayCycles = 0;
|
||||||
|
info->active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
@ -999,6 +998,8 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato
|
|||||||
}
|
}
|
||||||
if (iter != deviceReplyMap.end()) {
|
if (iter != deviceReplyMap.end()) {
|
||||||
DeviceReplyInfo* info = &(iter->second);
|
DeviceReplyInfo* info = &(iter->second);
|
||||||
|
// If a countdown has been set, the delay cycles will be ignored and the reply times out
|
||||||
|
// as soon as the countdown has expired
|
||||||
info->delayCycles = info->maxDelayCycles;
|
info->delayCycles = info->maxDelayCycles;
|
||||||
info->command = command;
|
info->command = command;
|
||||||
command->second.expectedReplies = expectedReplies;
|
command->second.expectedReplies = expectedReplies;
|
||||||
|
@ -93,3 +93,11 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
|
|||||||
void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
|
void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
|
||||||
|
|
||||||
bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; }
|
bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; }
|
||||||
|
|
||||||
|
ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) {
|
||||||
|
return updatePeriodicReply(true, replyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t DeviceHandlerMock::disablePeriodicReply(DeviceCommandId_t replyId) {
|
||||||
|
return updatePeriodicReply(false, replyId);
|
||||||
|
}
|
||||||
|
@ -18,6 +18,8 @@ class DeviceHandlerMock : public DeviceHandlerBase {
|
|||||||
void changeSimpleCommandReplyCountdown(uint32_t timeout);
|
void changeSimpleCommandReplyCountdown(uint32_t timeout);
|
||||||
void resetPeriodicReplyState();
|
void resetPeriodicReplyState();
|
||||||
bool getPeriodicReplyReceived();
|
bool getPeriodicReplyReceived();
|
||||||
|
ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId);
|
||||||
|
ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
|
@ -60,6 +60,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
|||||||
|
|
||||||
SECTION("Periodic reply nominal") {
|
SECTION("Periodic reply nominal") {
|
||||||
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
|
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
|
||||||
|
deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||||
@ -72,6 +73,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
|||||||
comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY);
|
comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY);
|
||||||
// Set the timeout to 0 to immediately timeout the reply
|
// Set the timeout to 0 to immediately timeout the reply
|
||||||
deviceHandlerMock.changePeriodicReplyCountdown(0);
|
deviceHandlerMock.changePeriodicReplyCountdown(0);
|
||||||
|
deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||||
@ -79,5 +81,15 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
|||||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
|
||||||
uint32_t missedReplies = deviceFdirMock.getMissedReplyCount();
|
uint32_t missedReplies = deviceFdirMock.getMissedReplyCount();
|
||||||
REQUIRE(missedReplies == 1);
|
REQUIRE(missedReplies == 1);
|
||||||
|
// Test if disabling of periodic reply
|
||||||
|
deviceHandlerMock.disablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ);
|
||||||
|
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
|
||||||
|
missedReplies = deviceFdirMock.getMissedReplyCount();
|
||||||
|
// Should still be 1 because periodic reply is now disabled
|
||||||
|
REQUIRE(missedReplies == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user