A lot of new features and tweaks #12

Merged
muellerr merged 17 commits from mueller_framework into front_branch 2020-07-08 18:49:10 +02:00
5 changed files with 78 additions and 48 deletions
Showing only changes of commit 5ec78b065c - Show all commits

View File

@ -18,18 +18,14 @@ public:
static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack. static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack.
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF; static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
/** //! No new messages on the queue
* No new messages on the queue
*/
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1); static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1);
/** //! No space left for more messages
* No space left for more messages
*/
static const ReturnValue_t FULL = MAKE_RETURN_CODE(2); static const ReturnValue_t FULL = MAKE_RETURN_CODE(2);
/** //! Returned if a reply method was called without partner
* Returned if a reply method was called without partner
*/
static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3); static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3);
//! Returned if the target destination is invalid.
static constexpr ReturnValue_t DESTINVATION_INVALID = MAKE_RETURN_CODE(4);
virtual ~MessageQueueIF() {} virtual ~MessageQueueIF() {}
/** /**

View File

@ -3,6 +3,9 @@
namespace objects { namespace objects {
enum framework_objects { enum framework_objects {
// Default verification reporter.
PUS_SERVICE_1 = 0x53000000,
//Generic IDs for IPC, modes, health, events //Generic IDs for IPC, modes, health, events
HEALTH_TABLE = 0x53010000, HEALTH_TABLE = 0x53010000,
// MODE_STORE = 0x53010100, // MODE_STORE = 0x53010100,
@ -12,6 +15,7 @@ enum framework_objects {
//IDs for PUS Packet Communication //IDs for PUS Packet Communication
TC_STORE = 0x534f0100, TC_STORE = 0x534f0100,
TM_STORE = 0x534f0200, TM_STORE = 0x534f0200,
NO_OBJECT = 0xFFFFFFFF NO_OBJECT = 0xFFFFFFFF
}; };
} }

View File

@ -330,13 +330,16 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
//MQ_NONBLOCK flag was set in its attributes, and the //MQ_NONBLOCK flag was set in its attributes, and the
//specified queue is full. //specified queue is full.
return MessageQueueIF::FULL; return MessageQueueIF::FULL;
case EBADF: case EBADF: {
//mq_des doesn't represent a valid message queue descriptor, //mq_des doesn't represent a valid message queue descriptor,
//or mq_des wasn't opened for writing. //or mq_des wasn't opened for writing.
sif::error << "MessageQueue::sendMessage: Configuration error " sif::error << "MessageQueue::sendMessage: Configuration error, MQ"
<< strerror(errno) << " in mq_send mqSendTo: " << sendTo << " destination invalid." << std::endl;
<< " sent from " << sentFrom << std::endl; sif::error << strerror(errno) << " in "
/*NO BREAK*/ <<"mq_send to: " << sendTo << " sent from "
<< sentFrom << std::endl;
return DESTINVATION_INVALID;
}
case EINTR: case EINTR:
//The call was interrupted by a signal. //The call was interrupted by a signal.
case EINVAL: case EINVAL:

View File

@ -1,17 +1,18 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcservices/VerificationReporter.h> #include <framework/tmtcservices/VerificationReporter.h>
object_id_t VerificationReporter::messageReceiver = 0; #include <framework/ipc/MessageQueueIF.h>
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/objectmanager/frameworkObjects.h>
object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1;
VerificationReporter::VerificationReporter() : VerificationReporter::VerificationReporter() :
acknowledgeQueue() { acknowledgeQueue(MessageQueueIF::NO_QUEUE) {
} }
VerificationReporter::~VerificationReporter() { VerificationReporter::~VerificationReporter() {}
//Default, empty
}
void VerificationReporter::sendSuccessReport(uint8_t set_report_id, void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
TcPacketBase* current_packet, uint8_t set_step) { TcPacketBase* current_packet, uint8_t set_step) {
@ -23,10 +24,11 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
current_packet->getPacketId(), current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), 0, set_step); current_packet->getPacketSequenceControl(), 0, set_step);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message); &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error << "VerificationReporter::sendSuccessReport: Error writing " sif::error << "VerificationReporter::sendSuccessReport: Error writing "
"to queue. Code: " << std::hex << (uint16_t) status << std::endl; << "to queue. Code: " << std::hex << status << std::dec
<< std::endl;
} }
} }
@ -39,10 +41,11 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId, PusVerificationMessage message(set_report_id, ackFlags, tcPacketId,
tcSequenceControl, 0, set_step); tcSequenceControl, 0, set_step);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message); &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error << "VerificationReporter::sendSuccessReport: Error writing " sif::error << "VerificationReporter::sendSuccessReport: Error writing "
"to queue. Code: " << std::hex << (uint16_t) status << std::endl; << "to queue. Code: " << std::hex << status << std::dec
<< std::endl;
} }
} }
@ -60,9 +63,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message); &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error sif::error << "VerificationReporter::sendFailureReport Error writing "
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: " << "to queue. Code: " << std::hex << status << std::dec
<< (uint16_t) status << std::endl; << std::endl;
} }
} }
@ -78,20 +81,25 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message); &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error sif::error << "VerificationReporter::sendFailureReport Error writing "
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: " << "to queue. Code: " << std::hex << status << std::dec
<< (uint16_t) status << std::endl; << std::endl;
} }
} }
void VerificationReporter::initialize() { void VerificationReporter::initialize() {
if(messageReceiver == objects::NO_OBJECT) {
sif::warning << "VerificationReporter::initialize: Verification message"
" receiver object ID not set yet in Factory!" << std::endl;
return;
}
AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>( AcceptsVerifyMessageIF* temp = objectManager->get<AcceptsVerifyMessageIF>(
messageReceiver); messageReceiver);
if (temp != NULL) { if (temp == nullptr) {
this->acknowledgeQueue = temp->getVerificationQueue(); sif::error << "VerificationReporter::initialize: Message "
} else { << "receiver invalid. Make sure it is set up properly and "
sif::error <<"implementsAcceptsVerifyMessageIF" << std::endl;
<< "VerificationReporter::VerificationReporter: Configuration error."
<< std::endl;
} }
this->acknowledgeQueue = temp->getVerificationQueue();
} }

View File

@ -1,5 +1,5 @@
#ifndef VERIFICATIONREPORTER_H_ #ifndef FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_
#define VERIFICATIONREPORTER_H_ #define FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_
#include <framework/objectmanager/ObjectManagerIF.h> #include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/tmtcservices/PusVerificationReport.h> #include <framework/tmtcservices/PusVerificationReport.h>
@ -8,24 +8,43 @@ namespace Factory{
void setStaticFrameworkObjectIds(); void setStaticFrameworkObjectIds();
} }
/**
* @brief This helper object is used to forward verification messages
* which are generated by the Flight Software Framework.
* @details
* The messages can be relayed to an arbitrary object, for example a dedicated
* Verification Reporter. The destination is set by setting the static framework
* Id VerificationReporter::messageReceiver. The default verification reporter
* will be the PUS service 1, which sends verification messages according
* to the PUS standard.
*
*/
class VerificationReporter { class VerificationReporter {
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
VerificationReporter(); VerificationReporter();
virtual ~VerificationReporter(); virtual ~VerificationReporter();
void sendSuccessReport( uint8_t set_report_id, TcPacketBase* current_packet, uint8_t set_step = 0 );
void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t set_step = 0); void sendSuccessReport( uint8_t set_report_id, TcPacketBase* current_packet,
void sendFailureReport( uint8_t report_id, TcPacketBase* current_packet, ReturnValue_t error_code = 0, uint8_t set_step = 0 );
uint8_t step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0 ); void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags,
uint16_t tcPacketId, uint16_t tcSequenceControl,
uint8_t set_step = 0);
void sendFailureReport( uint8_t report_id, TcPacketBase* current_packet,
ReturnValue_t error_code = 0,
uint8_t step = 0, uint32_t parameter1 = 0,
uint32_t parameter2 = 0 );
void sendFailureReport(uint8_t report_id, void sendFailureReport(uint8_t report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, ReturnValue_t error_code = 0, uint8_t step = 0, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
ReturnValue_t error_code = 0, uint8_t step = 0,
uint32_t parameter1 = 0, uint32_t parameter2 = 0); uint32_t parameter1 = 0, uint32_t parameter2 = 0);
void initialize(); void initialize();
private: private:
static object_id_t messageReceiver; static object_id_t messageReceiver;
MessageQueueId_t acknowledgeQueue; MessageQueueId_t acknowledgeQueue;
}; };
#endif /* VERIFICATIONREPORTER_H_ */ #endif /* FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_ */