Compare commits

...

26 Commits

Author SHA1 Message Date
Jakob Meier
16b125ef6c Merge branch 'meier/fixMgmLIS3MDLHandler' into meier/gpioOpenByLineName 2021-09-24 15:37:49 +02:00
Jakob Meier
10f8a0fd0e MgmLIS3MDLHandler fix in buildTransitionDeviceCommand 2021-09-24 15:33:55 +02:00
Jakob Meier
48a24d7dba removed gpio type GPIO_REGULAR 2021-09-24 10:21:40 +02:00
Jakob Meier
e7df520780 fixed merge conflicts 2021-09-23 17:54:41 +02:00
dd610f0d7e Merge branch 'mueller/master' into eive/develop 2021-09-23 17:34:24 +02:00
0987a160c9 new retval for empty slot list 2021-09-23 17:33:45 +02:00
ceeb0c5388 Merge branch 'eive/develop' of https://egit.irs.uni-stuttgart.de/eive/fsfw into eive/develop 2021-09-23 17:14:31 +02:00
91f7184ebb Merge branch 'mueller/master' into eive/develop 2021-09-23 17:14:25 +02:00
e1a85b47c5 tiny tweaks 2021-09-23 17:13:53 +02:00
a3eb870ba0 Corrected comment 2021-09-23 16:45:37 +02:00
ed2263b5f7 Merge pull request 'Improvements for devices' (#17) from mueller/acs-board-improvements into eive/develop
Reviewed-on: #17
2021-09-23 15:59:20 +02:00
dccc2f0ba7 printout fix SpiComIF 2021-09-23 15:57:50 +02:00
350fbc385c small tweak 2021-09-23 15:22:27 +02:00
c9b343ebcd op divider fixes 2021-09-23 15:20:10 +02:00
81c33d2dc6 added functions to set x,y,z limits 2021-09-23 14:56:20 +02:00
29c74283f1 sanity checks 2021-09-22 18:36:53 +02:00
c51d2df43d printout fix 2021-09-22 16:00:18 +02:00
d3b83f3cf9 API made more consistent 2021-09-22 15:02:34 +02:00
60229da670 Merge pull request 'GPIO Refactoring' (#16) from mueller/gpio-refactoring into eive/develop
Reviewed-on: #16
2021-09-22 14:39:53 +02:00
5c56eda610 fix for raspberry pi code 2021-09-22 12:19:30 +02:00
3d1be94e12 more checks and printouts 2021-09-21 19:27:33 +02:00
8e65d2d3fc refactored GPIO components 2021-09-21 17:31:03 +02:00
8374d495fa Merge remote-tracking branch 'origin/eive/develop' into mueller/master 2021-09-21 16:02:41 +02:00
e02879184b Merge pull request 'added option to open gpio by label instead of gpiochip*' (#15) from meier/gpioOpenByLabel into eive/develop
Reviewed-on: #15
2021-09-21 16:01:28 +02:00
87b68e84be Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/eive/fsfw into mueller/master 2021-09-20 18:33:03 +02:00
784a0140f4 tweak op divider divisor 2021-09-20 18:31:52 +02:00
19 changed files with 383 additions and 168 deletions

View File

@@ -26,7 +26,9 @@ enum GpioOperation {
enum GpioTypes { enum GpioTypes {
NONE, NONE,
GPIO_REGULAR, GPIO_REGULAR_BY_CHIP,
GPIO_REGULAR_BY_LABEL,
GPIO_REGULAR_BY_LINE_NAME,
CALLBACK CALLBACK
}; };
@@ -68,40 +70,84 @@ public:
int initValue = 0; int initValue = 0;
}; };
class GpiodRegular: public GpioBase { class GpiodRegularBase: public GpioBase {
public: public:
GpiodRegular() : GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
GpioBase(gpio::GpioTypes::GPIO_REGULAR, std::string(), gpio::Direction::IN, 0) { int initValue, int lineNum): GpioBase(gpioType, consumer, direction, initValue),
} lineNum(lineNum) {
;
GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_,
gpio::Direction direction_, int initValue_) :
GpioBase(gpio::GpioTypes::GPIO_REGULAR, consumer_, direction_, initValue_),
chipname(chipname_), lineNum(lineNum_) {
} }
GpiodRegular(std::string chipname_, int lineNum_, std::string consumer_) : // line number will be configured at a later point for the open by line name configuration
GpioBase(gpio::GpioTypes::GPIO_REGULAR, consumer_, gpio::Direction::IN, 0), GpiodRegularBase(gpio::GpioTypes gpioType, std::string consumer, gpio::Direction direction,
chipname(chipname_), lineNum(lineNum_) { int initValue): GpioBase(gpioType, consumer, direction, initValue) {
} }
GpiodRegular(std::string consumer_, gpio::Direction direction_, int initValue_,
std::string label_, int lineNum_) :
GpioBase(gpio::GpioTypes::GPIO_REGULAR, consumer_, direction_, initValue_), label(
label_), lineNum(lineNum_) {
}
GpiodRegular(std::string consumer_, std::string label_, int lineNum_) :
GpioBase(gpio::GpioTypes::GPIO_REGULAR, consumer_, gpio::Direction::IN, 0), label(
label_), lineNum(lineNum_) {
}
std::string chipname = "NONE";
std::string label = "NONE";
int lineNum = 0; int lineNum = 0;
struct gpiod_line* lineHandle = nullptr; struct gpiod_line* lineHandle = nullptr;
}; };
class GpiodRegularByChip: public GpiodRegularBase {
public:
GpiodRegularByChip() :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
std::string(), gpio::Direction::IN, gpio::LOW, 0) {
}
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
gpio::Direction direction_, int initValue_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP,
consumer_, direction_, initValue_, lineNum_),
chipname(chipname_){
}
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_,
gpio::Direction::IN, gpio::LOW, lineNum_),
chipname(chipname_) {
}
std::string chipname;
};
class GpiodRegularByLabel: public GpiodRegularBase {
public:
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_,
gpio::Direction direction_, int initValue_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
direction_, initValue_, lineNum_),
label(label_) {
}
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_,
gpio::Direction::IN, gpio::LOW, lineNum_),
label(label_) {
}
std::string label;
};
/**
* @brief Passing this GPIO configuration to the GPIO IF object will try to open the GPIO by its
* line name. This line name can be set in the device tree and must be unique. Otherwise
* the driver will open the first line with the given name.
*/
class GpiodRegularByLineName: public GpiodRegularBase {
public:
GpiodRegularByLineName(std::string lineName_, std::string consumer_, gpio::Direction direction_,
int initValue_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, direction_,
initValue_), lineName(lineName_) {
}
GpiodRegularByLineName(std::string lineName_, std::string consumer_) :
GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, gpio::Direction::IN,
gpio::LOW), lineName(lineName_) {
}
std::string lineName;
};
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_, int initValue_,

View File

@@ -3,11 +3,11 @@
#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/datapool/PoolReadGuard.h"
GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication, GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF *comCookie, uint8_t switchId, uint32_t transitionDelayMs): CookieIF *comCookie, uint32_t transitionDelayMs):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), DeviceHandlerBase(objectId, deviceCommunication, comCookie),
switchId(switchId), transitionDelayMs(transitionDelayMs), dataset(this) { transitionDelayMs(transitionDelayMs), dataset(this) {
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
debugDivider = new PeriodicOperationDivider(5); debugDivider = new PeriodicOperationDivider(3);
#endif #endif
} }
@@ -215,11 +215,32 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
PoolReadGuard readSet(&dataset); PoolReadGuard readSet(&dataset);
if(readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) { if(readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
dataset.angVelocX = angVelocX; if(std::abs(angVelocX) < this->absLimitX) {
dataset.angVelocY = angVelocY; dataset.angVelocX = angVelocX;
dataset.angVelocZ = angVelocZ; dataset.angVelocX.setValid(true);
}
else {
dataset.angVelocX.setValid(false);
}
if(std::abs(angVelocY) < this->absLimitY) {
dataset.angVelocY = angVelocY;
dataset.angVelocY.setValid(true);
}
else {
dataset.angVelocY.setValid(false);
}
if(std::abs(angVelocZ) < this->absLimitZ) {
dataset.angVelocZ = angVelocZ;
dataset.angVelocZ.setValid(true);
}
else {
dataset.angVelocZ.setValid(false);
}
dataset.temperature = temperature; dataset.temperature = temperature;
dataset.setValidity(true, true); dataset.temperature.setValid(true);
} }
break; break;
} }
@@ -234,7 +255,7 @@ uint32_t GyroHandlerL3GD20H::getTransitionDelayMs(Mode_t from, Mode_t to) {
return this->transitionDelayMs; return this->transitionDelayMs;
} }
void GyroHandlerL3GD20H::setGoNormalModeAtStartup() { void GyroHandlerL3GD20H::setToGoToNormalMode(bool enable) {
this->goNormalModeImmediately = true; this->goNormalModeImmediately = true;
} }
@@ -256,3 +277,9 @@ void GyroHandlerL3GD20H::fillCommandAndReplyMap() {
void GyroHandlerL3GD20H::modeChanged() { void GyroHandlerL3GD20H::modeChanged() {
internalState = InternalState::NONE; internalState = InternalState::NONE;
} }
void GyroHandlerL3GD20H::setAbsoluteLimits(float limitX, float limitY, float limitZ) {
this->absLimitX = limitX;
this->absLimitY = limitY;
this->absLimitZ = limitZ;
}

View File

@@ -19,13 +19,22 @@
class GyroHandlerL3GD20H: public DeviceHandlerBase { class GyroHandlerL3GD20H: public DeviceHandlerBase {
public: public:
GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication, GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie, uint8_t switchId, uint32_t transitionDelayMs = 10000); CookieIF* comCookie, uint32_t transitionDelayMs);
virtual ~GyroHandlerL3GD20H(); virtual ~GyroHandlerL3GD20H();
/**
* Set the absolute limit for the values on the axis in degrees per second.
* The dataset values will be marked as invalid if that limit is exceeded
* @param xLimit
* @param yLimit
* @param zLimit
*/
void setAbsoluteLimits(float limitX, float limitY, float limitZ);
/** /**
* @brief Configure device handler to go to normal mode immediately * @brief Configure device handler to go to normal mode immediately
*/ */
void setGoNormalModeAtStartup(); void setToGoToNormalMode(bool enable);
protected: protected:
/* DeviceHandlerBase overrides */ /* DeviceHandlerBase overrides */
@@ -40,12 +49,12 @@ protected:
size_t commandDataLen) override; size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override; DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override; const uint8_t *packet) override;
void fillCommandAndReplyMap() override; void fillCommandAndReplyMap() override;
void modeChanged() override; void modeChanged() override;
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
@@ -54,6 +63,10 @@ private:
uint32_t transitionDelayMs = 0; uint32_t transitionDelayMs = 0;
GyroPrimaryDataset dataset; GyroPrimaryDataset dataset;
float absLimitX = L3GD20H::RANGE_DPS_00;
float absLimitY = L3GD20H::RANGE_DPS_00;
float absLimitZ = L3GD20H::RANGE_DPS_00;
enum class InternalState { enum class InternalState {
NONE, NONE,
CONFIGURE, CONFIGURE,

View File

@@ -6,13 +6,13 @@
#endif #endif
MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication, MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie, uint8_t switchId, uint32_t transitionDelay): CookieIF* comCookie, uint32_t transitionDelay):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), DeviceHandlerBase(objectId, deviceCommunication, comCookie),
dataset(this), transitionDelay(transitionDelay) { dataset(this), transitionDelay(transitionDelay) {
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
debugDivider = new PeriodicOperationDivider(5); debugDivider = new PeriodicOperationDivider(3);
#endif #endif
/* Set to default values right away. */ // Set to default values right away
registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT; registers[0] = MGMLIS3MDL::CTRL_REG1_DEFAULT;
registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT; registers[1] = MGMLIS3MDL::CTRL_REG2_DEFAULT;
registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT; registers[2] = MGMLIS3MDL::CTRL_REG3_DEFAULT;
@@ -71,7 +71,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(
switch (internalState) { switch (internalState) {
case(InternalState::STATE_NONE): case(InternalState::STATE_NONE):
case(InternalState::STATE_NORMAL): { case(InternalState::STATE_NORMAL): {
return HasReturnvaluesIF::RETURN_OK; return DeviceHandlerBase::NOTHING_TO_SEND;
} }
case(InternalState::STATE_FIRST_CONTACT): { case(InternalState::STATE_FIRST_CONTACT): {
*id = MGMLIS3MDL::IDENTIFY_DEVICE; *id = MGMLIS3MDL::IDENTIFY_DEVICE;
@@ -291,7 +291,6 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id,
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
if(debugDivider->checkAndIncrement()) { if(debugDivider->checkAndIncrement()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "MGMHandlerLIS3: Magnetic field strength in" sif::info << "MGMHandlerLIS3: Magnetic field strength in"
" microtesla:" << std::endl; " microtesla:" << std::endl;
@@ -308,10 +307,29 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id,
#endif /* OBSW_VERBOSE_LEVEL >= 1 */ #endif /* OBSW_VERBOSE_LEVEL >= 1 */
PoolReadGuard readHelper(&dataset); PoolReadGuard readHelper(&dataset);
if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
dataset.fieldStrengthX = mgmX; if(std::abs(mgmX) < absLimitX) {
dataset.fieldStrengthY = mgmY; dataset.fieldStrengthX = mgmX;
dataset.fieldStrengthZ = mgmZ; dataset.fieldStrengthX.setValid(true);
dataset.setValidity(true, true); }
else {
dataset.fieldStrengthX.setValid(false);
}
if(std::abs(mgmY) < absLimitY) {
dataset.fieldStrengthY = mgmY;
dataset.fieldStrengthY.setValid(true);
}
else {
dataset.fieldStrengthY.setValid(false);
}
if(std::abs(mgmZ) < absLimitZ) {
dataset.fieldStrengthZ = mgmZ;
dataset.fieldStrengthZ.setValid(true);
}
else {
dataset.fieldStrengthZ.setValid(false);
}
} }
break; break;
} }
@@ -321,7 +339,6 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id,
float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0); float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0);
#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1
if(debugDivider->check()) { if(debugDivider->check()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" <<
std::endl; std::endl;
@@ -444,16 +461,6 @@ ReturnValue_t MgmLIS3MDLHandler::setOperatingMode(const uint8_t *commandData,
} }
void MgmLIS3MDLHandler::fillCommandAndReplyMap() { void MgmLIS3MDLHandler::fillCommandAndReplyMap() {
/*
* Regarding ArduinoBoard:
* Actually SPI answers directly, but as commanding ArduinoBoard the
* communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of
* the device, the device has to asked with a command, so periodic is zero.
*
* We dont read single registers, we just expect special
* reply from he Readall_MGM
*/
insertInCommandAndReplyMap(MGMLIS3MDL::READ_CONFIG_AND_DATA, 1, &dataset); insertInCommandAndReplyMap(MGMLIS3MDL::READ_CONFIG_AND_DATA, 1, &dataset);
insertInCommandAndReplyMap(MGMLIS3MDL::READ_TEMPERATURE, 1); insertInCommandAndReplyMap(MGMLIS3MDL::READ_TEMPERATURE, 1);
insertInCommandAndReplyMap(MGMLIS3MDL::SETUP_MGM, 1); insertInCommandAndReplyMap(MGMLIS3MDL::SETUP_MGM, 1);
@@ -475,7 +482,7 @@ ReturnValue_t MgmLIS3MDLHandler::prepareCtrlRegisterWrite() {
rawPacket = commandBuffer; rawPacket = commandBuffer;
rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1; rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1;
/* We dont have to check if this is working because we just did it */ // We dont have to check if this is working because we just did i
return RETURN_OK; return RETURN_OK;
} }
@@ -503,3 +510,9 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(
new PoolEntry<float>({0.0})); new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLimit) {
this->absLimitX = xLimit;
this->absLimitY = yLimit;
this->absLimitZ = zLimit;
}

View File

@@ -31,9 +31,17 @@ public:
static const Event CHANGE_OF_SETUP_PARAMETER = MAKE_EVENT(0, severity::LOW); static const Event CHANGE_OF_SETUP_PARAMETER = MAKE_EVENT(0, severity::LOW);
MgmLIS3MDLHandler(uint32_t objectId, object_id_t deviceCommunication, CookieIF* comCookie, MgmLIS3MDLHandler(uint32_t objectId, object_id_t deviceCommunication, CookieIF* comCookie,
uint8_t switchId, uint32_t transitionDelay = 10000); uint32_t transitionDelay);
virtual ~MgmLIS3MDLHandler(); virtual ~MgmLIS3MDLHandler();
/**
* Set the absolute limit for the values on the axis in microtesla. The dataset values will
* be marked as invalid if that limit is exceeded
* @param xLimit
* @param yLimit
* @param zLimit
*/
void setAbsoluteLimits(float xLimit, float yLimit, float zLimit);
void setToGoToNormalMode(bool enable); void setToGoToNormalMode(bool enable);
protected: protected:
@@ -42,7 +50,7 @@ protected:
void doShutDown() override; void doShutDown() override;
void doStartUp() override; void doStartUp() override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t buildCommandFromCommand( ReturnValue_t buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData, DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override; size_t commandDataLen) override;
@@ -52,7 +60,14 @@ protected:
DeviceCommandId_t *id) override; DeviceCommandId_t *id) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override; DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, /**
* This implementation is tailored towards space applications and will flag values larger
* than 100 microtesla on X,Y and 150 microtesla on Z as invalid
* @param id
* @param packet
* @return
*/
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override; const uint8_t *packet) override;
void fillCommandAndReplyMap() override; void fillCommandAndReplyMap() override;
void modeChanged(void) override; void modeChanged(void) override;
@@ -61,15 +76,19 @@ protected:
private: private:
MGMLIS3MDL::MgmPrimaryDataset dataset; MGMLIS3MDL::MgmPrimaryDataset dataset;
//Length a sindgle command SPI answer //Length a single command SPI answer
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2; static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
uint32_t transitionDelay; uint32_t transitionDelay;
//Single SPIcommand has 2 bytes, first for adress, second for content // Single SPI command has 2 bytes, first for adress, second for content
size_t singleComandSize = 2; size_t singleComandSize = 2;
//has the size for all adresses of the lis3mdl + the continous write bit // Has the size for all adresses of the lis3mdl + the continous write bit
uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1]; uint8_t commandBuffer[MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1];
float absLimitX = 100;
float absLimitY = 100;
float absLimitZ = 150;
/** /**
* We want to save the registers we set, so we dont have to read the * We want to save the registers we set, so we dont have to read the
* registers when we want to change something. * registers when we want to change something.

View File

@@ -8,12 +8,11 @@
MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId, MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId,
object_id_t deviceCommunication, CookieIF* comCookie, uint8_t switchId, object_id_t deviceCommunication, CookieIF* comCookie, uint32_t transitionDelay):
uint32_t transitionDelay):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), DeviceHandlerBase(objectId, deviceCommunication, comCookie),
primaryDataset(this), switchId(switchId), transitionDelay(transitionDelay) { primaryDataset(this), transitionDelay(transitionDelay) {
#if FSFW_HAL_RM3100_MGM_DEBUG == 1 #if FSFW_HAL_RM3100_MGM_DEBUG == 1
debugDivider = new PeriodicOperationDivider(1); debugDivider = new PeriodicOperationDivider(3);
#endif #endif
} }
@@ -322,13 +321,7 @@ ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(
} }
uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) { uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) {
return 25000; return this->transitionDelay;
}
ReturnValue_t MgmRM3100Handler::getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) {
*switches = &switchId;
*numberOfSwitches = 1;
return HasReturnvaluesIF::RETURN_OK;
} }
void MgmRM3100Handler::setToGoToNormalMode(bool enable) { void MgmRM3100Handler::setToGoToNormalMode(bool enable) {

View File

@@ -32,7 +32,7 @@ public:
SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO); SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO);
MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication, MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie, uint8_t switchId, uint32_t transitionDelay = 10000); CookieIF* comCookie, uint32_t transitionDelay);
virtual ~MgmRM3100Handler(); virtual ~MgmRM3100Handler();
/** /**
@@ -48,21 +48,16 @@ protected:
DeviceCommandId_t *id) override; DeviceCommandId_t *id) override;
void doStartUp() override; void doStartUp() override;
void doShutDown() override; void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand( ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
DeviceCommandId_t *id) override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
ReturnValue_t buildCommandFromCommand( const uint8_t *commandData, size_t commandDataLen) override;
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len, ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override; DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
const uint8_t *packet) override;
ReturnValue_t getSwitches(const uint8_t **switches,
uint8_t *numberOfSwitches) override;
void fillCommandAndReplyMap() override; void fillCommandAndReplyMap() override;
void modeChanged(void) override; void modeChanged(void) override;
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
@@ -97,7 +92,6 @@ private:
float scaleFactorZ = 1.0 / RM3100::DEFAULT_GAIN; float scaleFactorZ = 1.0 / RM3100::DEFAULT_GAIN;
bool goToNormalModeAtStartup = false; bool goToNormalModeAtStartup = false;
uint8_t switchId;
uint32_t transitionDelay; uint32_t transitionDelay;
ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand, ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand,

View File

@@ -45,16 +45,33 @@ ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) {
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
for(auto& gpioConfig: mapToAdd) { for(auto& gpioConfig: mapToAdd) {
switch(gpioConfig.second->gpioType) { auto& gpioType = gpioConfig.second->gpioType;
switch(gpioType) {
case(gpio::GpioTypes::NONE): { case(gpio::GpioTypes::NONE): {
return GPIO_INVALID_INSTANCE; return GPIO_INVALID_INSTANCE;
} }
case(gpio::GpioTypes::GPIO_REGULAR): { case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP): {
GpiodRegular* regularGpio = dynamic_cast<GpiodRegular*>(gpioConfig.second); auto regularGpio = dynamic_cast<GpiodRegularByChip*>(gpioConfig.second);
if(regularGpio == nullptr) { if(regularGpio == nullptr) {
return GPIO_INVALID_INSTANCE; return GPIO_INVALID_INSTANCE;
} }
configureRegularGpio(gpioConfig.first, regularGpio); configureGpioByChip(gpioConfig.first, *regularGpio);
break;
}
case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):{
auto regularGpio = dynamic_cast<GpiodRegularByLabel*>(gpioConfig.second);
if(regularGpio == nullptr) {
return GPIO_INVALID_INSTANCE;
}
configureGpioByLabel(gpioConfig.first, *regularGpio);
break;
}
case(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME):{
auto regularGpio = dynamic_cast<GpiodRegularByLineName*>(gpioConfig.second);
if(regularGpio == nullptr) {
return GPIO_INVALID_INSTANCE;
}
configureGpioByLineName(gpioConfig.first, *regularGpio);
break; break;
} }
case(gpio::GpioTypes::CALLBACK): { case(gpio::GpioTypes::CALLBACK): {
@@ -70,58 +87,84 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular *regularGpio) { ReturnValue_t LinuxLibgpioIF::configureGpioByLabel(gpioId_t gpioId,
std::string chipname; GpiodRegularByLabel &gpioByLabel) {
std::string label; std::string& label = gpioByLabel.label;
struct gpiod_chip* chip = gpiod_chip_open_by_label(label.c_str());
if (chip == nullptr) {
sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio "
<< "group with label " << label << ". Gpio ID: " << gpioId << std::endl;
return RETURN_FAILED;
}
std::string failOutput = "label: " + label;
return configureRegularGpio(gpioId, chip, gpioByLabel, failOutput);
}
ReturnValue_t LinuxLibgpioIF::configureGpioByChip(gpioId_t gpioId,
GpiodRegularByChip &gpioByChip) {
std::string& chipname = gpioByChip.chipname;
struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname.c_str());
if (chip == nullptr) {
sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip "
<< chipname << ". Gpio ID: " << gpioId << std::endl;
return RETURN_FAILED;
}
std::string failOutput = "chipname: " + chipname;
return configureRegularGpio(gpioId, chip, gpioByChip, failOutput);
}
ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId,
GpiodRegularByLineName &gpioByLineName) {
std::string& lineName = gpioByLineName.lineName;
char chipname[MAX_CHIPNAME_LENGTH];
unsigned int lineOffset;
int result = gpiod_ctxless_find_line(lineName.c_str(), chipname, MAX_CHIPNAME_LENGTH,
&lineOffset);
if (result != LINE_FOUND) {
parseFindeLineResult(result, lineName);
return RETURN_FAILED;
}
gpioByLineName.lineNum = static_cast<int>(lineOffset);
struct gpiod_chip* chip = gpiod_chip_open_by_name(chipname);
if (chip == nullptr) {
sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip "
<< chipname << ". <Gpio ID: " << gpioId << std::endl;
return RETURN_FAILED;
}
std::string failOutput = "line name: " + lineName;
return configureRegularGpio(gpioId, chip, gpioByLineName, failOutput);
}
ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod_chip* chip,
GpiodRegularBase& regularGpio, std::string failOutput) {
unsigned int lineNum; unsigned int lineNum;
struct gpiod_chip *chip;
gpio::Direction direction; gpio::Direction direction;
std::string consumer; std::string consumer;
struct gpiod_line *lineHandle; struct gpiod_line *lineHandle;
int result = 0; int result = 0;
chipname = regularGpio->chipname; lineNum = regularGpio.lineNum;
if (chipname != "NONE") {
chip = gpiod_chip_open_by_name(chipname.c_str());
if (!chip) {
sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open chip "
<< chipname << ". Gpio ID: " << gpioId << std::endl;
return RETURN_FAILED;
}
}
else if (label != "NONE") {
label = regularGpio->label;
chip = gpiod_chip_open_by_label(label.c_str());
if (!chip) {
sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open gpio from gpio "
<< "group with label " << label << ". Gpio ID: " << gpioId << std::endl;
return RETURN_FAILED;
}
}
else {
sif::warning << "LinuxLibgpioIF::configureRegularGpio: No gpio group specified"
<< std::endl;
}
lineNum = regularGpio->lineNum;
lineHandle = gpiod_chip_get_line(chip, lineNum); lineHandle = gpiod_chip_get_line(chip, lineNum);
if (!lineHandle) { if (!lineHandle) {
sif::debug << "LinuxLibgpioIF::configureRegularGpio: Failed to open line " << std::endl; sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open line " << std::endl;
sif::debug << "GPIO ID: " << gpioId << ", line number: " << lineNum << sif::warning << "GPIO ID: " << gpioId << ", line number: " << lineNum <<
", chipname: " << chipname << std::endl; ", " << failOutput << std::endl;
sif::debug << "Check if linux GPIO configuration has changed. " << std::endl; sif::warning << "Check if Linux GPIO configuration has changed. " << std::endl;
gpiod_chip_close(chip); gpiod_chip_close(chip);
return RETURN_FAILED; return RETURN_FAILED;
} }
direction = regularGpio->direction; direction = regularGpio.direction;
consumer = regularGpio->consumer; consumer = regularGpio.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(),
regularGpio->initValue); regularGpio.initValue);
if (result < 0) { if (result < 0) {
sif::error << "LinuxLibgpioIF::configureRegularGpio: Failed to request line " << lineNum << sif::error << "LinuxLibgpioIF::configureRegularGpio: Failed to request line " << lineNum <<
" from GPIO instance with ID: " << gpioId << std::endl; " from GPIO instance with ID: " << gpioId << std::endl;
@@ -151,7 +194,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
* 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.
*/ */
regularGpio->lineHandle = lineHandle; regularGpio.lineHandle = lineHandle;
return RETURN_OK; return RETURN_OK;
} }
@@ -162,8 +205,15 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
return UNKNOWN_GPIO_ID; return UNKNOWN_GPIO_ID;
} }
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) { auto gpioType = gpioMapIter->second->gpioType;
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 1); if (gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_CHIP
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LABEL
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME) {
auto regularGpio = dynamic_cast<GpiodRegularBase*>(gpioMapIter->second);
if(regularGpio == nullptr) {
return GPIO_TYPE_FAILURE;
}
return driveGpio(gpioId, *regularGpio, gpio::HIGH);
} }
else { else {
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second); auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
@@ -184,8 +234,15 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
return UNKNOWN_GPIO_ID; return UNKNOWN_GPIO_ID;
} }
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) { auto& gpioType = gpioMapIter->second->gpioType;
return driveGpio(gpioId, dynamic_cast<GpiodRegular*>(gpioMapIter->second), 0); if (gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_CHIP
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LABEL
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME) {
auto regularGpio = dynamic_cast<GpiodRegularBase*>(gpioMapIter->second);
if(regularGpio == nullptr) {
return GPIO_TYPE_FAILURE;
}
return driveGpio(gpioId, *regularGpio, gpio::LOW);
} }
else { else {
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second); auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
@@ -200,12 +257,8 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
} }
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
GpiodRegular* regularGpio, unsigned int logicLevel) { GpiodRegularBase& regularGpio, gpio::Levels logicLevel) {
if(regularGpio == nullptr) { int result = gpiod_line_set_value(regularGpio.lineHandle, logicLevel);
return GPIO_TYPE_FAILURE;
}
int result = gpiod_line_set_value(regularGpio->lineHandle, logicLevel);
if (result < 0) { if (result < 0) {
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;
@@ -222,8 +275,11 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
return UNKNOWN_GPIO_ID; return UNKNOWN_GPIO_ID;
} }
if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIO_REGULAR) { auto gpioType = gpioMapIter->second->gpioType;
GpiodRegular* regularGpio = dynamic_cast<GpiodRegular*>(gpioMapIter->second); if (gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_CHIP
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LABEL
or gpioType == gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME) {
auto regularGpio = dynamic_cast<GpiodRegularBase*>(gpioMapIter->second);
if(regularGpio == nullptr) { if(regularGpio == nullptr) {
return GPIO_TYPE_FAILURE; return GPIO_TYPE_FAILURE;
} }
@@ -242,13 +298,14 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
for(auto& gpioConfig: mapToAdd) { for(auto& gpioConfig: mapToAdd) {
switch(gpioConfig.second->gpioType) { switch(gpioConfig.second->gpioType) {
case(gpio::GpioTypes::GPIO_REGULAR): { case(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
auto regularGpio = dynamic_cast<GpiodRegular*>(gpioConfig.second); case(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL): {
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 = checkForConflictsRegularGpio(gpioConfig.first, *regularGpio, mapToAdd);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
status = result; status = result;
} }
@@ -276,17 +333,19 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){
ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck, ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck,
GpiodRegular* gpioToCheck, GpioMap& mapToAdd) { GpiodRegularBase& gpioToCheck, 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()) {
if(gpioMapIter->second->gpioType != gpio::GpioTypes::GPIO_REGULAR) { auto& gpioType = gpioMapIter->second->gpioType;
if(gpioType != gpio::GpioTypes::GPIO_REGULAR_BY_CHIP and
gpioType != gpio::GpioTypes::GPIO_REGULAR_BY_LABEL) {
sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different " sif::warning << "LinuxLibgpioIF::checkForConflicts: ID already exists for different "
"GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl; "GPIO type" << gpioIdToCheck << ". Removing duplicate." << std::endl;
mapToAdd.erase(gpioIdToCheck); mapToAdd.erase(gpioIdToCheck);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
auto ownRegularGpio = dynamic_cast<GpiodRegular*>(gpioMapIter->second); auto ownRegularGpio = dynamic_cast<GpiodRegularBase*>(gpioMapIter->second);
if(ownRegularGpio == nullptr) { if(ownRegularGpio == nullptr) {
return GPIO_TYPE_FAILURE; return GPIO_TYPE_FAILURE;
} }
@@ -320,3 +379,21 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToChe
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) {
switch (result) {
case LINE_NOT_EXISTS:
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Line with name " << lineName
<< " does not exist" << std::endl;
break;
case LINE_ERROR:
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: " << "Line with name "
<< lineName << " does not exist" << std::endl;
break;
default:
sif::warning << "LinuxLibgpioIF::parseFindeLineResult: Unknown return code for line with "
<< "name " << lineName << std::endl;
break;
}
}

View File

@@ -6,6 +6,7 @@
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
class GpioCookie; class GpioCookie;
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. The
@@ -37,6 +38,12 @@ public:
ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override;
private: private:
static const size_t MAX_CHIPNAME_LENGTH = 11;
static const int LINE_NOT_EXISTS = 0;
static const int LINE_ERROR = -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;
@@ -47,9 +54,15 @@ private:
* @param gpioId The GPIO ID of the GPIO to drive. * @param gpioId The GPIO ID of the GPIO to drive.
* @param logiclevel The logic level to set. O or 1. * @param logiclevel The logic level to set. O or 1.
*/ */
ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegular* regularGpio, unsigned int logiclevel); ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio,
gpio::Levels logicLevel);
ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegular* regularGpio); ReturnValue_t configureGpioByLabel(gpioId_t gpioId, GpiodRegularByLabel& gpioByLabel);
ReturnValue_t configureGpioByChip(gpioId_t gpioId, GpiodRegularByChip& gpioByChip);
ReturnValue_t configureGpioByLineName(gpioId_t gpioId,
GpiodRegularByLineName &gpioByLineName);
ReturnValue_t configureRegularGpio(gpioId_t gpioId, struct gpiod_chip* chip,
GpiodRegularBase& regularGpio, std::string failOutput);
/** /**
* @brief This function checks if GPIOs are already registered and whether * @brief This function checks if GPIOs are already registered and whether
@@ -62,7 +75,7 @@ private:
*/ */
ReturnValue_t checkForConflicts(GpioMap& mapToAdd); ReturnValue_t checkForConflicts(GpioMap& mapToAdd);
ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegularBase& regularGpio,
GpioMap& mapToAdd); GpioMap& mapToAdd);
ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio,
GpioMap& mapToAdd); GpioMap& mapToAdd);
@@ -72,6 +85,7 @@ private:
*/ */
ReturnValue_t configureGpios(GpioMap& mapToAdd); ReturnValue_t configureGpios(GpioMap& mapToAdd);
void parseFindeLineResult(int result, std::string& lineName);
}; };
#endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */ #endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */

View File

@@ -12,7 +12,7 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
GpiodRegular* config = new GpiodRegular(); auto config = new GpiodRegularByChip();
/* Default chipname for Raspberry Pi. There is still gpiochip1 for expansion, but most users /* Default chipname for Raspberry Pi. There is still gpiochip1 for expansion, but most users
will not need this */ will not need this */
config->chipname = "gpiochip0"; config->chipname = "gpiochip0";

View File

@@ -141,8 +141,8 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
if(sendLen > spiCookie->getMaxBufferSize()) { if(sendLen > spiCookie->getMaxBufferSize()) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "SpiComIF::sendMessage: Too much data sent, send length" << sendLen << sif::warning << "SpiComIF::sendMessage: Too much data sent, send length " << sendLen <<
"larger than maximum buffer length" << spiCookie->getMaxBufferSize() << std::endl; "larger than maximum buffer length " << spiCookie->getMaxBufferSize() << std::endl;
#else #else
sif::printWarning("SpiComIF::sendMessage: Too much data sent, send length %lu larger " sif::printWarning("SpiComIF::sendMessage: Too much data sent, send length %lu larger "
"than maximum buffer length %lu!\n", static_cast<unsigned long>(sendLen), "than maximum buffer length %lu!\n", static_cast<unsigned long>(sendLen),
@@ -197,12 +197,26 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
if(gpioId != gpio::NO_GPIO) { if(gpioId != gpio::NO_GPIO) {
result = spiMutex->lockMutex(timeoutType, timeoutMs); result = spiMutex->lockMutex(timeoutType, timeoutMs);
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
#else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex\n");
#endif
#endif
return result;
}
ReturnValue_t result = gpioComIF->pullLow(gpioId);
if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl;
#else
sif::printWarning("SpiComIF::sendMessage: Pulling low CS pin failed");
#endif
#endif #endif
return result; return result;
} }
gpioComIF->pullLow(gpioId);
} }
/* Execute transfer */ /* Execute transfer */
@@ -384,11 +398,11 @@ GpioIF* SpiComIF::getGpioInterface() {
void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) {
int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast<uint8_t*>(&mode)); int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast<uint8_t*>(&mode));
if(retval != 0) { if(retval != 0) {
utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI mode failed");
} }
retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
if(retval != 0) { if(retval != 0) {
utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI speed failed");
} }
} }

View File

@@ -7,7 +7,7 @@
/** /**
* @brief Base class to implement reconfiguration and failure handling for * @brief Base class to implement reconfiguration and failure handling for
* redundant devices by monitoring their modes health states. * redundant devices by monitoring their modes and health states.
* @details * @details
* Documentation: Dissertation Baetz p.156, 157. * Documentation: Dissertation Baetz p.156, 157.
* *

View File

@@ -334,8 +334,7 @@ protected:
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
* have been set. * have been set.
* - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can * - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can
* be used if no reply is expected. Otherwise, the developer can call #actionHelper.finish * be used if no reply is expected
* to finish the command handling.
* - Anything else triggers an event with the return code as a parameter as well as a * - Anything else triggers an event with the return code as a parameter as well as a
* step reply failed with the return code * step reply failed with the return code
*/ */

View File

@@ -7,14 +7,13 @@ PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider,
} }
bool PeriodicOperationDivider::checkAndIncrement() { bool PeriodicOperationDivider::checkAndIncrement() {
counter++;
bool opNecessary = check(); bool opNecessary = check();
if(opNecessary) { if(opNecessary) {
if(resetAutomatically) { if(resetAutomatically) {
counter = 1; resetCounter();
} }
return opNecessary;
} }
counter++;
return opNecessary; return opNecessary;
} }

View File

@@ -77,6 +77,7 @@ enum: uint8_t {
HAL_UART, //HURT HAL_UART, //HURT
HAL_I2C, //HI2C HAL_I2C, //HI2C
HAL_GPIO, //HGIO HAL_GPIO, //HGIO
FIXED_SLOT_TASK_IF, //FTIF
FW_CLASS_ID_COUNT // [EXPORT] : [END] FW_CLASS_ID_COUNT // [EXPORT] : [END]
}; };

View File

@@ -62,7 +62,8 @@ protected:
struct ChildInfo { struct ChildInfo {
MessageQueueId_t commandQueue; MessageQueueId_t commandQueue;
Mode_t mode; Mode_t mode;
Submode_t submode;bool healthChanged; Submode_t submode;
bool healthChanged;
}; };
Mode_t mode; Mode_t mode;

View File

@@ -1,4 +1,5 @@
#include "fsfw/tasks/FixedSlotSequence.h" #include "fsfw/tasks/FixedSlotSequence.h"
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include <cstdlib> #include <cstdlib>
@@ -92,10 +93,9 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs,
ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t FixedSlotSequence::checkSequence() const {
if(slotList.empty()) { if(slotList.empty()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedSlotSequence::checkSequence:" sif::warning << "FixedSlotSequence::checkSequence: Slot list is empty!" << std::endl;
<< " Slot list is empty!" << std::endl;
#endif #endif
return HasReturnvaluesIF::RETURN_FAILED; return FixedTimeslotTaskIF::SLOT_LIST_EMPTY;
} }
if(customCheckFunction != nullptr) { if(customCheckFunction != nullptr) {

View File

@@ -2,7 +2,7 @@
#define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ #define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_
#include "FixedSequenceSlot.h" #include "FixedSequenceSlot.h"
#include "../objectmanager/SystemObject.h" #include "fsfw/objectmanager/SystemObject.h"
#include <set> #include <set>
@@ -136,6 +136,7 @@ public:
* @details * @details
* Checks if timing is ok (must be ascending) and if all handlers were found. * Checks if timing is ok (must be ascending) and if all handlers were found.
* @return * @return
* - SLOT_LIST_EMPTY if the slot list is empty
*/ */
ReturnValue_t checkSequence() const; ReturnValue_t checkSequence() const;
@@ -147,6 +148,7 @@ public:
* The general check will be continued for now if the custom check function * The general check will be continued for now if the custom check function
* fails but a diagnostic debug output will be given. * fails but a diagnostic debug output will be given.
* @param customCheckFunction * @param customCheckFunction
*
*/ */
void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &)); void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &));

View File

@@ -2,7 +2,8 @@
#define FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_ #define FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_
#include "PeriodicTaskIF.h" #include "PeriodicTaskIF.h"
#include "../objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/returnvalues/FwClassIds.h"
/** /**
* @brief Following the same principle as the base class IF. * @brief Following the same principle as the base class IF.
@@ -12,6 +13,8 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF {
public: public:
virtual ~FixedTimeslotTaskIF() {} virtual ~FixedTimeslotTaskIF() {}
static constexpr ReturnValue_t SLOT_LIST_EMPTY = HasReturnvaluesIF::makeReturnCode(
CLASS_ID::FIXED_SLOT_TASK_IF, 0);
/** /**
* Add an object with a slot time and the execution step to the task. * Add an object with a slot time and the execution step to the task.
* The execution step will be passed to the object (e.g. as an operation * The execution step will be passed to the object (e.g. as an operation