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.command = deviceCommandMap.end();
|
||||
info.countdown = countdown;
|
||||
if (info.periodic) {
|
||||
info.active = true;
|
||||
}
|
||||
auto resultPair = deviceReplyMap.emplace(replyId, info);
|
||||
if (resultPair.second) {
|
||||
return RETURN_OK;
|
||||
@ -522,8 +519,10 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI
|
||||
}
|
||||
if (enable) {
|
||||
info->delayCycles = info->maxDelayCycles;
|
||||
info->active = true;
|
||||
} else {
|
||||
info->delayCycles = 0;
|
||||
info->active = false;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -999,6 +998,8 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato
|
||||
}
|
||||
if (iter != deviceReplyMap.end()) {
|
||||
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->command = command;
|
||||
command->second.expectedReplies = expectedReplies;
|
||||
|
@ -93,3 +93,11 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
|
||||
void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
|
||||
|
||||
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 resetPeriodicReplyState();
|
||||
bool getPeriodicReplyReceived();
|
||||
ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId);
|
||||
ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId);
|
||||
|
||||
protected:
|
||||
void doStartUp() override;
|
||||
|
@ -60,6 +60,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
||||
|
||||
SECTION("Periodic reply nominal") {
|
||||
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
|
||||
deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||
@ -72,6 +73,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
||||
comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY);
|
||||
// Set the timeout to 0 to immediately timeout the reply
|
||||
deviceHandlerMock.changePeriodicReplyCountdown(0);
|
||||
deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE);
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE);
|
||||
@ -79,5 +81,15 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
||||
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
|
||||
uint32_t missedReplies = deviceFdirMock.getMissedReplyCount();
|
||||
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…
Reference in New Issue
Block a user