added gpio read function

This commit is contained in:
2021-02-14 09:25:40 +01:00
parent 76e59e3593
commit bdc4b1cec5
18 changed files with 161 additions and 56 deletions

View File

@ -0,0 +1,8 @@
target_sources(${TARGET_NAME} PUBLIC
LibgpioTest.cpp
TestTask.cpp
)
target_include_directories(${TARGET_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -0,0 +1,35 @@
#include "LibgpioTest.h"
#include "devices/gpioIds.h"
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
LibgpioTest::LibgpioTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie) :
TestTask(objectId) {
gpioInterface = objectManager->get<GpioIF>(gpioIfobjectId);
if (gpioInterface == nullptr) {
sif::error << "LibgpioTest::LibgpioTest: Invalid Gpio interface." << std::endl;
}
gpioInterface->initialize(gpioCookie);
}
LibgpioTest::~LibgpioTest() {
}
ReturnValue_t LibgpioTest::performPeriodicAction() {
int gpioState;
ReturnValue_t result;
result = gpioInterface->readGpio(gpioIds::Test_ID, &gpioState);
if (result != RETURN_OK) {
sif::debug << "LibgpioTest::performPeriodicAction: Failed to read gpio "
<< std::endl;
return RETURN_FAILED;
}
else {
sif::debug << "LibgpioTest::performPeriodicAction: MIO 0 state = " << gpioState
<< std::endl;
}
return RETURN_OK;
}

View File

@ -0,0 +1,25 @@
#ifndef TEST_TESTTASKS_LIBGPIOTEST_H_
#define TEST_TESTTASKS_LIBGPIOTEST_H_
#include "TestTask.h"
#include "GpioIF.h"
#include "GpioCookie.h"
#include <fsfw/objectmanager/SystemObject.h>
/**
* @brief Test for the GPIO read implementation of the LinuxLibgpioIF.
* @author J. Meier
*/
class LibgpioTest: public TestTask {
public:
LibgpioTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie);
virtual ~LibgpioTest();
protected:
virtual ReturnValue_t performPeriodicAction() override;
private:
GpioIF* gpioInterface;
};
#endif /* TEST_TESTTASKS_LIBGPIOTEST_H_ */