updating code from Flying Laptop
This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
@ -1,20 +1,12 @@
|
||||
/*
|
||||
* PUSDistributor.cpp
|
||||
*
|
||||
* Created on: 18.06.2012
|
||||
* Author: baetz
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/tcdistribution/CCSDSDistributorIF.h>
|
||||
#include <framework/tcdistribution/PUSDistributor.h>
|
||||
#include <framework/tmtcpacket/pus/TcPacketStored.h>
|
||||
#include <framework/tmtcservices/PusVerificationReport.h>
|
||||
|
||||
PUSDistributor::PUSDistributor(uint16_t set_apid ) : TcDistributor(objects::PUS_PACKET_DISTRIBUTOR), checker(set_apid), verify_channel(),
|
||||
current_packet(), tc_status(RETURN_FAILED) {
|
||||
PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource) :
|
||||
TcDistributor(setObjectId), checker(setApid), verifyChannel(), currentPacket(), tcStatus(
|
||||
RETURN_FAILED), packetSource(setPacketSource) {
|
||||
|
||||
}
|
||||
|
||||
@ -25,21 +17,22 @@ PUSDistributor::~PUSDistributor() {
|
||||
iterator_t PUSDistributor::selectDestination() {
|
||||
// debug << "PUSDistributor::handlePacket received: " << this->current_packet_id.store_index << ", " << this->current_packet_id.packet_index << std::endl;
|
||||
iterator_t queueMapIt = this->queueMap.end();
|
||||
this->current_packet.setStoreAddress( this->currentMessage.getStorageId() );
|
||||
if ( current_packet.getWholeData() != NULL ) {
|
||||
tc_status = checker.checkPacket( ¤t_packet );
|
||||
this->currentPacket.setStoreAddress(this->currentMessage.getStorageId());
|
||||
if (currentPacket.getWholeData() != NULL) {
|
||||
tcStatus = checker.checkPacket(¤tPacket);
|
||||
// info << "PUSDistributor::handlePacket: packetCheck returned with " << (int)tc_status << std::endl;
|
||||
uint32_t queue_id = current_packet.getService();
|
||||
queueMapIt = this->queueMap.find( queue_id );
|
||||
uint32_t queue_id = currentPacket.getService();
|
||||
queueMapIt = this->queueMap.find(queue_id);
|
||||
} else {
|
||||
tc_status = PACKET_LOST;
|
||||
tcStatus = PACKET_LOST;
|
||||
}
|
||||
if ( queueMapIt == this->queueMap.end() ) {
|
||||
tc_status = DESTINATION_NOT_FOUND;
|
||||
if (queueMapIt == this->queueMap.end()) {
|
||||
tcStatus = DESTINATION_NOT_FOUND;
|
||||
}
|
||||
|
||||
if ( tc_status != RETURN_OK ) {
|
||||
debug << "PUSDistributor::handlePacket: error with " << (int)tc_status << std::endl;
|
||||
if (tcStatus != RETURN_OK) {
|
||||
debug << "PUSDistributor::handlePacket: error with " << (int) tcStatus
|
||||
<< std::endl;
|
||||
return this->queueMap.end();
|
||||
} else {
|
||||
return queueMapIt;
|
||||
@ -47,7 +40,6 @@ iterator_t PUSDistributor::selectDestination() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//uint16_t PUSDistributor::createDestination( uint8_t service_id, uint8_t subservice_id ) {
|
||||
// return ( service_id << 8 ) + subservice_id;
|
||||
//}
|
||||
@ -57,28 +49,31 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
|
||||
bool errorCode = true;
|
||||
uint16_t serviceId = service->getIdentifier();
|
||||
MessageQueueId_t queue = service->getRequestQueue();
|
||||
errorCode = this->queueMap.insert( std::pair<uint32_t, MessageQueueId_t>( serviceId, queue) ).second;
|
||||
if( errorCode == false ) {
|
||||
returnValue = OSAL::RESOURCE_IN_USE;
|
||||
errorCode = this->queueMap.insert(
|
||||
std::pair<uint32_t, MessageQueueId_t>(serviceId, queue)).second;
|
||||
if (errorCode == false) {
|
||||
returnValue = OperatingSystemIF::RESOURCE_IN_USE;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
MessageQueueId_t PUSDistributor::getRequestQueue() {
|
||||
return this->tcQueue.getId();
|
||||
return tcQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||
if ( queueStatus != RETURN_OK ) {
|
||||
tc_status = queueStatus;
|
||||
if (queueStatus != RETURN_OK) {
|
||||
tcStatus = queueStatus;
|
||||
}
|
||||
if ( tc_status != RETURN_OK ) {
|
||||
this->verify_channel.sendFailureReport( TC_VERIFY::ACCEPTANCE_FAILURE, ¤t_packet, tc_status );
|
||||
if (tcStatus != RETURN_OK) {
|
||||
this->verifyChannel.sendFailureReport(TC_VERIFY::ACCEPTANCE_FAILURE,
|
||||
¤tPacket, tcStatus);
|
||||
//A failed packet is deleted immediately after reporting, otherwise it will block memory.
|
||||
current_packet.deletePacket();
|
||||
currentPacket.deletePacket();
|
||||
return RETURN_FAILED;
|
||||
} else {
|
||||
this->verify_channel.sendSuccessReport( TC_VERIFY::ACCEPTANCE_SUCCESS, ¤t_packet );
|
||||
this->verifyChannel.sendSuccessReport(TC_VERIFY::ACCEPTANCE_SUCCESS,
|
||||
¤tPacket);
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
@ -88,7 +83,8 @@ uint16_t PUSDistributor::getIdentifier() {
|
||||
}
|
||||
|
||||
ReturnValue_t PUSDistributor::initialize() {
|
||||
CCSDSDistributorIF* ccsdsDistributor = objectManager->get<CCSDSDistributorIF>(objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||
CCSDSDistributorIF* ccsdsDistributor =
|
||||
objectManager->get<CCSDSDistributorIF>(packetSource);
|
||||
if (ccsdsDistributor == NULL) {
|
||||
return RETURN_FAILED;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user