eive-obsw/test/testtasks/LibgpiodTest.cpp

37 lines
1.1 KiB
C++
Raw Normal View History

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