Merge branch 'master' into gaisser_small_map_issues

This commit is contained in:
Steffen Gaisser 2020-09-29 14:14:48 +02:00
commit 291a62eeb9
3 changed files with 81 additions and 51 deletions

View File

@ -4,13 +4,13 @@
namespace objects { namespace objects {
enum framework_objects { enum framework_objects {
// Default verification reporter. // Default verification reporter.
PUS_SERVICE_1 = 0x53000001, PUS_SERVICE_1_VERIFICATION = 0x53000001,
PUS_SERVICE_2 = 0x53000002, PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002,
PUS_SERVICE_5 = 0x53000005, PUS_SERVICE_5_EVENT_REPORTING = 0x53000005,
PUS_SERVICE_8 = 0x53000008, PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
PUS_SERVICE_9 = 0x53000009, PUS_SERVICE_9_TIME_MGMT = 0x53000009,
PUS_SERVICE_17 = 0x53000017, PUS_SERVICE_17_TEST = 0x53000017,
PUS_SERVICE_200 = 0x53000200, PUS_SERVICE_200_MODE_MGMT = 0x53000200,
//Generic IDs for IPC, modes, health, events //Generic IDs for IPC, modes, health, events
HEALTH_TABLE = 0x53010000, HEALTH_TABLE = 0x53010000,

View File

@ -1,55 +1,59 @@
#include "../serviceinterface/ServiceInterfaceStream.h" #include "VerificationReporter.h"
#include "AcceptsVerifyMessageIF.h" #include "AcceptsVerifyMessageIF.h"
#include "PusVerificationReport.h" #include "PusVerificationReport.h"
#include "VerificationReporter.h"
object_id_t VerificationReporter::messageReceiver = 0; #include "../ipc/MessageQueueIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../objectmanager/frameworkObjects.h"
object_id_t VerificationReporter::messageReceiver =
objects::PUS_SERVICE_1_VERIFICATION;
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) {
if (this->acknowledgeQueue == 0) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize(); this->initialize();
} }
PusVerificationMessage message(set_report_id, PusVerificationMessage message(set_report_id,
current_packet->getAcknowledgeFlags(), current_packet->getAcknowledgeFlags(),
current_packet->getPacketId(), current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), 0, set_step); current_packet->getPacketSequenceControl(), 0, set_step);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error sif::error << "VerificationReporter::sendSuccessReport: Error writing "
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: " << "to queue. Code: " << std::hex << status << std::dec
<< (uint16_t) status << std::endl; << std::endl;
} }
} }
void VerificationReporter::sendSuccessReport(uint8_t set_report_id, void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
uint8_t set_step) { uint8_t set_step) {
if (this->acknowledgeQueue == 0) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize(); this->initialize();
} }
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, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
sif::error sif::error << "VerificationReporter::sendSuccessReport: Error writing "
<< "VerificationReporter::sendSuccessReport: Error writing to queue. Code: " << "to queue. Code: " << std::hex << status << std::dec
<< (uint16_t) status << std::endl; << std::endl;
} }
} }
void VerificationReporter::sendFailureReport(uint8_t report_id, void VerificationReporter::sendFailureReport(uint8_t report_id,
TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step, TcPacketBase* current_packet, ReturnValue_t error_code, uint8_t step,
uint32_t parameter1, uint32_t parameter2) { uint32_t parameter1, uint32_t parameter2) {
if (this->acknowledgeQueue == 0) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize(); this->initialize();
} }
PusVerificationMessage message(report_id, PusVerificationMessage message(report_id,
@ -57,11 +61,12 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
current_packet->getPacketId(), current_packet->getPacketId(),
current_packet->getPacketSequenceControl(), error_code, step, current_packet->getPacketSequenceControl(), error_code, step,
parameter1, parameter2); parameter1, parameter2);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&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 << "0x" << status << std::dec
<< (uint16_t) status << std::endl; << std::endl;
} }
} }
@ -69,27 +74,33 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
ReturnValue_t error_code, uint8_t step, uint32_t parameter1, ReturnValue_t error_code, uint8_t step, uint32_t parameter1,
uint32_t parameter2) { uint32_t parameter2) {
if (this->acknowledgeQueue == 0) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize(); this->initialize();
} }
PusVerificationMessage message(report_id, ackFlags, tcPacketId, PusVerificationMessage message(report_id, ackFlags, tcPacketId,
tcSequenceControl, error_code, step, parameter1, parameter2); tcSequenceControl, error_code, step, parameter1, parameter2);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
&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 << "0x" << 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." return;
<< std::endl;
} }
this->acknowledgeQueue = temp->getVerificationQueue();
} }

View File

@ -1,31 +1,50 @@
#ifndef VERIFICATIONREPORTER_H_ #ifndef FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_
#define VERIFICATIONREPORTER_H_ #define FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_
#include "../objectmanager/ObjectManagerIF.h"
#include "PusVerificationReport.h" #include "PusVerificationReport.h"
#include "../objectmanager/ObjectManagerIF.h"
namespace Factory{ 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 /* FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ */