added gpio read function

This commit is contained in:
Jakob Meier 2021-02-14 09:25:40 +01:00
parent 3f41adf340
commit e00667ba0b
18 changed files with 161 additions and 56 deletions

View File

@ -43,6 +43,7 @@ set(LIB_CSP_NAME libcsp)
set(FSFW_PATH fsfw) set(FSFW_PATH fsfw)
set(MISSION_PATH mission) set(MISSION_PATH mission)
set(CSPLIB_PATH libcsp) set(CSPLIB_PATH libcsp)
set(TEST_PATH test/testtasks)
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)
@ -84,6 +85,7 @@ endif()
add_subdirectory(${BSP_PATH}) add_subdirectory(${BSP_PATH})
add_subdirectory(${FSFW_PATH}) add_subdirectory(${FSFW_PATH})
add_subdirectory(${MISSION_PATH}) add_subdirectory(${MISSION_PATH})
add_subdirectory(${TEST_PATH})
################################################################################ ################################################################################
# Post-Sources preparation # Post-Sources preparation

View File

@ -157,6 +157,16 @@ void InitMission::initTasks(){
// << "failed!" << std::endl; // << "failed!" << std::endl;
// } // }
#endif
#if TE0720 == 1 && TEST_LIBGPIOD == 1
PeriodicTaskIF* TestTask = TaskFactory::instance()->
createPeriodicTask("Libgpiod Test Task", 60,
PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, nullptr);
result = TestTask->addComponent(objects::LIBGPIOD_TEST);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Object add component libgpiod test task object" << std::endl;
}
#endif #endif
//Main thread sleep //Main thread sleep
@ -174,8 +184,8 @@ void InitMission::initTasks(){
PusMedPrio->startTask(); PusMedPrio->startTask();
PusLowPrio->startTask(); PusLowPrio->startTask();
#if OBSW_ADD_TEST_CODE == 1 #if TE0720 == 1 && TEST_LIBGPIOD == 1
// TestTimeslotTask->startTask(); TestTask->startTask();
#endif #endif
sif::info << "Tasks started.." << std::endl; sif::info << "Tasks started.." << std::endl;
} }

View File

@ -33,6 +33,10 @@
#include <bsp_q7s/gpio/LinuxLibgpioIF.h> #include <bsp_q7s/gpio/LinuxLibgpioIF.h>
#include <bsp_q7s/gpio/cookies/GpioCookie.h> #include <bsp_q7s/gpio/cookies/GpioCookie.h>
# if TEST_LIBGPIOD == 1
#include "LibgpioTest.h"
#endif
void Factory::setStaticFrameworkObjectIds() { void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL; PusServiceBase::packetDestination = objects::TM_FUNNEL;
@ -56,15 +60,6 @@ void ObjectFactory::produce(){
Factory::setStaticFrameworkObjectIds(); Factory::setStaticFrameworkObjectIds();
ObjectFactory::produceGenericObjects(); ObjectFactory::produceGenericObjects();
/* Cookies */
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH,
addresses::P60DOCK);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
addresses::PDU1);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
addresses::PDU2);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH,
addresses::ACU);
#if TE0720 == 1 #if TE0720 == 1
I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1,
TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0"));
@ -80,12 +75,31 @@ void ObjectFactory::produce(){
new CspComIF(objects::CSP_COM_IF); new CspComIF(objects::CSP_COM_IF);
new I2cComIF(objects::I2C_COM_IF); new I2cComIF(objects::I2C_COM_IF);
#if TE0720 == 0
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH,
addresses::P60DOCK);
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
addresses::PDU1);
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
addresses::PDU2);
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH,
addresses::ACU);
/* Device Handler */ /* Device Handler */
new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); P60DockHandler* p60dockhandler = new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie);
new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie);
new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie);
new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie);
new PCDUHandler(objects::PCDU_HANDLER, 50); new PCDUHandler(objects::PCDU_HANDLER, 50);
/**
* Setting PCDU devices to mode normal immediately after start up because PCDU is always
* running.
*/
p60dockhandler->setModeNormal();
pdu1handler->setModeNormal();
pdu2handler->setModeNormal();
acuhandler->setModeNormal();
#endif
/* Temperature sensors */ /* Temperature sensors */
Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler( Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(
objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, objects::TMP1075_HANDLER_1, objects::I2C_COM_IF,
@ -99,10 +113,19 @@ void ObjectFactory::produce(){
/* Thermal objects */ /* Thermal objects */
GpioCookie* gpioCookie = new GpioCookie; GpioCookie* gpioCookie = new GpioCookie;
#if TE0720 == 1 #if TE0720 == 1
#if TEST_LIBGPIOD == 1
/* Configure MIO0 as input */
GpioConfig_t gpioConfigMio0(std::string("gpiochip0"), 0,
std::string("MIO0"), Gpio::IN, 0);
gpioCookie->addGpio(gpioIds::Test_ID, gpioConfigMio0);
#else
// Configuration for MIO0 on TE0720-03-1CFA // Configuration for MIO0 on TE0720-03-1CFA
GpioConfig_t gpioConfigForDummyHeater(std::string("gpiochip0"), 0, GpioConfig_t gpioConfigForDummyHeater(std::string("gpiochip0"), 0,
std::string("Heater0"), Gpio::OUT, 0); std::string("Heater0"), Gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigForDummyHeater); gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigForDummyHeater);
#endif
#else #else
/* Pin H2-11 on stack connector */ /* Pin H2-11 on stack connector */
GpioConfig_t gpioConfigHeater0(std::string("gpiochip7"), 18, GpioConfig_t gpioConfigHeater0(std::string("gpiochip7"), 18,
@ -148,4 +171,8 @@ void ObjectFactory::produce(){
objects::CCSDS_PACKET_DISTRIBUTOR, objects::CCSDS_PACKET_DISTRIBUTOR,
objects::TM_STORE, objects::TC_STORE); objects::TM_STORE, objects::TC_STORE);
new TcUnixUdpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE); new TcUnixUdpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
#if TE0720 == 1 && TEST_LIBGPIOD == 1
new LibgpioTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie);
#endif
} }

View File

@ -187,7 +187,6 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
reply = csp_read(conn, timeout_ms); reply = csp_read(conn, timeout_ms);
if (reply == NULL) { if (reply == NULL) {
sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl;
csp_buffer_free(reply);
csp_close(conn); csp_close(conn);
return RETURN_FAILED; return RETURN_FAILED;
} }

View File

@ -3,4 +3,9 @@ target_sources(${TARGET_NAME} PUBLIC
LinuxLibgpioIF.cpp LinuxLibgpioIF.cpp
) )
target_include_directories(${TARGET_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cookies
)

View File

@ -33,7 +33,7 @@ ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
return result; return result;
} }
result = configureGpios(mapToAdd); result = configureGpios(&mapToAdd);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -44,7 +44,7 @@ ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap mapToAdd) { ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
GpioMapIter mapToAddIter; GpioMapIter mapToAddIter;
std::string chipname; std::string chipname;
unsigned int lineNum; unsigned int lineNum;
@ -54,17 +54,18 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap mapToAdd) {
struct gpiod_line *lineHandle; struct gpiod_line *lineHandle;
int result; int result;
for (mapToAddIter = mapToAdd.begin(); mapToAddIter != mapToAdd.end(); mapToAddIter++) { mapToAddIter = mapToAdd->begin();
for (; mapToAddIter != mapToAdd->end(); mapToAddIter++) {
chipname = gpioMapIter->second.chipname; chipname = mapToAddIter->second.chipname;
chip = gpiod_chip_open_by_name(chipname.c_str()); chip = gpiod_chip_open_by_name(chipname.c_str());
if (!chip) { if (!chip) {
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip " sif::error << "LinuxLibgpioIF::configureGpios: Failed to open chip "
<< chipname << ". Gpio ID: " << gpioMapIter->first << std::endl; << chipname << ". Gpio ID: " << mapToAddIter->first << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
lineNum = gpioMapIter->second.lineNum; lineNum = mapToAddIter->second.lineNum;
lineHandle = gpiod_chip_get_line(chip, lineNum); lineHandle = gpiod_chip_get_line(chip, lineNum);
if (!lineHandle) { if (!lineHandle) {
sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line" << std::endl; sif::error << "LinuxLibgpioIF::configureGpios: Failed to open line" << std::endl;
@ -72,16 +73,16 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap mapToAdd) {
return RETURN_FAILED; return RETURN_FAILED;
} }
direction = gpioMapIter->second.direction; direction = mapToAddIter->second.direction;
consumer = gpioMapIter->second.consumer; consumer = mapToAddIter->second.consumer;
/* Configure direction and add a description to the GPIO */ /* Configure direction and add a description to the GPIO */
switch (direction) { switch (direction) {
case Gpio::OUT: case Gpio::OUT:
result = gpiod_line_request_output(lineHandle, consumer.c_str(), result = gpiod_line_request_output(lineHandle, consumer.c_str(),
gpioMapIter->second.initValue); mapToAddIter->second.initValue);
if (result < 0) { if (result < 0) {
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "
<< lineNum << " from GPIO instance with ID: " << gpioMapIter->first << lineNum << " from GPIO instance with ID: " << mapToAddIter->first
<< std::endl; << std::endl;
gpiod_line_release(lineHandle); gpiod_line_release(lineHandle);
return RETURN_FAILED; return RETURN_FAILED;
@ -91,7 +92,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap mapToAdd) {
result = gpiod_line_request_input(lineHandle, consumer.c_str()); result = gpiod_line_request_input(lineHandle, consumer.c_str());
if (result < 0) { if (result < 0) {
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "
<< lineNum << " from GPIO instance with ID: " << gpioMapIter->first << lineNum << " from GPIO instance with ID: " << mapToAddIter->first
<< std::endl; << std::endl;
gpiod_line_release(lineHandle); gpiod_line_release(lineHandle);
return RETURN_FAILED; return RETURN_FAILED;
@ -106,7 +107,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap mapToAdd) {
* Write line handle to GPIO configuration instance so it can later be used to set or * Write line handle to GPIO configuration instance so it can later be used to set or
* read states of GPIOs. * read states of GPIOs.
*/ */
gpioMapIter->second.lineHandle = lineHandle; mapToAddIter->second.lineHandle = lineHandle;
} }
return RETURN_OK; return RETURN_OK;
} }
@ -124,7 +125,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
int result; int result;
struct gpiod_line *lineHandle; struct gpiod_line *lineHandle;
GpioMapIter gpioMapIter = gpioMap.find(gpioId); gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()){ if (gpioMapIter == gpioMap.end()){
sif::debug << "LinuxLibgpioIF::driveGpio: Unknown gpio id " << gpioId << std::endl; sif::debug << "LinuxLibgpioIF::driveGpio: Unknown gpio id " << gpioId << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
@ -134,7 +135,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
result = gpiod_line_set_value(lineHandle, logiclevel); result = gpiod_line_set_value(lineHandle, logiclevel);
if (result < 0) { if (result < 0) {
sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID "
<< gpioId << "to logic level" << logiclevel << std::endl; << gpioId << " to logic level " << logiclevel << std::endl;
return DRIVE_GPIO_FAILURE; return DRIVE_GPIO_FAILURE;
} }
@ -144,7 +145,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
struct gpiod_line *lineHandle; struct gpiod_line *lineHandle;
GpioMapIter gpioMapIter = gpioMap.find(gpioId); gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()){ if (gpioMapIter == gpioMap.end()){
sif::debug << "LinuxLibgpioIF::readGpio: Unknown gpio id " << gpioId << std::endl; sif::debug << "LinuxLibgpioIF::readGpio: Unknown gpio id " << gpioId << std::endl;
return RETURN_FAILED; return RETURN_FAILED;

View File

@ -57,7 +57,7 @@ private:
/** /**
* @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd.
*/ */
ReturnValue_t configureGpios(GpioMap mapToAdd); ReturnValue_t configureGpios(GpioMap* mapToAdd);
}; };
#endif /* BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ */ #endif /* BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ */

View File

@ -39,7 +39,7 @@ typedef struct GpioConfig {
std::string consumer; std::string consumer;
Gpio::Direction direction; Gpio::Direction direction;
int initValue; int initValue;
struct gpiod_line *lineHandle; struct gpiod_line* lineHandle;
} GpioConfig_t; } GpioConfig_t;
using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>; using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>;
using GpioMapIter = GpioMap::iterator; using GpioMapIter = GpioMap::iterator;

View File

@ -6,7 +6,8 @@
#ifndef FSFWCONFIG_OBSWCONFIG_H_ #ifndef FSFWCONFIG_OBSWCONFIG_H_
#define FSFWCONFIG_OBSWCONFIG_H_ #define FSFWCONFIG_OBSWCONFIG_H_
#define OBSW_ADD_TEST_CODE 0 #define TEST_LIBGPIOD 0
#define ADD_TEST_TAST 1
// These defines should be disabled for mission code but are useful for // These defines should be disabled for mission code but are useful for
// debugging. // debugging.

View File

@ -13,6 +13,7 @@ namespace gpioIds {
HEATER_5, HEATER_5,
HEATER_6, HEATER_6,
HEATER_7, HEATER_7,
Test_ID
}; };
} }

View File

@ -50,6 +50,7 @@ namespace objects {
/* 0x54 ('T') for test handlers */ /* 0x54 ('T') for test handlers */
TEST_TASK = 0x54694269, TEST_TASK = 0x54694269,
LIBGPIOD_TEST = 0x54123456,
SPI_TEST = 0x54000010, SPI_TEST = 0x54000010,
DUMMY_INTERFACE = 0x5400CAFE, DUMMY_INTERFACE = 0x5400CAFE,
DUMMY_HANDLER = 0x5400AFFE, DUMMY_HANDLER = 0x5400AFFE,

View File

@ -6,7 +6,6 @@ GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t c
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) : uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) :
DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress),
maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), hkTableDataset(hkTableDataset) { maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), hkTableDataset(hkTableDataset) {
mode = MODE_NORMAL;
if (comCookie == NULL) { if (comCookie == NULL) {
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie"
<< std::endl; << std::endl;
@ -392,3 +391,7 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) {
return nullptr; return nullptr;
} }
} }
void GomspaceDeviceHandler::setModeNormal() {
mode = MODE_NORMAL;
}

View File

@ -36,6 +36,12 @@ public:
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset);
virtual ~GomspaceDeviceHandler(); virtual ~GomspaceDeviceHandler();
/**
* @brief This function can be used to set a gomspace device to normal mode immediately after
* object creation.
*/
void setModeNormal();
protected: protected:
static const uint8_t MAX_PACKET_LEN = 36; static const uint8_t MAX_PACKET_LEN = 36;

View File

@ -214,21 +214,13 @@ void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullHigh(gpioId); result = gpioInterface->pullHigh(gpioId);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id" sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id "
<< gpioId << "high" << std::endl; << gpioId << " high" << std::endl;
triggerEvent(GPIO_PULL_HIGH_FAILED, result); triggerEvent(GPIO_PULL_HIGH_FAILED, result);
} }
else { else {
switchStates[switchNr] = ON; switchStates[switchNr] = ON;
} }
int gpioState;
result = gpioInterface->readGpio(gpioId, &gpioState);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to read gpio"
<< std::endl;
}
sif::debug << "HeaterHandler::handleSwitchOnCommand: GPIO state: " << gpioState
<< std::endl;
} }
else { else {
triggerEvent(SWITCH_ALREADY_ON, switchNr); triggerEvent(SWITCH_ALREADY_ON, switchNr);
@ -283,14 +275,6 @@ void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
} }
} }
int gpioState;
result = gpioInterface->readGpio(gpioId, &gpioState);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to read gpio"
<< std::endl;
}
sif::debug << "HeaterHandler::handleSwitchOnCommand: GPIO state: " << gpioState
<< std::endl;
} }
else { else {
sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl;

View File

@ -1,3 +0,0 @@
CXXSRC += $(wildcard $(CURRENTPATH)/testdevices/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/testinterfaces/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/testtasks/*.cpp)

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_ */