Merge pull request 'Update Linux GPIO' (#20) from mueller/update-linux-gpio into eive/develop
Reviewed-on: #20
This commit is contained in:
commit
ac2b196883
@ -9,12 +9,13 @@ using gpioId_t = uint16_t;
|
|||||||
|
|
||||||
namespace gpio {
|
namespace gpio {
|
||||||
|
|
||||||
enum Levels {
|
enum Levels: uint8_t {
|
||||||
LOW = 0,
|
LOW = 0,
|
||||||
HIGH = 1
|
HIGH = 1,
|
||||||
|
NONE = 99
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Direction {
|
enum Direction: uint8_t {
|
||||||
IN = 0,
|
IN = 0,
|
||||||
OUT = 1
|
OUT = 1
|
||||||
};
|
};
|
||||||
@ -24,7 +25,7 @@ enum GpioOperation {
|
|||||||
WRITE
|
WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GpioTypes {
|
enum class GpioTypes {
|
||||||
NONE,
|
NONE,
|
||||||
GPIO_REGULAR_BY_CHIP,
|
GPIO_REGULAR_BY_CHIP,
|
||||||
GPIO_REGULAR_BY_LABEL,
|
GPIO_REGULAR_BY_LABEL,
|
||||||
@ -34,7 +35,8 @@ enum GpioTypes {
|
|||||||
|
|
||||||
static constexpr gpioId_t NO_GPIO = -1;
|
static constexpr gpioId_t NO_GPIO = -1;
|
||||||
|
|
||||||
using gpio_cb_t = void (*) (gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args);
|
using gpio_cb_t = void (*) (gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value,
|
||||||
|
void* args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ public:
|
|||||||
GpioBase() = default;
|
GpioBase() = default;
|
||||||
|
|
||||||
GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
GpioBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
||||||
int initValue):
|
gpio::Levels initValue):
|
||||||
gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {}
|
gpioType(gpioType), consumer(consumer),direction(direction), initValue(initValue) {}
|
||||||
|
|
||||||
virtual~ GpioBase() {};
|
virtual~ GpioBase() {};
|
||||||
@ -67,19 +69,19 @@ public:
|
|||||||
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
||||||
std::string consumer;
|
std::string consumer;
|
||||||
gpio::Direction direction = gpio::Direction::IN;
|
gpio::Direction direction = gpio::Direction::IN;
|
||||||
int initValue = 0;
|
gpio::Levels initValue = gpio::Levels::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GpiodRegularBase: public GpioBase {
|
class GpiodRegularBase: public GpioBase {
|
||||||
public:
|
public:
|
||||||
GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
||||||
int initValue, int lineNum): GpioBase(gpioType, consumer, direction, initValue),
|
gpio::Levels initValue, int lineNum):
|
||||||
lineNum(lineNum) {
|
GpioBase(gpioType, consumer, direction, initValue), lineNum(lineNum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// line number will be configured at a later point for the open by line name configuration
|
// line number will be configured at a later point for the open by line name configuration
|
||||||
GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
|
||||||
int initValue): GpioBase(gpioType, consumer, direction, initValue) {
|
gpio::Levels initValue): GpioBase(gpioType, consumer, direction, initValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int lineNum = 0;
|
int lineNum = 0;
|
||||||
@ -94,7 +96,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
||||||
gpio::Direction direction_, int initValue_) :
|
gpio::Direction direction_, gpio::Levels initValue_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
|
||||||
consumer_, direction_, initValue_, lineNum_),
|
consumer_, direction_, initValue_, lineNum_),
|
||||||
chipname(chipname_){
|
chipname(chipname_){
|
||||||
@ -112,7 +114,7 @@ public:
|
|||||||
class GpiodRegularByLabel: public GpiodRegularBase {
|
class GpiodRegularByLabel: public GpiodRegularBase {
|
||||||
public:
|
public:
|
||||||
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_,
|
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_,
|
||||||
gpio::Direction direction_, int initValue_) :
|
gpio::Direction direction_, gpio::Levels initValue_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
|
||||||
direction_, initValue_, lineNum_),
|
direction_, initValue_, lineNum_),
|
||||||
label(label_) {
|
label(label_) {
|
||||||
@ -135,14 +137,14 @@ public:
|
|||||||
class GpiodRegularByLineName: public GpiodRegularBase {
|
class GpiodRegularByLineName: public GpiodRegularBase {
|
||||||
public:
|
public:
|
||||||
GpiodRegularByLineName(std::string lineName_, std::string consumer_, gpio::Direction direction_,
|
GpiodRegularByLineName(std::string lineName_, std::string consumer_, gpio::Direction direction_,
|
||||||
int initValue_) :
|
gpio::Levels initValue_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, direction_,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, direction_,
|
||||||
initValue_), lineName(lineName_) {
|
initValue_), lineName(lineName_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GpiodRegularByLineName(std::string lineName_, std::string consumer_) :
|
GpiodRegularByLineName(std::string lineName_, std::string consumer_) :
|
||||||
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, gpio::Direction::IN,
|
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_,
|
||||||
gpio::LOW), lineName(lineName_) {
|
gpio::Direction::IN, gpio::LOW), lineName(lineName_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string lineName;
|
std::string lineName;
|
||||||
@ -150,7 +152,7 @@ public:
|
|||||||
|
|
||||||
class GpioCallback: public GpioBase {
|
class GpioCallback: public GpioBase {
|
||||||
public:
|
public:
|
||||||
GpioCallback(std::string consumer, gpio::Direction direction_, int initValue_,
|
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
|
||||||
gpio::gpio_cb_t callback, void* callbackArgs):
|
gpio::gpio_cb_t callback, void* callbackArgs):
|
||||||
GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
||||||
callback(callback), callbackArgs(callbackArgs) {}
|
callback(callback), callbackArgs(callbackArgs) {}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
#include "GyroL3GD20Handler.h"
|
||||||
|
|
||||||
#include "fsfw/datapool/PoolReadGuard.h"
|
#include "fsfw/datapool/PoolReadGuard.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
|
GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
|
||||||
CookieIF *comCookie, uint32_t transitionDelayMs):
|
CookieIF *comCookie, uint32_t transitionDelayMs):
|
||||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||||
|
@ -59,7 +59,6 @@ protected:
|
|||||||
LocalDataPoolManager &poolManager) override;
|
LocalDataPoolManager &poolManager) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t switchId = 0;
|
|
||||||
uint32_t transitionDelayMs = 0;
|
uint32_t transitionDelayMs = 0;
|
||||||
GyroPrimaryDataset dataset;
|
GyroPrimaryDataset dataset;
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication,
|
MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication,
|
||||||
CookieIF* comCookie, uint32_t transitionDelay):
|
CookieIF* comCookie, uint32_t transitionDelay):
|
||||||
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
|
||||||
|
@ -89,9 +89,16 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
// Might be a configuration error
|
// Might be a configuration error
|
||||||
sif::warning << "MgmRM3100Handler::buildTransitionDeviceCommand: Unknown internal state!" <<
|
sif::warning << "MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||||
std::endl;
|
"Unknown internal state" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||||
|
"Unknown internal state\n");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,12 +349,18 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
|
|||||||
|
|
||||||
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
#if FSFW_HAL_RM3100_MGM_DEBUG == 1
|
||||||
if(debugDivider->checkAndIncrement()) {
|
if(debugDivider->checkAndIncrement()) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "MgmRM3100Handler: Magnetic field strength in"
|
sif::info << "MgmRM3100Handler: Magnetic field strength in"
|
||||||
" microtesla:" << std::endl;
|
" microtesla:" << std::endl;
|
||||||
/* Set terminal to utf-8 if there is an issue with micro printout. */
|
|
||||||
sif::info << "X: " << fieldStrengthX << " uT" << std::endl;
|
sif::info << "X: " << fieldStrengthX << " uT" << std::endl;
|
||||||
sif::info << "Y: " << fieldStrengthY << " uT" << std::endl;
|
sif::info << "Y: " << fieldStrengthY << " uT" << std::endl;
|
||||||
sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl;
|
sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n");
|
||||||
|
sif::printInfo("X: %f uT\n", fieldStrengthX);
|
||||||
|
sif::printInfo("Y: %f uT\n", fieldStrengthY);
|
||||||
|
sif::printInfo("Z: %f uT\n", fieldStrengthZ);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ enum MgmPoolIds: lp_id_t {
|
|||||||
TEMPERATURE_CELCIUS
|
TEMPERATURE_CELCIUS
|
||||||
};
|
};
|
||||||
|
|
||||||
class MgmPrimaryDataset: public StaticLocalDataSet<5> {
|
class MgmPrimaryDataset: public StaticLocalDataSet<4> {
|
||||||
public:
|
public:
|
||||||
MgmPrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
MgmPrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
||||||
StaticLocalDataSet(hkOwner, MGM_DATA_SET_ID) {}
|
StaticLocalDataSet(hkOwner, MGM_DATA_SET_ID) {}
|
||||||
|
@ -108,7 +108,7 @@ enum MgmPoolIds: lp_id_t {
|
|||||||
FIELD_STRENGTH_Z,
|
FIELD_STRENGTH_Z,
|
||||||
};
|
};
|
||||||
|
|
||||||
class Rm3100PrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
|
class Rm3100PrimaryDataset: public StaticLocalDataSet<3> {
|
||||||
public:
|
public:
|
||||||
Rm3100PrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
Rm3100PrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
||||||
StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {}
|
StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
#include "LinuxLibgpioIF.h"
|
||||||
|
|
||||||
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
||||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||||
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -165,22 +166,10 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
|||||||
case(gpio::OUT): {
|
case(gpio::OUT): {
|
||||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
||||||
regularGpio.initValue);
|
regularGpio.initValue);
|
||||||
if (result < 0) {
|
|
||||||
sif::error << "LinuxLibgpioIF::configureRegularGpio: Failed to request line " << lineNum <<
|
|
||||||
" from GPIO instance with ID: " << gpioId << std::endl;
|
|
||||||
gpiod_line_release(lineHandle);
|
|
||||||
return RETURN_FAILED;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(gpio::IN): {
|
case(gpio::IN): {
|
||||||
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
||||||
if (result < 0) {
|
|
||||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "
|
|
||||||
<< lineNum << " from GPIO instance with ID: " << gpioId << std::endl;
|
|
||||||
gpiod_line_release(lineHandle);
|
|
||||||
return RETURN_FAILED;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -189,6 +178,18 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
|||||||
return GPIO_INVALID_INSTANCE;
|
return GPIO_INVALID_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result < 0) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "LinuxLibgpioIF::configureRegularGpio: Failed to request line " <<
|
||||||
|
lineNum << " from GPIO instance with ID: " << gpioId << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("LinuxLibgpioIF::configureRegularGpio: "
|
||||||
|
"Failed to request line %d from GPIO instance with ID: %d\n", lineNum, gpioId);
|
||||||
|
#endif
|
||||||
|
gpiod_line_release(lineHandle);
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -221,7 +222,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
|
|||||||
return GPIO_INVALID_INSTANCE;
|
return GPIO_INVALID_INSTANCE;
|
||||||
}
|
}
|
||||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
||||||
1, gpioCallback->callbackArgs);
|
gpio::Levels::HIGH, gpioCallback->callbackArgs);
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
@ -230,7 +231,11 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
|
|||||||
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
|
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
|
||||||
gpioMapIter = gpioMap.find(gpioId);
|
gpioMapIter = gpioMap.find(gpioId);
|
||||||
if (gpioMapIter == gpioMap.end()) {
|
if (gpioMapIter == gpioMap.end()) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LinuxLibgpioIF::pullLow: Unknown GPIO ID " << gpioId << std::endl;
|
sif::warning << "LinuxLibgpioIF::pullLow: Unknown GPIO ID " << gpioId << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("LinuxLibgpioIF::pullLow: Unknown GPIO ID %d\n", gpioId);
|
||||||
|
#endif
|
||||||
return UNKNOWN_GPIO_ID;
|
return UNKNOWN_GPIO_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +255,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
|
|||||||
return GPIO_INVALID_INSTANCE;
|
return GPIO_INVALID_INSTANCE;
|
||||||
}
|
}
|
||||||
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
|
||||||
0, gpioCallback->callbackArgs);
|
gpio::Levels::LOW, gpioCallback->callbackArgs);
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
@ -260,8 +265,13 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
|
|||||||
GpiodRegularBase& regularGpio, gpio::Levels logicLevel) {
|
GpiodRegularBase& regularGpio, gpio::Levels logicLevel) {
|
||||||
int result = gpiod_line_set_value(regularGpio.lineHandle, logicLevel);
|
int result = gpiod_line_set_value(regularGpio.lineHandle, logicLevel);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId <<
|
sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId <<
|
||||||
" to logic level " << logicLevel << std::endl;
|
" to logic level " << logicLevel << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID %d to "
|
||||||
|
"logic level %d\n", gpioId, logicLevel);
|
||||||
|
#endif
|
||||||
return DRIVE_GPIO_FAILURE;
|
return DRIVE_GPIO_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +281,11 @@ 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) {
|
||||||
gpioMapIter = gpioMap.find(gpioId);
|
gpioMapIter = gpioMap.find(gpioId);
|
||||||
if (gpioMapIter == gpioMap.end()){
|
if (gpioMapIter == gpioMap.end()){
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl;
|
sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("LinuxLibgpioIF::readGpio: Unknown GPIOD ID %d\n", gpioId);
|
||||||
|
#endif
|
||||||
return UNKNOWN_GPIO_ID;
|
return UNKNOWN_GPIO_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,10 +300,14 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
|
|||||||
*gpioState = gpiod_line_get_value(regularGpio->lineHandle);
|
*gpioState = gpiod_line_get_value(regularGpio->lineHandle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
|
||||||
|
if(gpioCallback->callback == nullptr) {
|
||||||
|
return GPIO_INVALID_INSTANCE;
|
||||||
|
}
|
||||||
|
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::READ,
|
||||||
|
gpio::Levels::NONE, gpioCallback->callbackArgs);
|
||||||
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,13 +317,14 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
|
|||||||
for(auto& gpioConfig: mapToAdd) {
|
for(auto& gpioConfig: mapToAdd) {
|
||||||
switch(gpioConfig.second->gpioType) {
|
switch(gpioConfig.second->gpioType) {
|
||||||
case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
||||||
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL): {
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
||||||
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
||||||
auto regularGpio = dynamic_cast<GpiodRegularBase*>(gpioConfig.second);
|
auto regularGpio = dynamic_cast<GpiodRegularBase*>(gpioConfig.second);
|
||||||
if(regularGpio == nullptr) {
|
if(regularGpio == nullptr) {
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
}
|
}
|
||||||
/* Check for conflicts and remove duplicates if necessary */
|
// Check for conflicts and remove duplicates if necessary
|
||||||
result = checkForConflictsRegularGpio(gpioConfig.first, *regularGpio, mapToAdd);
|
result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
status = result;
|
status = result;
|
||||||
}
|
}
|
||||||
@ -316,15 +335,22 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
|
|||||||
if(callbackGpio == nullptr) {
|
if(callbackGpio == nullptr) {
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
}
|
}
|
||||||
/* Check for conflicts and remove duplicates if necessary */
|
// Check for conflicts and remove duplicates if necessary
|
||||||
result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd);
|
result = checkForConflictsById(gpioConfig.first,
|
||||||
|
gpioConfig.second->gpioType, mapToAdd);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
status = result;
|
status = result;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Invalid GPIO type detected for GPIO ID " << gpioConfig.first
|
||||||
|
<< std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("Invalid GPIO type detected for GPIO ID %d\n", gpioConfig.first);
|
||||||
|
#endif
|
||||||
|
status = GPIO_TYPE_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,68 +358,86 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck,
|
ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
|
||||||
GpiodRegularBase& gpioToCheck, GpioMap& mapToAdd) {
|
gpio::GpioTypes expectedType, GpioMap& mapToAdd) {
|
||||||
/* Cross check with private map */
|
// Cross check with private map
|
||||||
gpioMapIter = gpioMap.find(gpioIdToCheck);
|
gpioMapIter = gpioMap.find(gpioIdToCheck);
|
||||||
if(gpioMapIter != gpioMap.end()) {
|
if(gpioMapIter != gpioMap.end()) {
|
||||||
auto& gpioType = gpioMapIter->second->gpioType;
|
auto& gpioType = gpioMapIter->second->gpioType;
|
||||||
if(gpioType != gpio::GpioTypes::GPIO_REGULAR_BY_CHIP and
|
bool eraseDuplicateDifferentType = false;
|
||||||
gpioType != gpio::GpioTypes::GPIO_REGULAR_BY_LABEL) {
|
switch(expectedType) {
|
||||||
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
|
case(gpio::GpioTypes::NONE): {
|
||||||
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
|
break;
|
||||||
mapToAdd.erase(gpioIdToCheck);
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
auto ownRegularGpio = dynamic_cast<GpiodRegularBase*>(gpioMapIter->second);
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
||||||
if(ownRegularGpio == nullptr) {
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
||||||
return GPIO_TYPE_FAILURE;
|
case(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
||||||
|
if(gpioType == gpio::GpioTypes::NONE or gpioType == gpio::GpioTypes::CALLBACK) {
|
||||||
|
eraseDuplicateDifferentType = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(gpio::GpioTypes::CALLBACK): {
|
||||||
|
if(gpioType != gpio::GpioTypes::CALLBACK) {
|
||||||
|
eraseDuplicateDifferentType = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(eraseDuplicateDifferentType) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for "
|
||||||
|
"different GPIO type " << gpioIdToCheck <<
|
||||||
|
". Removing duplicate from map to add" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printWarning("LinuxLibgpioIF::checkForConflicts: ID already exists for "
|
||||||
|
"different GPIO type %d. Removing duplicate from map to add\n", gpioIdToCheck);
|
||||||
|
#endif
|
||||||
|
mapToAdd.erase(gpioIdToCheck);
|
||||||
|
return GPIO_DUPLICATE_DETECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove element from map to add because a entry for this GPIO
|
// Remove element from map to add because a entry for this GPIO already exists
|
||||||
already exists */
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition"
|
sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO "
|
||||||
<< " detected. Duplicate will be removed from map to add." << std::endl;
|
"definition with ID " << gpioIdToCheck << " detected. " <<
|
||||||
mapToAdd.erase(gpioIdToCheck);
|
"Duplicate will be removed from map to add" << std::endl;
|
||||||
}
|
#else
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
sif::printWarning("LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition "
|
||||||
}
|
"with ID %d detected. Duplicate will be removed from map to add\n", gpioIdToCheck);
|
||||||
|
#endif
|
||||||
ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck,
|
|
||||||
GpioCallback *callbackGpio, GpioMap& mapToAdd) {
|
|
||||||
/* Cross check with private map */
|
|
||||||
gpioMapIter = gpioMap.find(gpioIdToCheck);
|
|
||||||
if(gpioMapIter != gpioMap.end()) {
|
|
||||||
if(gpioMapIter->second->gpioType != gpio::GpioTypes::CALLBACK) {
|
|
||||||
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
|
|
||||||
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
|
|
||||||
mapToAdd.erase(gpioIdToCheck);
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove element from map to add because a entry for this GPIO
|
|
||||||
already exists */
|
|
||||||
sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition"
|
|
||||||
<< " detected. Duplicate will be removed from map to add." << std::endl;
|
|
||||||
mapToAdd.erase(gpioIdToCheck);
|
mapToAdd.erase(gpioIdToCheck);
|
||||||
|
return GPIO_DUPLICATE_DETECTED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) {
|
void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) {
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
case LINE_NOT_EXISTS:
|
case LINE_NOT_EXISTS:
|
||||||
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Line with name " << lineName
|
case LINE_ERROR: {
|
||||||
<< " does not exist" << std::endl;
|
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Line with name " << lineName <<
|
||||||
|
" does not exist" << std::endl;
|
||||||
break;
|
break;
|
||||||
case LINE_ERROR:
|
}
|
||||||
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: " << "Line with name "
|
default: {
|
||||||
<< lineName << " does not exist" << std::endl;
|
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Unknown return code for line "
|
||||||
|
"with name " << lineName << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Unknown return code for line with "
|
#else
|
||||||
<< "name " << lineName << std::endl;
|
case LINE_NOT_EXISTS:
|
||||||
|
case LINE_ERROR: {
|
||||||
|
sif::printWarning("LinuxLibgpioIF::parseFindeLineResult: Line with name %s "
|
||||||
|
"does not exist\n", lineName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
sif::printWarning("LinuxLibgpioIF::parseFindeLineResult: Unknown return code for line "
|
||||||
|
"with name %s\n", lineName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_
|
#ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||||
#define LINUX_GPIO_LINUXLIBGPIOIF_H_
|
#define LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||||
|
|
||||||
#include "../../common/gpio/GpioIF.h"
|
#include "fsfw/returnvalues/FwClassIds.h"
|
||||||
#include <returnvalues/classIds.h>
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
|
|
||||||
class GpioCookie;
|
class GpioCookie;
|
||||||
class GpiodRegularIF;
|
class GpiodRegularIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class implements the GpioIF for a linux based system. The
|
* @brief This class implements the GpioIF for a linux based system.
|
||||||
* implementation is based on the libgpiod lib which requires linux 4.8
|
* @details
|
||||||
* or higher.
|
* This implementation is based on the libgpiod lib which requires Linux 4.8 or higher.
|
||||||
* @note The Petalinux SDK from Xilinx supports libgpiod since Petalinux
|
* @note
|
||||||
* 2019.1.
|
* The Petalinux SDK from Xilinx supports libgpiod since Petalinux 2019.1.
|
||||||
*/
|
*/
|
||||||
class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
class LinuxLibgpioIF : public GpioIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
@ -28,6 +28,8 @@ public:
|
|||||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3);
|
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3);
|
||||||
static constexpr ReturnValue_t GPIO_INVALID_INSTANCE =
|
static constexpr ReturnValue_t GPIO_INVALID_INSTANCE =
|
||||||
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4);
|
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4);
|
||||||
|
static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED =
|
||||||
|
HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 5);
|
||||||
|
|
||||||
LinuxLibgpioIF(object_id_t objectId);
|
LinuxLibgpioIF(object_id_t objectId);
|
||||||
virtual ~LinuxLibgpioIF();
|
virtual ~LinuxLibgpioIF();
|
||||||
@ -44,7 +46,7 @@ private:
|
|||||||
static const int LINE_ERROR = -1;
|
static const int LINE_ERROR = -1;
|
||||||
static const int LINE_FOUND = 1;
|
static const int LINE_FOUND = 1;
|
||||||
|
|
||||||
/* Holds the information and configuration of all used GPIOs */
|
// Holds the information and configuration of all used GPIOs
|
||||||
GpioUnorderedMap gpioMap;
|
GpioUnorderedMap gpioMap;
|
||||||
GpioUnorderedMapIter gpioMapIter;
|
GpioUnorderedMapIter gpioMapIter;
|
||||||
|
|
||||||
@ -75,9 +77,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t checkForConflicts(GpioMap& mapToAdd);
|
ReturnValue_t checkForConflicts(GpioMap& mapToAdd);
|
||||||
|
|
||||||
ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegularBase& regularGpio,
|
ReturnValue_t checkForConflictsById(gpioId_t gpiodId, gpio::GpioTypes type,
|
||||||
GpioMap& mapToAdd);
|
|
||||||
ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio,
|
|
||||||
GpioMap& mapToAdd);
|
GpioMap& mapToAdd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +227,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
|
|||||||
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
|
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
|
||||||
result = FULL_DUPLEX_TRANSFER_FAILED;
|
result = FULL_DUPLEX_TRANSFER_FAILED;
|
||||||
}
|
}
|
||||||
#if FSFW_HAL_LINUX_SPI_WIRETAPPING == 1
|
#if FSFW_HAL_SPI_WIRETAPPING == 1
|
||||||
performSpiWiretapping(spiCookie);
|
performSpiWiretapping(spiCookie);
|
||||||
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
|
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Can be used for low-level debugging of the SPI bus */
|
// Can be used for low-level debugging of the SPI bus
|
||||||
#ifndef FSFW_HAL_LINUX_SPI_WIRETAPPING
|
#ifndef FSFW_HAL_SPI_WIRETAPPING
|
||||||
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
|
#define FSFW_HAL_SPI_WIRETAPPING 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG
|
#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG
|
||||||
|
@ -29,6 +29,8 @@ enum: uint8_t {
|
|||||||
PUS_SERVICE_9 = 89,
|
PUS_SERVICE_9 = 89,
|
||||||
PUS_SERVICE_17 = 97,
|
PUS_SERVICE_17 = 97,
|
||||||
PUS_SERVICE_23 = 103,
|
PUS_SERVICE_23 = 103,
|
||||||
|
MGM_LIS3MDL = 106,
|
||||||
|
MGM_RM3100 = 107,
|
||||||
|
|
||||||
FW_SUBSYSTEM_ID_RANGE
|
FW_SUBSYSTEM_ID_RANGE
|
||||||
};
|
};
|
||||||
|
@ -78,6 +78,8 @@ enum: uint8_t {
|
|||||||
HAL_I2C, //HI2C
|
HAL_I2C, //HI2C
|
||||||
HAL_GPIO, //HGIO
|
HAL_GPIO, //HGIO
|
||||||
FIXED_SLOT_TASK_IF, //FTIF
|
FIXED_SLOT_TASK_IF, //FTIF
|
||||||
|
MGM_LIS3MDL, //MGMLIS3
|
||||||
|
MGM_RM3100, //MGMRM3100
|
||||||
FW_CLASS_ID_COUNT // [EXPORT] : [END]
|
FW_CLASS_ID_COUNT // [EXPORT] : [END]
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -16,15 +16,18 @@ InternalUnitTester::~InternalUnitTester() {}
|
|||||||
ReturnValue_t InternalUnitTester::performTests(
|
ReturnValue_t InternalUnitTester::performTests(
|
||||||
const struct InternalUnitTester::TestConfig& testConfig) {
|
const struct InternalUnitTester::TestConfig& testConfig) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "Running internal unit tests.." << std::endl;
|
sif::info << "Running internal unit tests.. Error messages might follow" <<
|
||||||
|
std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("Running internal unit tests..\n");
|
sif::printInfo("Running internal unit tests..\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
testserialize::test_serialization();
|
testserialize::test_serialization();
|
||||||
testmq::testMq();
|
testmq::testMq();
|
||||||
|
if(testConfig.testSemaphores) {
|
||||||
testsemaph::testBinSemaph();
|
testsemaph::testBinSemaph();
|
||||||
testsemaph::testCountingSemaph();
|
testsemaph::testCountingSemaph();
|
||||||
|
}
|
||||||
testmutex::testMutex();
|
testmutex::testMutex();
|
||||||
if(testConfig.testArrayPrinter) {
|
if(testConfig.testArrayPrinter) {
|
||||||
arrayprinter::testArrayPrinter();
|
arrayprinter::testArrayPrinter();
|
||||||
|
@ -18,6 +18,7 @@ class InternalUnitTester: public HasReturnvaluesIF {
|
|||||||
public:
|
public:
|
||||||
struct TestConfig {
|
struct TestConfig {
|
||||||
bool testArrayPrinter = false;
|
bool testArrayPrinter = false;
|
||||||
|
bool testSemaphores = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
InternalUnitTester();
|
InternalUnitTester();
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
#include "fsfw_tests/internal/osal/IntTestMutex.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
#include "fsfw/platform.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
|
|
||||||
#if defined(WIN32) || defined(UNIX)
|
#if defined PLATFORM_WIN || defined PLATFORM_UNIX
|
||||||
#include <fsfw/osal/host/Mutex.h>
|
#include "fsfw/osal/host/Mutex.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
#endif
|
#endif
|
||||||
@ -20,7 +22,7 @@ void testmutex::testMutex() {
|
|||||||
// timed_mutex from the C++ library specifies undefined behaviour if
|
// timed_mutex from the C++ library specifies undefined behaviour if
|
||||||
// the timed mutex is locked twice from the same thread.
|
// the timed mutex is locked twice from the same thread.
|
||||||
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
||||||
#if defined(WIN32) || defined(UNIX)
|
#if defined PLATFORM_WIN || defined PLATFORM_UNIX
|
||||||
// This calls the function from
|
// This calls the function from
|
||||||
// another thread and stores the returnvalue in a future.
|
// another thread and stores the returnvalue in a future.
|
||||||
auto future = std::async(&MutexIF::lockMutex, mutex, MutexIF::TimeoutType::WAITING, 1);
|
auto future = std::async(&MutexIF::lockMutex, mutex, MutexIF::TimeoutType::WAITING, 1);
|
||||||
@ -37,8 +39,7 @@ void testmutex::testMutex() {
|
|||||||
unitt::put_error(id);
|
unitt::put_error(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we should pass a define like FSFW_OSAL_HOST to the build.
|
#if !defined PLATFORM_WIN && !defined PLATFORM_UNIX
|
||||||
#if !defined(WIN32) && !defined(UNIX)
|
|
||||||
result = mutex->unlockMutex();
|
result = mutex->unlockMutex();
|
||||||
if(result != MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX) {
|
if(result != MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX) {
|
||||||
unitt::put_error(id);
|
unitt::put_error(id);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
#include "fsfw_tests/internal/osal/IntTestSemaphore.h"
|
||||||
#include "fsfw_tests/internal/UnittDefinitions.h"
|
#include "fsfw_tests/internal/UnittDefinitions.h"
|
||||||
|
|
||||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
#include "fsfw/tasks/SemaphoreFactory.h"
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include <fsfw/timemanager/Stopwatch.h>
|
#include "fsfw/timemanager/Stopwatch.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ void testsemaph::testBinSemaph() {
|
|||||||
}
|
}
|
||||||
testBinSemaphoreImplementation(binSemaph, id);
|
testBinSemaphoreImplementation(binSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
SemaphoreIF* binSemaphUsingTask =
|
SemaphoreIF* binSemaphUsingTask =
|
||||||
SemaphoreFactory::instance()->createBinarySemaphore(1);
|
SemaphoreFactory::instance()->createBinarySemaphore(1);
|
||||||
testBinSemaphoreImplementation(binSemaphUsingTask, id);
|
testBinSemaphoreImplementation(binSemaphUsingTask, id);
|
||||||
@ -36,7 +37,7 @@ void testsemaph::testCountingSemaph() {
|
|||||||
}
|
}
|
||||||
testBinSemaphoreImplementation(countingSemaph, id);
|
testBinSemaphoreImplementation(countingSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
countingSemaph = SemaphoreFactory::instance()->
|
countingSemaph = SemaphoreFactory::instance()->
|
||||||
createCountingSemaphore(1, 1, 1);
|
createCountingSemaphore(1, 1, 1);
|
||||||
testBinSemaphoreImplementation(countingSemaph, id);
|
testBinSemaphoreImplementation(countingSemaph, id);
|
||||||
@ -50,7 +51,7 @@ void testsemaph::testCountingSemaph() {
|
|||||||
createCountingSemaphore(3,3);
|
createCountingSemaphore(3,3);
|
||||||
testCountingSemaphImplementation(countingSemaph, id);
|
testCountingSemaphImplementation(countingSemaph, id);
|
||||||
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
SemaphoreFactory::instance()->deleteSemaphore(countingSemaph);
|
||||||
#if defined(freeRTOS)
|
#if defined FSFW_OSAL_FREERTOS
|
||||||
countingSemaph = SemaphoreFactory::instance()->
|
countingSemaph = SemaphoreFactory::instance()->
|
||||||
createCountingSemaphore(3, 0, 1);
|
createCountingSemaphore(3, 0, 1);
|
||||||
uint8_t semaphCount = countingSemaph->getSemaphoreCounter();
|
uint8_t semaphCount = countingSemaph->getSemaphoreCounter();
|
||||||
|
Loading…
Reference in New Issue
Block a user