2021-02-14 11:03:53 +01:00
|
|
|
#include "LibgpiodTest.h"
|
|
|
|
|
2021-02-14 12:23:29 +01:00
|
|
|
#include <fsfwconfig/devices/gpioIds.h>
|
2021-02-14 09:25:40 +01:00
|
|
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
|
|
|
|
2021-02-14 12:23:29 +01:00
|
|
|
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) {
|
2021-02-14 11:03:53 +01:00
|
|
|
sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl;
|
2021-02-14 09:25:40 +01:00
|
|
|
}
|
|
|
|
gpioInterface->initialize(gpioCookie);
|
|
|
|
}
|
|
|
|
|
2021-02-14 11:03:53 +01:00
|
|
|
LibgpiodTest::~LibgpiodTest() {
|
2021-02-14 09:25:40 +01:00
|
|
|
}
|
|
|
|
|
2021-02-14 11:03:53 +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) {
|
2021-02-14 11:03:53 +01:00
|
|
|
sif::debug << "LibgpiodTest::performPeriodicAction: Failed to read gpio "
|
2021-02-14 09:25:40 +01:00
|
|
|
<< std::endl;
|
|
|
|
return RETURN_FAILED;
|
|
|
|
}
|
|
|
|
else {
|
2021-02-14 11:03:53 +01:00
|
|
|
sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState
|
2021-02-14 09:25:40 +01:00
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|