added gpio read function
This commit is contained in:
8
test/testtasks/CMakeLists.txt
Normal file
8
test/testtasks/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
target_sources(${TARGET_NAME} PUBLIC
|
||||
LibgpioTest.cpp
|
||||
TestTask.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
35
test/testtasks/LibgpioTest.cpp
Normal file
35
test/testtasks/LibgpioTest.cpp
Normal 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;
|
||||
}
|
||||
|
25
test/testtasks/LibgpioTest.h
Normal file
25
test/testtasks/LibgpioTest.h
Normal 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_ */
|
Reference in New Issue
Block a user