run auto-formatter

This commit is contained in:
Jakob Meier 2022-06-06 11:55:42 +02:00
parent 4fba2704aa
commit ae2f7219fd
17 changed files with 136 additions and 156 deletions

View File

@ -188,7 +188,10 @@ and open the documentation conveniently. Try `helper.py -h for more information.
The formatting is done by the `clang-format` tool. The configuration is contained within the The formatting is done by the `clang-format` tool. The configuration is contained within the
`.clang-format` file in the repository root. As long as `clang-format` is installed, you `.clang-format` file in the repository root. As long as `clang-format` is installed, you
can run the `apply-clang-format.sh` helper script to format all source files consistently. can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with:
````sh
sudo pip install cmakelang
````
## Index ## Index

View File

@ -66,7 +66,7 @@ void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId
DeviceHandlerBase::~DeviceHandlerBase() { DeviceHandlerBase::~DeviceHandlerBase() {
if (comCookie != nullptr) { if (comCookie != nullptr) {
delete comCookie; delete comCookie;
} }
if (defaultFDIRUsed) { if (defaultFDIRUsed) {
delete fdirInstance; delete fdirInstance;
@ -256,7 +256,7 @@ void DeviceHandlerBase::decrementDeviceReplyMap() {
missedReply(replyPair.first); missedReply(replyPair.first);
timedOut = false; timedOut = false;
if (not replyPair.second.periodic) { if (not replyPair.second.periodic) {
replyPair.second.active = false; replyPair.second.active = false;
} }
} }
} }
@ -1396,8 +1396,7 @@ uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand)
DeviceReplyMap::iterator iter = deviceReplyMap.find(deviceCommand); DeviceReplyMap::iterator iter = deviceReplyMap.find(deviceCommand);
if (iter == deviceReplyMap.end()) { if (iter == deviceReplyMap.end()) {
return 0; return 0;
} } else if (iter->second.countdown != nullptr) {
else if (iter->second.countdown != nullptr) {
return 0; return 0;
} }
return iter->second.delayCycles; return iter->second.delayCycles;

View File

@ -792,7 +792,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
DeviceCommandMap::iterator command; DeviceCommandMap::iterator command;
//! Instead of using delayCycles to specify the maximum time to wait for the device reply, it //! Instead of using delayCycles to specify the maximum time to wait for the device reply, it
//! is also possible specify a countdown //! is also possible specify a countdown
Countdown* countdown = nullptr; Countdown *countdown = nullptr;
//! will be set to true when reply is enabled //! will be set to true when reply is enabled
bool active = false; bool active = false;
}; };
@ -1259,13 +1259,13 @@ class DeviceHandlerBase : public DeviceHandlerIF,
/** /**
* @brief Handles disabling of replies which use a timeout to detect missed replies. * @brief Handles disabling of replies which use a timeout to detect missed replies.
*/ */
void disableTimeoutControlledReply(DeviceReplyInfo* info); void disableTimeoutControlledReply(DeviceReplyInfo *info);
/** /**
* @brief Handles disabling of replies which use a number of maximum delay cycles to detect * @brief Handles disabling of replies which use a number of maximum delay cycles to detect
* missed replies. * missed replies.
*/ */
void disableDelayCyclesControlledReply(DeviceReplyInfo* info); void disableDelayCyclesControlledReply(DeviceReplyInfo *info);
/** /**
* Retrive data from the #IPCStore. * Retrive data from the #IPCStore.

View File

@ -37,8 +37,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy
EventId_t idTo = 0, bool idInverted = false, EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0, object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
bool reporterInverted = false); bool reporterInverted = false);
ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object);
object_id_t object);
ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0,
EventId_t idTo = 0, bool idInverted = false, EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterTo = 0, object_id_t reporterFrom = 0, object_id_t reporterTo = 0,

View File

@ -20,8 +20,7 @@ class EventManagerIF {
bool forwardAllButSelected = false) = 0; bool forwardAllButSelected = false) = 0;
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0; virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0;
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0; virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0;
virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object) = 0;
object_id_t object) = 0;
virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0,
EventId_t idTo = 0, bool idInverted = false, EventId_t idTo = 0, bool idInverted = false,
object_id_t reporterFrom = 0, object_id_t reporterFrom = 0,

View File

@ -15,16 +15,16 @@ FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent
FailureIsolationBase::~FailureIsolationBase() { FailureIsolationBase::~FailureIsolationBase() {
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER); EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) { if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not" sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not"
" been initialized!" " been initialized!"
<< std::endl; << std::endl;
#endif #endif
return; return;
} }
manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId); manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId);
QueueFactory::instance()->deleteMessageQueue(eventQueue); QueueFactory::instance()->deleteMessageQueue(eventQueue);
} }
ReturnValue_t FailureIsolationBase::initialize() { ReturnValue_t FailureIsolationBase::initialize() {

View File

@ -6,12 +6,7 @@
class FaultCounter : public HasParametersIF { class FaultCounter : public HasParametersIF {
public: public:
enum class ParameterIds { FAILURE_THRESHOLD, FAULT_COUNT, TIMEOUT };
enum class ParameterIds {
FAILURE_THRESHOLD,
FAULT_COUNT,
TIMEOUT
};
FaultCounter(); FaultCounter();
FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs, FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs,
@ -30,10 +25,10 @@ class FaultCounter : public HasParametersIF {
void setFailureThreshold(uint32_t failureThreshold); void setFailureThreshold(uint32_t failureThreshold);
void setFaultDecrementTimeMs(uint32_t timeMs); void setFaultDecrementTimeMs(uint32_t timeMs);
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
ParameterWrapper *parameterWrapper, ParameterWrapper *parameterWrapper,
const ParameterWrapper *newValues = nullptr, uint16_t startAtIndex = const ParameterWrapper *newValues = nullptr,
0); uint16_t startAtIndex = 0);
void setParameterDomain(uint8_t domain); void setParameterDomain(uint8_t domain);

View File

@ -5,9 +5,7 @@
HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId)
: objectId(objectId), owner(owner) {} : objectId(objectId), owner(owner) {}
HealthHelper::~HealthHelper() { HealthHelper::~HealthHelper() { healthTable->removeObject(objectId); }
healthTable->removeObject(objectId);
}
ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) {
switch (message->getCommand()) { switch (message->getCommand()) {

View File

@ -28,10 +28,10 @@ ReturnValue_t HealthTable::registerObject(object_id_t object,
} }
ReturnValue_t HealthTable::removeObject(object_id_t object) { ReturnValue_t HealthTable::removeObject(object_id_t object) {
mapIterator = healthMap.find(object); mapIterator = healthMap.find(object);
if (mapIterator == healthMap.end()) { if (mapIterator == healthMap.end()) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
healthMap.erase(mapIterator); healthMap.erase(mapIterator);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -1,7 +1,8 @@
#include "ComIFMock.h" #include "ComIFMock.h"
#include "DeviceHandlerMock.h" #include "DeviceHandlerMock.h"
ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId){} ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {}
ComIFMock::~ComIFMock() {} ComIFMock::~ComIFMock() {}
@ -19,29 +20,27 @@ ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestL
} }
ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) {
switch(testCase) { switch (testCase) {
case TestCase::MISSED_REPLY: { case TestCase::MISSED_REPLY: {
*size = 0; *size = 0;
return RETURN_OK; return RETURN_OK;
} }
case TestCase::SIMPLE_COMMAND_NOMINAL: { case TestCase::SIMPLE_COMMAND_NOMINAL: {
*size = 1; *size = 1;
data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; data = DeviceHandlerMock::SIMPLE_COMMAND_DATA;
*buffer = &data; *buffer = &data;
break; break;
} }
case TestCase::PERIODIC_REPLY_NOMINAL: { case TestCase::PERIODIC_REPLY_NOMINAL: {
*size = 1; *size = 1;
data = DeviceHandlerMock::PERIODIC_REPLY_DATA; data = DeviceHandlerMock::PERIODIC_REPLY_DATA;
*buffer = &data; *buffer = &data;
break; break;
} }
default: default:
break; break;
} }
return RETURN_OK; return RETURN_OK;
} }
void ComIFMock::setTestCase(TestCase testCase_) { void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; }
testCase = testCase_;
}

View File

@ -1,7 +1,5 @@
#include "CookieIFMock.h" #include "CookieIFMock.h"
CookieIFMock::CookieIFMock() { CookieIFMock::CookieIFMock() {}
}
CookieIFMock::~CookieIFMock() { CookieIFMock::~CookieIFMock() {}
}

View File

@ -1,4 +1,5 @@
#include "DeviceHandlerCommander.h" #include "DeviceHandlerCommander.h"
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId)
@ -60,6 +61,4 @@ ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t
ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; }
void DeviceHandlerCommander::resetReplyReturnCode() { void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; }
lastReplyReturnCode = RETURN_FAILED;
}

View File

@ -1,16 +1,16 @@
#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ #ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_
#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ #define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandActionHelper.h"
#include "fsfw/action/CommandsActionsIF.h" #include "fsfw/action/CommandsActionsIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
class DeviceHandlerCommander : public ExecutableObjectIF, class DeviceHandlerCommander : public ExecutableObjectIF,
public SystemObject, public SystemObject,
public CommandsActionsIF, public CommandsActionsIF,
public HasReturnvaluesIF { public HasReturnvaluesIF {
public: public:
DeviceHandlerCommander(object_id_t objectId); DeviceHandlerCommander(object_id_t objectId);
virtual ~DeviceHandlerCommander(); virtual ~DeviceHandlerCommander();
@ -36,7 +36,6 @@ class DeviceHandlerCommander : public ExecutableObjectIF,
void resetReplyReturnCode(); void resetReplyReturnCode();
private: private:
static const uint32_t QUEUE_SIZE = 20; static const uint32_t QUEUE_SIZE = 20;
MessageQueueIF* commandQueue = nullptr; MessageQueueIF* commandQueue = nullptr;

View File

@ -42,13 +42,13 @@ ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t devic
ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) { DeviceCommandId_t *foundId, size_t *foundLen) {
switch (*start) { switch (*start) {
case SIMPLE_COMMAND_DATA: { case SIMPLE_COMMAND_DATA: {
*foundId = SIMPLE_COMMAND; *foundId = SIMPLE_COMMAND;
*foundLen = sizeof(SIMPLE_COMMAND_DATA); *foundLen = sizeof(SIMPLE_COMMAND_DATA);
return RETURN_OK; return RETURN_OK;
break; break;
} }
case PERIODIC_REPLY_DATA: { case PERIODIC_REPLY_DATA: {
*foundId = PERIODIC_REPLY; *foundId = PERIODIC_REPLY;
*foundLen = sizeof(PERIODIC_REPLY_DATA); *foundLen = sizeof(PERIODIC_REPLY_DATA);
return RETURN_OK; return RETURN_OK;
@ -64,7 +64,7 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons
switch (id) { switch (id) {
case SIMPLE_COMMAND: case SIMPLE_COMMAND:
case PERIODIC_REPLY: { case PERIODIC_REPLY: {
periodicReplyReceived = true; periodicReplyReceived = true;
break; break;
} }
default: default:
@ -74,9 +74,9 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons
} }
void DeviceHandlerMock::fillCommandAndReplyMap() { void DeviceHandlerMock::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0,
&simpleCommandReplyTimeout); &simpleCommandReplyTimeout);
insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0,
&periodicReplyCountdown); &periodicReplyCountdown);
} }
@ -90,10 +90,6 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
simpleCommandReplyTimeout.setTimeout(timeout); simpleCommandReplyTimeout.setTimeout(timeout);
} }
void DeviceHandlerMock::resetPeriodicReplyState() { void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
periodicReplyReceived = false;
}
bool DeviceHandlerMock::getPeriodicReplyReceived() { bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; }
return periodicReplyReceived;
}

View File

@ -3,45 +3,42 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
class DeviceHandlerMock: public DeviceHandlerBase { class DeviceHandlerMock : public DeviceHandlerBase {
public: public:
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
static const DeviceCommandId_t PERIODIC_REPLY = 2;
static const DeviceCommandId_t SIMPLE_COMMAND = 1; static const uint8_t SIMPLE_COMMAND_DATA = 1;
static const DeviceCommandId_t PERIODIC_REPLY = 2; static const uint8_t PERIODIC_REPLY_DATA = 2;
static const uint8_t SIMPLE_COMMAND_DATA = 1; DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
static const uint8_t PERIODIC_REPLY_DATA = 2; FailureIsolationBase *fdirInstance);
virtual ~DeviceHandlerMock();
void changePeriodicReplyCountdown(uint32_t timeout);
void changeSimpleCommandReplyCountdown(uint32_t timeout);
void resetPeriodicReplyState();
bool getPeriodicReplyReceived();
DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, protected:
CookieIF *comCookie, FailureIsolationBase* fdirInstance); void doStartUp() override;
virtual ~DeviceHandlerMock(); void doShutDown() override;
void changePeriodicReplyCountdown(uint32_t timeout); ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
void changeSimpleCommandReplyCountdown(uint32_t timeout); ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
void resetPeriodicReplyState(); ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
bool getPeriodicReplyReceived(); size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
void fillCommandAndReplyMap() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
protected: private:
void doStartUp() override; Countdown simpleCommandReplyTimeout = Countdown(50);
void doShutDown() override; Countdown periodicReplyCountdown = Countdown(10);
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData, size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void fillCommandAndReplyMap() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
private: uint8_t commandBuffer[1];
Countdown simpleCommandReplyTimeout = Countdown(50); bool periodicReplyReceived = false;
Countdown periodicReplyCountdown = Countdown(10);
uint8_t commandBuffer[1];
bool periodicReplyReceived = false;
}; };
#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ #endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */

View File

@ -8,21 +8,20 @@
#include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" #include "fsfw_tests/unit/testcfg/objects/systemObjectList.h"
TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
// Will be deleted with DHB destructor
// Will be deleted with DHB destructor CookieIFMock* cookieIFMock = new CookieIFMock;
CookieIFMock* cookieIFMock = new CookieIFMock; ComIFMock comIF(objects::COM_IF_MOCK);
ComIFMock comIF(objects::COM_IF_MOCK); DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT);
DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK,
DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, cookieIFMock, &deviceFdirMock);
cookieIFMock, &deviceFdirMock); ReturnValue_t result = deviceHandlerMock.initialize();
ReturnValue_t result = deviceHandlerMock.initialize(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER);
DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); result = deviceHandlerCommander.initialize();
result = deviceHandlerCommander.initialize(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
SECTION("Commanding nominal") { SECTION("Commanding nominal") {
comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL);
result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK,
DeviceHandlerMock::SIMPLE_COMMAND); DeviceHandlerMock::SIMPLE_COMMAND);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
@ -37,28 +36,28 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
} }
SECTION("Commanding missed reply") { SECTION("Commanding missed reply") {
comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY);
deviceHandlerCommander.resetReplyReturnCode(); deviceHandlerCommander.resetReplyReturnCode();
// Set the timeout to 0 to immediately timeout the reply // Set the timeout to 0 to immediately timeout the reply
deviceHandlerMock.changeSimpleCommandReplyCountdown(0); deviceHandlerMock.changeSimpleCommandReplyCountdown(0);
result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK,
DeviceHandlerMock::SIMPLE_COMMAND); DeviceHandlerMock::SIMPLE_COMMAND);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
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);
deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ);
deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ);
deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);
deviceHandlerCommander.performOperation(); deviceHandlerCommander.performOperation();
result = deviceHandlerCommander.getReplyReturnCode(); result = deviceHandlerCommander.getReplyReturnCode();
REQUIRE(result == DeviceHandlerIF::TIMEOUT); REQUIRE(result == DeviceHandlerIF::TIMEOUT);
uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); uint32_t missedReplies = deviceFdirMock.getMissedReplyCount();
REQUIRE(missedReplies == 1); REQUIRE(missedReplies == 1);
} }
SECTION("Periodic reply nominal") { SECTION("Periodic reply nominal") {
comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL);
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);
@ -68,7 +67,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
} }
SECTION("Missed periodic reply") { SECTION("Missed periodic reply") {
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.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION);