v1.12.0 #269

Merged
muellerr merged 493 commits from develop into main 2022-07-04 11:19:05 +02:00
6 changed files with 169 additions and 146 deletions
Showing only changes of commit d0e18f8b35 - Show all commits

View File

@ -7,9 +7,9 @@
#include <objects/systemObjectList.h> #include <objects/systemObjectList.h>
#include <tmtc/apid.h> #include <tmtc/apid.h>
#include <tmtc/pusIds.h> #include <tmtc/pusIds.h>
#include "fsfw_tests/integration/task/TestTask.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "fsfw_tests/integration/task/TestTask.h"
#if OBSW_USE_TMTC_TCP_BRIDGE == 0 #if OBSW_USE_TMTC_TCP_BRIDGE == 0
#include "fsfw/osal/common/UdpTcPollingTask.h" #include "fsfw/osal/common/UdpTcPollingTask.h"

View File

@ -273,7 +273,7 @@ void Q7STestTask::testGpsDaemonShm() {
} }
void Q7STestTask::testGpsDaemonSocket() { void Q7STestTask::testGpsDaemonSocket() {
if(gpsmmShmPtr == nullptr) { if (gpsmmShmPtr == nullptr) {
gpsmmShmPtr = new gpsmm("localhost", DEFAULT_GPSD_PORT); gpsmmShmPtr = new gpsmm("localhost", DEFAULT_GPSD_PORT);
} }
// The data from the device will generally be read all at once. Therefore, we // The data from the device will generally be read all at once. Therefore, we
@ -291,17 +291,16 @@ void Q7STestTask::testGpsDaemonSocket() {
return; return;
} }
// Stopwatch watch; // Stopwatch watch;
gps_data_t *gps = nullptr; gps_data_t* gps = nullptr;
gpsmmShmPtr->stream(WATCH_ENABLE | WATCH_JSON); gpsmmShmPtr->stream(WATCH_ENABLE | WATCH_JSON);
if(not gpsmmShmPtr->waiting(50000000)) { if (not gpsmmShmPtr->waiting(50000000)) {
return; return;
} }
gps = gpsmmShmPtr->read(); gps = gpsmmShmPtr->read();
if (gps == nullptr) { if (gps == nullptr) {
if (gpsReadFailedSwitch) { if (gpsReadFailedSwitch) {
gpsReadFailedSwitch = false; gpsReadFailedSwitch = false;
sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed" sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed" << std::endl;
<< std::endl;
} }
return; return;
} }

View File

@ -2,6 +2,7 @@
#define BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ #define BSP_Q7S_BOARDTEST_Q7STESTTASK_H_
#include <libgpsmm.h> #include <libgpsmm.h>
#include "test/testtasks/TestTask.h" #include "test/testtasks/TestTask.h"
class CoreController; class CoreController;

View File

@ -29,8 +29,8 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() {
sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} else { } else {
sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << static_cast<int>(gpioState) sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = "
<< std::endl; << static_cast<int>(gpioState) << std::endl;
} }
break; break;
} }

View File

@ -29,6 +29,10 @@ HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, H
if (mainLineSwitcher == nullptr) { if (mainLineSwitcher == nullptr) {
throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF"); throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF");
} }
heaterMutex = MutexFactory::instance()->createMutex();
if (heaterMutex == nullptr) {
throw std::runtime_error("HeaterHandler::HeaterHandler: Creating Mutex failed");
}
auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this)); auto mqArgs = MqArgs(setObjectId_, static_cast<void*>(this));
commandQueue = QueueFactory::instance()->createMessageQueue( commandQueue = QueueFactory::instance()->createMessageQueue(
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
@ -43,9 +47,14 @@ ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) {
for (const auto& heater : helper.heaters) { for (const auto& heater : helper.heaters) {
heater.first->performOperation(0); heater.first->performOperation(0);
} }
} catch(const std::out_of_range& e) { for (const auto& heater : heaterVec) {
sif::info << heater.switchState << ",";
}
sif::info << std::endl;
} catch (const std::out_of_range& e) {
sif::warning << "HeaterHandler::performOperation: " sif::warning << "HeaterHandler::performOperation: "
"Out of range error | " << e.what() << std::endl; "Out of range error | "
<< e.what() << std::endl;
} }
return RETURN_OK; return RETURN_OK;
} }
@ -77,13 +86,7 @@ ReturnValue_t HeaterHandler::initialize() {
ReturnValue_t HeaterHandler::initializeHeaterMap() { ReturnValue_t HeaterHandler::initializeHeaterMap() {
for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) { for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) {
gpio::Levels level; heaterVec.push_back(HeaterWrapper(helper.heaters[switchNr], SwitchState::OFF));
gpioInterface->readGpio(helper.heaters[switchNr].second, level);
SwitchState initState = SwitchState::OFF;
if(level == gpio::Levels::HIGH) {
}
heaterVec.push_back(HeaterWrapper(helper.heaters[switchNr], initState));
} }
return RETURN_OK; return RETURN_OK;
} }
@ -208,7 +211,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) {
// Check state of main line switch // Check state of main line switch
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { if (mainSwitchState == PowerSwitchIF::SWITCH_ON) {
if (checkSwitchState(heaterIdx) == SwitchState::ON) { if (checkSwitchState(heaterIdx) == SwitchState::OFF) {
gpioId_t gpioId = heater.gpioId; gpioId_t gpioId = heater.gpioId;
result = gpioInterface->pullHigh(gpioId); result = gpioInterface->pullHigh(gpioId);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -262,7 +265,11 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
<< " low" << std::endl; << " low" << std::endl;
triggerEvent(GPIO_PULL_LOW_FAILED, result); triggerEvent(GPIO_PULL_LOW_FAILED, result);
} else { } else {
auto result = heaterMutex->lockMutex();
heater.switchState = OFF; heater.switchState = OFF;
if (result == HasReturnvaluesIF::RETURN_OK) {
heaterMutex->unlockMutex();
}
triggerEvent(HEATER_WENT_OFF, heaterIdx, 0); triggerEvent(HEATER_WENT_OFF, heaterIdx, 0);
// When all switches are off, also main line switch will be turned off // When all switches are off, also main line switch will be turned off
if (allSwitchesOff()) { if (allSwitchesOff()) {
@ -284,12 +291,14 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) {
heater.active = false; heater.active = false;
} }
HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) { HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) const {
MutexGuard mg(heaterMutex);
return heaterVec.at(switchNr).switchState; return heaterVec.at(switchNr).switchState;
} }
bool HeaterHandler::allSwitchesOff() { bool HeaterHandler::allSwitchesOff() {
bool allSwitchesOrd = false; bool allSwitchesOrd = false;
MutexGuard mg(heaterMutex);
/* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */
for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) { for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) {
allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState; allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState;
@ -301,7 +310,19 @@ MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->g
ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; } ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; }
ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const {
ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch);
if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) {
return PowerSwitchIF::SWITCH_OFF;
}
if (switchNr > 7) {
return PowerSwitchIF::RETURN_FAILED;
}
if (checkSwitchState(static_cast<heater::Switchers>(switchNr)) == SwitchState::ON) {
return PowerSwitchIF::SWITCH_ON;
}
return PowerSwitchIF::SWITCH_OFF;
}
ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; }

View File

@ -54,22 +54,22 @@ class HeaterHandler : public ExecutableObjectIF,
virtual ~HeaterHandler(); virtual ~HeaterHandler();
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
/** /**
* @brief This function will be called from the Heater object to check * @brief This function will be called from the Heater object to check
* the current switch state. * the current switch state.
*/ */
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; ReturnValue_t getSwitchState(uint8_t switchNr) const override;
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; ReturnValue_t getFuseState(uint8_t fuseNr) const override;
virtual uint32_t getSwitchDelayMs(void) const override; uint32_t getSwitchDelayMs(void) const override;
virtual MessageQueueId_t getCommandQueue() const override; MessageQueueId_t getCommandQueue() const override;
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override; const uint8_t* data, size_t size) override;
virtual ReturnValue_t initialize() override; ReturnValue_t initialize() override;
private: private:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER;
@ -113,6 +113,8 @@ class HeaterHandler : public ExecutableObjectIF,
HeaterMap heaterVec = {}; HeaterMap heaterVec = {};
MutexIF* heaterMutex = nullptr;
HeaterHelper helper; HeaterHelper helper;
/** Size of command queue */ /** Size of command queue */
@ -141,7 +143,7 @@ class HeaterHandler : public ExecutableObjectIF,
* @brief Returns the state of a switch (ON - true, or OFF - false). * @brief Returns the state of a switch (ON - true, or OFF - false).
* @param switchNr The number of the switch to check. * @param switchNr The number of the switch to check.
*/ */
SwitchState checkSwitchState(heater::Switchers switchNr); SwitchState checkSwitchState(heater::Switchers switchNr) const;
/** /**
* @brief This function runs commands waiting for execution. * @brief This function runs commands waiting for execution.