Merge branch 'mueller_framework' into front_branch

This commit is contained in:
Robin Müller 2020-06-30 16:41:38 +02:00
commit 062ebabb9a
18 changed files with 114 additions and 67 deletions

View File

@ -105,18 +105,18 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
} }
// and now we set a HK message and send it the HK packet destination. // and now we set a HK message and send it the HK packet destination.
//HousekeepingMessage hkMessage; CommandMessage hkMessage;
// hkMessage.setHkReportMessage(sid, storeId); HousekeepingMessage::setHkReportMessage(&hkMessage, sid, storeId);
// if(hkQueue == nullptr) { if(hkQueue == nullptr) {
// return QUEUE_NOT_SET; return QUEUE_NOT_SET;
// } }
//
// if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) { if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
// result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage); result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
// } }
// else { else {
// result = hkQueue->sendToDefault(&hkMessage); result = hkQueue->sendToDefault(&hkMessage);
// } }
return result; return result;
} }

View File

@ -42,7 +42,7 @@ ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer,
if(registeredVariables[count]->isValid()) { if(registeredVariables[count]->isValid()) {
// set validity buffer here. // set validity buffer here.
this->bitSetter(validityMask + validBufferIndex, this->bitSetter(validityMask + validBufferIndex,
validBufferIndexBit, true); validBufferIndexBit);
if(validBufferIndexBit == 7) { if(validBufferIndexBit == 7) {
validBufferIndex ++; validBufferIndex ++;
validBufferIndexBit = 0; validBufferIndexBit = 0;
@ -83,13 +83,12 @@ ReturnValue_t LocalDataSet::serializeLocalPoolIds(uint8_t** buffer,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void LocalDataSet::bitSetter(uint8_t* byte, uint8_t position, void LocalDataSet::bitSetter(uint8_t* byte, uint8_t position) const {
bool value) const {
if(position > 7) { if(position > 7) {
sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl;
return; return;
} }
uint8_t shiftNumber = position + (7 - 2 * position); uint8_t shiftNumber = position + (7 - 2 * position);
*byte |= 1UL << shiftNumber; *byte |= 1 << shiftNumber;
} }

View File

@ -98,14 +98,10 @@ private:
LocalDataPoolManager* hkManager; LocalDataPoolManager* hkManager;
/** /**
* Sets the bit at the bit-position of a byte provided by its address * Set n-th bit of a byte, with n being the position from 0
* to the specified value (zero or one). * (most significant bit) to 7 (least significant bit)
* @param byte Pointer to byte to bitset.
* @param position MSB first, 0 to 7 possible.
* @param value Value to set.
* @return
*/ */
void bitSetter(uint8_t* byte, uint8_t position, bool value) const; void bitSetter(uint8_t* byte, uint8_t position) const;
}; };
#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */ #endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */

View File

@ -1374,6 +1374,15 @@ ReturnValue_t DeviceHandlerBase::changeCollectionInterval(sid_t sid,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
// In this function, the task handle should be valid if the task
// was implemented correctly. We still check to be 1000 % sure :-)
if(executingTask != nullptr) {
pstIntervalMs = executingTask->getPeriodMs();
}
return HasReturnvaluesIF::RETURN_OK;
}
DataSetIF* DeviceHandlerBase::getDataSetHandle(sid_t sid) { DataSetIF* DeviceHandlerBase::getDataSetHandle(sid_t sid) {
auto iter = deviceReplyMap.find(sid.ownerSetId); auto iter = deviceReplyMap.find(sid.ownerSetId);
if(iter != deviceReplyMap.end()) { if(iter != deviceReplyMap.end()) {

View File

@ -11,6 +11,8 @@
#include <framework/modes/HasModesIF.h> #include <framework/modes/HasModesIF.h>
#include <framework/power/PowerSwitchIF.h> #include <framework/power/PowerSwitchIF.h>
#include <framework/ipc/MessageQueueIF.h> #include <framework/ipc/MessageQueueIF.h>
#include <framework/tasks/PeriodicTaskIF.h>
#include <framework/action/ActionHelper.h> #include <framework/action/ActionHelper.h>
#include <framework/health/HealthHelper.h> #include <framework/health/HealthHelper.h>
#include <framework/parameters/ParameterHelper.h> #include <framework/parameters/ParameterHelper.h>
@ -18,6 +20,7 @@
#include <framework/datapoollocal/LocalDataPoolManager.h> #include <framework/datapoollocal/LocalDataPoolManager.h>
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h> #include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
#include <framework/datapoollocal/OwnsLocalDataPoolIF.h> #include <framework/datapoollocal/OwnsLocalDataPoolIF.h>
#include <map> #include <map>
namespace Factory{ namespace Factory{
@ -563,6 +566,8 @@ protected:
/** This is the counter value from performOperation(). */ /** This is the counter value from performOperation(). */
uint8_t pstStep = 0; uint8_t pstStep = 0;
uint32_t pstIntervalMs = 0;
/** /**
* Wiretapping flag: * Wiretapping flag:
* *
@ -1196,9 +1201,11 @@ private:
ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message);
void parseReply(const uint8_t* receivedData, virtual ReturnValue_t initializeAfterTaskCreation() override;
size_t receivedDataLen);
DataSetIF* getDataSetHandle(sid_t sid) override; DataSetIF* getDataSetHandle(sid_t sid) override;
void parseReply(const uint8_t* receivedData,
size_t receivedDataLen);
}; };
#endif /* DEVICEHANDLERBASE_H_ */ #endif /* DEVICEHANDLERBASE_H_ */

View File

@ -68,6 +68,10 @@ size_t CommandMessage::getMinimumMessageSize() const {
return MINIMUM_COMMAND_MESSAGE_SIZE; return MINIMUM_COMMAND_MESSAGE_SIZE;
} }
void CommandMessage::clearCommandMessage() {
clear();
}
void CommandMessage::clear() { void CommandMessage::clear() {
CommandMessageCleaner::clearCommandMessage(this); CommandMessageCleaner::clearCommandMessage(this);
} }
@ -84,18 +88,15 @@ void CommandMessage::setToUnknownCommand() {
void CommandMessage::setReplyRejected(ReturnValue_t reason, void CommandMessage::setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) { Command_t initialCommand) {
std::memcpy(getData(), &reason, sizeof(reason)); setParameter(reason);
std::memcpy(getData() + sizeof(reason), &initialCommand, setParameter2(initialCommand);
sizeof(initialCommand));
} }
ReturnValue_t CommandMessage::getReplyRejectedReason( ReturnValue_t CommandMessage::getReplyRejectedReason(
Command_t *initialCommand) const { Command_t *initialCommand) const {
ReturnValue_t reason = HasReturnvaluesIF::RETURN_FAILED; ReturnValue_t reason = getParameter();
std::memcpy(&reason, getData(), sizeof(reason));
if(initialCommand != nullptr) { if(initialCommand != nullptr) {
std::memcpy(initialCommand, getData() + sizeof(reason), *initialCommand = getParameter2();
sizeof(Command_t));
} }
return reason; return reason;
} }

View File

@ -111,7 +111,9 @@ public:
ReturnValue_t getReplyRejectedReason( ReturnValue_t getReplyRejectedReason(
Command_t* initialCommand = nullptr) const override; Command_t* initialCommand = nullptr) const override;
virtual void clear() override; virtual void clear() override;
void clearCommandMessage();
/** /**
* Extract message ID, which is the first byte of the command ID for the * Extract message ID, which is the first byte of the command ID for the

View File

@ -94,7 +94,8 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object, bool setTaskIF) {
if(setTaskIF) { if(setTaskIF) {
newObject->setTaskIF(this); newObject->setTaskIF(this);
} }
return HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = newObject->initializeAfterTaskCreation();
return result;
} }
uint32_t PeriodicTask::getPeriodMs() const { uint32_t PeriodicTask::getPeriodMs() const {

View File

@ -92,7 +92,7 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
void FixedTimeslotTask::taskFunctionality() { void FixedTimeslotTask::taskFunctionality() {
// A local iterator for the Polling Sequence Table is created to // A local iterator for the Polling Sequence Table is created to
// find the start time for the first entry. // find the start time for the first entry.
SlotListIter slotListIter = pollingSeqTable.current; FixedSlotSequence::SlotListIter slotListIter = pollingSeqTable.current;
// Get start time for first entry. // Get start time for first entry.
chron_ms interval(slotListIter->pollingTimeMs); chron_ms interval(slotListIter->pollingTimeMs);
auto currentStartTime { auto currentStartTime {

View File

@ -36,7 +36,7 @@ public:
private: private:
//! External instantiation is forbidden. //! External instantiation is forbidden.
QueueMapManager(); QueueMapManager();
std::atomic<uint32_t> queueCounter = MessageQueueIF::NO_QUEUE + 1; std::atomic<uint32_t> queueCounter = 1;
MutexIF* mapLock; MutexIF* mapLock;
QueueMap queueMap; QueueMap queueMap;
static QueueMapManager* mqManagerInstance; static QueueMapManager* mqManagerInstance;

View File

@ -36,7 +36,9 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object,
if(setTaskIF) { if(setTaskIF) {
newObject->setTaskIF(this); newObject->setTaskIF(this);
} }
return HasReturnvaluesIF::RETURN_OK;
ReturnValue_t result = newObject->initializeAfterTaskCreation();
return result;
} }
ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {

View File

@ -78,7 +78,8 @@ ReturnValue_t MultiObjectTask::addComponent(object_id_t object) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
objectList.push_back(newObject); objectList.push_back(newObject);
return HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = newObject->initializeAfterTaskCreation();
return result;
} }
uint32_t MultiObjectTask::getPeriodMs() const { uint32_t MultiObjectTask::getPeriodMs() const {

View File

@ -1,15 +1,5 @@
/** #ifndef FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_
* @file ExecutableObjectIF.h #define FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_
*
* @brief This file contains the definition for the ExecutableObjectIF interface.
*
* @author Bastian Baetz
*
* @date 12.03.2012
*/
#ifndef EXECUTABLEOBJECTIF_H_
#define EXECUTABLEOBJECTIF_H_
class PeriodicTaskIF; class PeriodicTaskIF;
@ -20,6 +10,7 @@ class PeriodicTaskIF;
* @brief The interface provides a method to execute objects within a task. * @brief The interface provides a method to execute objects within a task.
* @details The performOperation method, that is required by the interface is * @details The performOperation method, that is required by the interface is
* executed cyclically within a task context. * executed cyclically within a task context.
* @author Bastian Baetz
*/ */
class ExecutableObjectIF { class ExecutableObjectIF {
public: public:
@ -43,9 +34,20 @@ public:
* a reference to the executing task * a reference to the executing task
* @param task_ Pointer to the taskIF of this task * @param task_ Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task_) { virtual void setTaskIF(PeriodicTaskIF* task_) {};
/**
* This function should be called after the object was assigned to a
* specific task.
*
* Example: Can be used to get task execution frequency.
* The task is created after initialize() and the object ctors have been
* called so the execution frequency can't be cached in initialize()
* @return
*/
virtual ReturnValue_t initializeAfterTaskCreation() {
return HasReturnvaluesIF::RETURN_OK;
} }
}; };
#endif /* EXECUTABLEOBJECTIF_H_ */ #endif /* FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_ */

View File

@ -9,6 +9,7 @@ FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime,
if(executingTask != nullptr) { if(executingTask != nullptr) {
handler->setTaskIF(executingTask); handler->setTaskIF(executingTask);
} }
handler->initializeAfterTaskCreation();
} }
FixedSequenceSlot::~FixedSequenceSlot() {} FixedSequenceSlot::~FixedSequenceSlot() {}

View File

@ -57,7 +57,9 @@ ReturnValue_t CommandingServiceBase::initialize() {
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>( PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
packetSource); packetSource);
if (packetForwarding == nullptr or distributor == nullptr) { if (packetForwarding == nullptr or distributor == nullptr) {
return RETURN_FAILED; sif::error << "CommandingServiceBase::intialize: Packet source or "
"packet destination invalid!" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
} }
distributor->registerService(this); distributor->registerService(this);
@ -68,7 +70,9 @@ ReturnValue_t CommandingServiceBase::initialize() {
TCStore = objectManager->get<StorageManagerIF>(objects::TC_STORE); TCStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
if (IPCStore == nullptr or TCStore == nullptr) { if (IPCStore == nullptr or TCStore == nullptr) {
return RETURN_FAILED; sif::error << "CommandingServiceBase::intialize: IPC store or TC store "
"not initialized yet!" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
} }
return RETURN_OK; return RETURN_OK;
@ -109,8 +113,8 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
* command as failure parameter 1 */ * command as failure parameter 1 */
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and if(reply->getCommand() == CommandMessage::REPLY_REJECTED and
result == RETURN_FAILED) { result == RETURN_FAILED) {
result = reply->getReplyRejectedReason( result = reply->getReplyRejectedReason();
reinterpret_cast<Command_t*>(&failureParameter1)); failureParameter1 = iter->command;
} }
switch (result) { switch (result) {
@ -176,14 +180,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
} }
else { else {
if (isStep) { if (isStep) {
nextCommand->clear(); nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags, TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
iter->tcInfo.tcPacketId, iter->tcInfo.tcPacketId,
iter->tcInfo.tcSequenceControl, sendResult, iter->tcInfo.tcSequenceControl, sendResult,
++iter->step, failureParameter1, failureParameter2); ++iter->step, failureParameter1, failureParameter2);
} else { } else {
nextCommand->clear(); nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, TC_VERIFY::COMPLETION_FAILURE,
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId, iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
@ -318,7 +322,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
storedPacket->getPacketSequenceControl(); storedPacket->getPacketSequenceControl();
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket); acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
} else { } else {
command.clear(); command.clearCommandMessage();
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} }
@ -335,7 +339,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket); acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} else { } else {
command.clear(); command.clearCommandMessage();
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} }
@ -374,7 +378,7 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) { void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
reply->clear(); reply->clearCommandMessage();
} }

View File

@ -276,7 +276,6 @@ protected:
void checkAndExecuteFifo(CommandMapIter iter); void checkAndExecuteFifo(CommandMapIter iter);
private: private:
/** /**
* This method handles internal execution of a command, * This method handles internal execution of a command,
* once it has been started by @sa{startExecution()} in the request * once it has been started by @sa{startExecution()} in the request
@ -296,10 +295,13 @@ private:
void handleCommandQueue(); void handleCommandQueue();
/** /**
* @brief Handler function for request queue
* @details
* Sequence of request queue handling: * Sequence of request queue handling:
* isValidSubservice -> getMessageQueueAndObject -> startExecution * isValidSubservice -> getMessageQueueAndObject -> startExecution
* Generates Start Success Reports TM[1,3] in subfunction @sa{startExecution()} * Generates a Start Success Reports TM[1,3] in subfunction
* or Start Failure Report TM[1,4] by using the TC Verification Service * @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
* TC Verification Service.
*/ */
void handleRequestQueue(); void handleRequestQueue();

View File

@ -32,6 +32,10 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
return RETURN_OK; return RETURN_OK;
} }
void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) {
this->taskHandle = taskHandle;
}
void PusServiceBase::handleRequestQueue() { void PusServiceBase::handleRequestQueue() {
TmTcMessage message; TmTcMessage message;
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
@ -108,3 +112,10 @@ ReturnValue_t PusServiceBase::initialize() {
return RETURN_FAILED; return RETURN_FAILED;
} }
} }
ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {
// If task parameters, for example task frequency are required, this
// function should be overriden and the system object task IF can
// be used to get those parameters.
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -96,11 +96,20 @@ public:
* @return @c RETURN_OK if the periodic performService was successful. * @return @c RETURN_OK if the periodic performService was successful.
* @c RETURN_FAILED else. * @c RETURN_FAILED else.
*/ */
ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t performOperation(uint8_t opCode) override;
virtual uint16_t getIdentifier(); virtual uint16_t getIdentifier() override;
MessageQueueId_t getRequestQueue(); MessageQueueId_t getRequestQueue() override;
virtual ReturnValue_t initialize(); virtual ReturnValue_t initialize() override;
virtual void setTaskIF(PeriodicTaskIF* taskHandle) override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
protected: protected:
/**
* @brief Handle to the underlying task
* @details
* Will be set by setTaskIF(), which is called on task creation.
*/
PeriodicTaskIF* taskHandle = nullptr;
/** /**
* The APID of this instance of the Service. * The APID of this instance of the Service.
*/ */