2020-09-29 13:34:27 +02:00
|
|
|
#include "VerificationReporter.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "AcceptsVerifyMessageIF.h"
|
|
|
|
#include "PusVerificationReport.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2021-06-05 19:52:38 +02:00
|
|
|
#include "../objectmanager/ObjectManager.h"
|
2020-09-29 13:34:27 +02:00
|
|
|
#include "../ipc/MessageQueueIF.h"
|
2021-06-05 19:52:38 +02:00
|
|
|
#include "../serviceinterface/ServiceInterface.h"
|
2020-09-29 13:34:27 +02:00
|
|
|
#include "../objectmanager/frameworkObjects.h"
|
|
|
|
|
|
|
|
object_id_t VerificationReporter::messageReceiver =
|
|
|
|
objects::PUS_SERVICE_1_VERIFICATION;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
VerificationReporter::VerificationReporter() :
|
2020-09-29 13:34:27 +02:00
|
|
|
acknowledgeQueue(MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 13:34:27 +02:00
|
|
|
VerificationReporter::~VerificationReporter() {}
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
2021-06-13 16:29:13 +02:00
|
|
|
TcPacketBase* currentPacket, uint8_t set_step) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2021-06-13 16:29:13 +02:00
|
|
|
if(currentPacket == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(set_report_id,
|
2021-06-13 16:29:13 +02:00
|
|
|
currentPacket->getAcknowledgeFlags(),
|
|
|
|
currentPacket->getPacketId(),
|
|
|
|
currentPacket->getPacketSequenceControl(), 0, set_step);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << status << std::dec
|
|
|
|
<< std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
2018-07-12 16:29:32 +02:00
|
|
|
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
|
|
|
|
uint8_t set_step) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(set_report_id, ackFlags, tcPacketId,
|
|
|
|
tcSequenceControl, 0, set_step);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendSuccessReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << status << std::dec
|
|
|
|
<< std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
2021-06-13 16:29:13 +02:00
|
|
|
TcPacketBase* currentPacket, ReturnValue_t error_code, uint8_t step,
|
2016-06-15 23:48:41 +02:00
|
|
|
uint32_t parameter1, uint32_t parameter2) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2021-06-13 16:29:13 +02:00
|
|
|
if(currentPacket == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(report_id,
|
2021-06-13 16:29:13 +02:00
|
|
|
currentPacket->getAcknowledgeFlags(),
|
|
|
|
currentPacket->getPacketId(),
|
|
|
|
currentPacket->getPacketSequenceControl(), error_code, step,
|
2016-06-15 23:48:41 +02:00
|
|
|
parameter1, parameter2);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendFailureReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << "0x" << status << std::dec
|
|
|
|
<< std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
2018-07-12 16:29:32 +02:00
|
|
|
uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl,
|
|
|
|
ReturnValue_t error_code, uint8_t step, uint32_t parameter1,
|
|
|
|
uint32_t parameter2) {
|
2020-09-29 13:34:27 +02:00
|
|
|
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
2016-06-15 23:48:41 +02:00
|
|
|
this->initialize();
|
|
|
|
}
|
2018-07-12 16:29:32 +02:00
|
|
|
PusVerificationMessage message(report_id, ackFlags, tcPacketId,
|
|
|
|
tcSequenceControl, error_code, step, parameter1, parameter2);
|
2020-09-29 13:34:27 +02:00
|
|
|
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
|
|
|
&message);
|
2018-07-12 16:29:32 +02:00
|
|
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::sendFailureReport: Error writing "
|
|
|
|
<< "to queue. Code: " << std::hex << "0x" << status << std::dec
|
|
|
|
<< std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerificationReporter::initialize() {
|
2020-09-29 13:34:27 +02:00
|
|
|
if(messageReceiver == objects::NO_OBJECT) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::warning << "VerificationReporter::initialize: Verification message"
|
|
|
|
" receiver object ID not set yet in Factory!" << std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2020-09-29 13:34:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-06-05 19:52:38 +02:00
|
|
|
AcceptsVerifyMessageIF* temp = ObjectManager::instance()->get<AcceptsVerifyMessageIF>(
|
2018-07-12 16:29:32 +02:00
|
|
|
messageReceiver);
|
2020-09-29 13:34:27 +02:00
|
|
|
if (temp == nullptr) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-09-29 13:34:27 +02:00
|
|
|
sif::error << "VerificationReporter::initialize: Message "
|
|
|
|
<< "receiver invalid. Make sure it is set up properly and "
|
|
|
|
<< "implementsAcceptsVerifyMessageIF" << std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2020-09-29 13:34:27 +02:00
|
|
|
return;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
2020-09-29 13:34:27 +02:00
|
|
|
this->acknowledgeQueue = temp->getVerificationQueue();
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|