minor improvements for PUS distributor
This commit is contained in:
parent
d1a256cbf6
commit
0e76333d33
@ -1,10 +1,12 @@
|
|||||||
#include "CCSDSDistributorIF.h"
|
#include "CCSDSDistributorIF.h"
|
||||||
#include "PUSDistributor.h"
|
#include "PUSDistributor.h"
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../tmtcpacket/pus/TcPacketStored.h"
|
#include "../tmtcpacket/pus/TcPacketStored.h"
|
||||||
#include "../tmtcservices/PusVerificationReport.h"
|
#include "../tmtcservices/PusVerificationReport.h"
|
||||||
|
|
||||||
|
#define PUS_DISTRIBUTOR_DEBUGGING 1
|
||||||
|
|
||||||
PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||||
object_id_t setPacketSource) :
|
object_id_t setPacketSource) :
|
||||||
TcDistributor(setObjectId), checker(setApid), verifyChannel(),
|
TcDistributor(setObjectId), checker(setApid), verifyChannel(),
|
||||||
@ -13,10 +15,10 @@ PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
|||||||
PUSDistributor::~PUSDistributor() {}
|
PUSDistributor::~PUSDistributor() {}
|
||||||
|
|
||||||
PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1
|
||||||
// sif:: debug << "PUSDistributor::handlePacket received: "
|
store_address_t storeId = this->currentMessage.getStorageId());
|
||||||
// << this->current_packet_id.store_index << ", "
|
sif:: debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " <<
|
||||||
// << this->current_packet_id.packet_index << std::endl;
|
storeId.packetIndex << std::endl;
|
||||||
#endif
|
#endif
|
||||||
TcMqMapIter queueMapIt = this->queueMap.end();
|
TcMqMapIter queueMapIt = this->queueMap.end();
|
||||||
if(this->currentPacket == nullptr) {
|
if(this->currentPacket == nullptr) {
|
||||||
@ -25,15 +27,17 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||||||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||||
if (currentPacket->getWholeData() != nullptr) {
|
if (currentPacket->getWholeData() != nullptr) {
|
||||||
tcStatus = checker.checkPacket(currentPacket);
|
tcStatus = checker.checkPacket(currentPacket);
|
||||||
#ifdef DEBUG
|
|
||||||
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "PUSDistributor::handlePacket: Packet format "
|
sif::debug << "PUSDistributor::handlePacket: Packet format invalid, code " <<
|
||||||
<< "invalid, code "<< static_cast<int>(tcStatus)
|
static_cast<int>(tcStatus) << std::endl;
|
||||||
<< std::endl;
|
#else
|
||||||
|
sif::printDebug("PUSDistributor::handlePacket: Packet format invalid, code %d\n",
|
||||||
|
static_cast<int>(tcStatus));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
uint32_t queue_id = currentPacket->getService();
|
uint32_t queue_id = currentPacket->getService();
|
||||||
queueMapIt = this->queueMap.find(queue_id);
|
queueMapIt = this->queueMap.find(queue_id);
|
||||||
}
|
}
|
||||||
@ -43,11 +47,12 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||||||
|
|
||||||
if (queueMapIt == this->queueMap.end()) {
|
if (queueMapIt == this->queueMap.end()) {
|
||||||
tcStatus = DESTINATION_NOT_FOUND;
|
tcStatus = DESTINATION_NOT_FOUND;
|
||||||
#ifdef DEBUG
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "PUSDistributor::handlePacket: Destination not found, "
|
sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl;
|
||||||
<< "code "<< static_cast<int>(tcStatus) << std::endl;
|
#else
|
||||||
#endif
|
sif::printDebug("PUSDistributor::handlePacket: Destination not found\n");
|
||||||
|
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,15 +68,23 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||||||
|
|
||||||
ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
|
ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
|
||||||
uint16_t serviceId = service->getIdentifier();
|
uint16_t serviceId = service->getIdentifier();
|
||||||
|
#if PUS_DISTRIBUTOR_DEBUGGING == 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
// sif::info << "Service ID: " << (int)serviceId << std::endl;
|
sif::info << "Service ID: " << static_cast<int>(serviceId) << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printInfo("Service ID: %d\n", static_cast<int>(serviceId));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
MessageQueueId_t queue = service->getRequestQueue();
|
MessageQueueId_t queue = service->getRequestQueue();
|
||||||
auto returnPair = queueMap.emplace(serviceId, queue);
|
auto returnPair = queueMap.emplace(serviceId, queue);
|
||||||
if (not returnPair.second) {
|
if (not returnPair.second) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "PUSDistributor::registerService: Service ID already"
|
sif::error << "PUSDistributor::registerService: Service ID already"
|
||||||
" exists in map." << std::endl;
|
" exists in map" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("PUSDistributor::registerService: Service ID already exists in map\n");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return SERVICE_ID_ALREADY_EXISTS;
|
return SERVICE_ID_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
@ -115,9 +128,11 @@ ReturnValue_t PUSDistributor::initialize() {
|
|||||||
objectManager->get<CCSDSDistributorIF>(packetSource);
|
objectManager->get<CCSDSDistributorIF>(packetSource);
|
||||||
if (ccsdsDistributor == nullptr) {
|
if (ccsdsDistributor == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "PUSDistributor::initialize: Packet source invalid."
|
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;
|
||||||
<< " Make sure it exists and implements CCSDSDistributorIF!"
|
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
|
||||||
<< std::endl;
|
#else
|
||||||
|
sif::printError("PUSDistributor::initialize: Packet source invalid\n");
|
||||||
|
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
|
||||||
#endif
|
#endif
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user