fsfw/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h

38 lines
1.5 KiB
C
Raw Normal View History

2022-05-16 11:10:35 +02:00
#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_
#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
2022-06-05 12:52:55 +02:00
#include <fsfw/objectmanager/SystemObject.h>
2022-05-16 11:10:35 +02:00
/**
* @brief The ComIFMock supports the simulation of various device communication error cases
* like incomplete or wrong replies and can be used to test the
* DeviceHandlerBase.
2022-05-16 11:10:35 +02:00
*/
class ComIFMock : public DeviceCommunicationIF, public SystemObject {
public:
2022-06-05 12:52:55 +02:00
enum class TestCase { SIMPLE_COMMAND_NOMINAL, PERIODIC_REPLY_NOMINAL, MISSED_REPLY };
ComIFMock(object_id_t objectId);
2022-05-16 11:10:35 +02:00
virtual ~ComIFMock();
virtual ReturnValue_t initializeInterface(CookieIF *cookie) override;
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData,
size_t sendLen) override;
virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override;
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override;
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
size_t *size) override;
2022-06-05 12:52:55 +02:00
void setTestCase(TestCase testCase_);
2022-05-16 11:10:35 +02:00
private:
2022-06-05 12:52:55 +02:00
TestCase testCase = TestCase::SIMPLE_COMMAND_NOMINAL;
static const uint8_t SIMPLE_COMMAND_DATA = 1;
static const uint8_t PERIODIC_REPLY_DATA = 2;
uint8_t data = 0;
2022-05-16 11:10:35 +02:00
};
#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ */