error handling for invalid dest queues improved
This commit is contained in:
parent
b56aa94f99
commit
5ec78b065c
@ -18,18 +18,14 @@ public:
|
||||
static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack.
|
||||
|
||||
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);
|
||||
/**
|
||||
* No space left for more messages
|
||||
*/
|
||||
//! No space left for more messages
|
||||
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);
|
||||
//! Returned if the target destination is invalid.
|
||||
static constexpr ReturnValue_t DESTINVATION_INVALID = MAKE_RETURN_CODE(4);
|
||||
|
||||
virtual ~MessageQueueIF() {}
|
||||
/**
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
namespace objects {
|
||||
enum framework_objects {
|
||||
// Default verification reporter.
|
||||
PUS_SERVICE_1 = 0x53000000,
|
||||
|
||||
//Generic IDs for IPC, modes, health, events
|
||||
HEALTH_TABLE = 0x53010000,
|
||||
// MODE_STORE = 0x53010100,
|
||||
@ -12,6 +15,7 @@ enum framework_objects {
|
||||
//IDs for PUS Packet Communication
|
||||
TC_STORE = 0x534f0100,
|
||||
TM_STORE = 0x534f0200,
|
||||
|
||||
NO_OBJECT = 0xFFFFFFFF
|
||||
};
|
||||
}
|
||||
|
@ -330,13 +330,16 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
//MQ_NONBLOCK flag was set in its attributes, and the
|
||||
//specified queue is full.
|
||||
return MessageQueueIF::FULL;
|
||||
case EBADF:
|
||||
case EBADF: {
|
||||
//mq_des doesn't represent a valid message queue descriptor,
|
||||
//or mq_des wasn't opened for writing.
|
||||
sif::error << "MessageQueue::sendMessage: Configuration error "
|
||||
<< strerror(errno) << " in mq_send mqSendTo: " << sendTo
|
||||
<< " sent from " << sentFrom << std::endl;
|
||||
/*NO BREAK*/
|
||||
sif::error << "MessageQueue::sendMessage: Configuration error, MQ"
|
||||
<< " destination invalid." << std::endl;
|
||||
sif::error << strerror(errno) << " in "
|
||||
<<"mq_send to: " << sendTo << " sent from "
|
||||
<< sentFrom << std::endl;
|
||||
return DESTINVATION_INVALID;
|
||||
}
|
||||
case EINTR:
|
||||
//The call was interrupted by a signal.
|
||||
case EINVAL:
|
||||
|
@ -1,17 +1,18 @@
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
|
||||
#include <framework/tmtcservices/PusVerificationReport.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() :
|
||||
acknowledgeQueue() {
|
||||
acknowledgeQueue(MessageQueueIF::NO_QUEUE) {
|
||||
}
|
||||
|
||||
VerificationReporter::~VerificationReporter() {
|
||||
//Default, empty
|
||||
}
|
||||
VerificationReporter::~VerificationReporter() {}
|
||||
|
||||
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
||||
TcPacketBase* current_packet, uint8_t set_step) {
|
||||
@ -23,10 +24,11 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
||||
current_packet->getPacketId(),
|
||||
current_packet->getPacketSequenceControl(), 0, set_step);
|
||||
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
||||
&message);
|
||||
&message);
|
||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||
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,
|
||||
tcSequenceControl, 0, set_step);
|
||||
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
||||
&message);
|
||||
&message);
|
||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||
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,
|
||||
&message);
|
||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error
|
||||
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
|
||||
<< (uint16_t) status << std::endl;
|
||||
sif::error << "VerificationReporter::sendFailureReport Error writing "
|
||||
<< "to queue. Code: " << std::hex << status << std::dec
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,20 +81,25 @@ void VerificationReporter::sendFailureReport(uint8_t report_id,
|
||||
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue,
|
||||
&message);
|
||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error
|
||||
<< "VerificationReporter::sendFailureReport Error writing to queue. Code: "
|
||||
<< (uint16_t) status << std::endl;
|
||||
sif::error << "VerificationReporter::sendFailureReport Error writing "
|
||||
<< "to queue. Code: " << std::hex << status << std::dec
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
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>(
|
||||
messageReceiver);
|
||||
if (temp != NULL) {
|
||||
this->acknowledgeQueue = temp->getVerificationQueue();
|
||||
} else {
|
||||
sif::error
|
||||
<< "VerificationReporter::VerificationReporter: Configuration error."
|
||||
<< std::endl;
|
||||
if (temp == nullptr) {
|
||||
sif::error << "VerificationReporter::initialize: Message "
|
||||
<< "receiver invalid. Make sure it is set up properly and "
|
||||
<<"implementsAcceptsVerifyMessageIF" << std::endl;
|
||||
|
||||
}
|
||||
this->acknowledgeQueue = temp->getVerificationQueue();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef VERIFICATIONREPORTER_H_
|
||||
#define VERIFICATIONREPORTER_H_
|
||||
#ifndef FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_
|
||||
#define FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_
|
||||
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/tmtcservices/PusVerificationReport.h>
|
||||
@ -8,24 +8,43 @@ namespace Factory{
|
||||
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 {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
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 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 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 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,
|
||||
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);
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
static object_id_t messageReceiver;
|
||||
MessageQueueId_t acknowledgeQueue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* VERIFICATIONREPORTER_H_ */
|
||||
#endif /* FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user