1
0
forked from fsfw/fsfw

updating code from Flying Laptop

This is the framework of Flying Laptop OBSW version A.13.0.
This commit is contained in:
2018-07-12 16:29:32 +02:00
parent 1d22a6c97e
commit 575f70ba03
395 changed files with 12807 additions and 8404 deletions

View File

@ -1,16 +1,9 @@
/*
* CCSDSDistributor.cpp
*
* Created on: 18.06.2012
* Author: baetz
*/
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tcdistribution/CCSDSDistributor.h>
#include <framework/tmtcpacket/SpacePacketBase.h>
CCSDSDistributor::CCSDSDistributor( uint16_t set_default_apid ) :
TcDistributor( objects::CCSDS_PACKET_DISTRIBUTOR ), default_apid( set_default_apid ), tcStore(NULL) {
CCSDSDistributor::CCSDSDistributor( uint16_t setDefaultApid, object_id_t setObjectId ) :
TcDistributor( setObjectId ), default_apid( setDefaultApid ), tcStore(NULL) {
}
CCSDSDistributor::~CCSDSDistributor() {
@ -21,6 +14,7 @@ iterator_t CCSDSDistributor::selectDestination() {
// debug << "CCSDSDistributor::selectDestination received: " << this->currentMessage.getStorageId().pool_index << ", " << this->currentMessage.getStorageId().packet_index << std::endl;
const uint8_t* p_packet = NULL;
uint32_t size = 0;
//TODO check returncode?
this->tcStore->getData( this->currentMessage.getStorageId(), &p_packet, &size );
SpacePacketBase current_packet( p_packet );
// info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex << current_packet.getAPID() << std::dec << std::endl;
@ -35,7 +29,7 @@ iterator_t CCSDSDistributor::selectDestination() {
}
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
return this->tcQueue.getId();
return tcQueue->getId();
}
ReturnValue_t CCSDSDistributor::registerApplication(

View File

@ -1,10 +1,3 @@
/*
* CCSDSDistributor.h
*
* Created on: 18.06.2012
* Author: baetz
*/
#ifndef CCSDSDISTRIBUTOR_H_
#define CCSDSDISTRIBUTOR_H_
@ -48,7 +41,7 @@ public:
* \c tcStore is set in the \c initialize method.
* @param set_default_apid The default APID, where packets with unknown destination are sent to.
*/
CCSDSDistributor( uint16_t set_default_apid = 0x35 );
CCSDSDistributor( uint16_t setDefaultApid, object_id_t setObjectId );
/**
* The destructor is empty.
*/

View File

@ -1,15 +1,8 @@
/*
* CCSDSDistributorIF.h
*
* Created on: 21.11.2012
* Author: baetz
*/
#ifndef CCSDSDISTRIBUTORIF_H_
#define CCSDSDISTRIBUTORIF_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/ipc/MessageQueueSenderIF.h>
/**
* This is the Interface to a CCSDS Distributor.
* On a CCSDS Distributor, Applications (in terms of CCSDS) may register themselves,

View File

@ -1,23 +0,0 @@
#!/bin/bash
#
# OSAL makefile
#
# Created on: Mar 04, 2010
# Author: ziemke
# Author: Claas Ziemke
# Copyright 2010, Claas Ziemke <claas.ziemke@gmx.net>
#
BASEDIR=../../
include $(BASEDIR)options.mk
OBJ = $(BUILDDIR)/TcDistributor.o\
$(BUILDDIR)/CCSDSDistributor.o
all: $(OBJ)
$(BUILDDIR)/%.o: %.cpp %.h
$(CPP) $(CFLAGS) $(DEFINES) $(CCOPT) ${INCLUDE} -c $< -o $@
clean:
$(RM) *.o *.gcno *.gcda

View File

@ -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( &current_packet );
this->currentPacket.setStoreAddress(this->currentMessage.getStorageId());
if (currentPacket.getWholeData() != NULL) {
tcStatus = checker.checkPacket(&currentPacket);
// 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, &current_packet, tc_status );
if (tcStatus != RETURN_OK) {
this->verifyChannel.sendFailureReport(TC_VERIFY::ACCEPTANCE_FAILURE,
&currentPacket, 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, &current_packet );
this->verifyChannel.sendSuccessReport(TC_VERIFY::ACCEPTANCE_SUCCESS,
&currentPacket);
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 {

View File

@ -1,10 +1,3 @@
/*
* PUSDistributor.h
*
* Created on: 18.06.2012
* Author: baetz
*/
#ifndef PUSDISTRIBUTOR_H_
#define PUSDISTRIBUTOR_H_
@ -21,7 +14,25 @@
* or failure messages.
* \ingroup tc_distribution
*/
class PUSDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF {
class PUSDistributor: public TcDistributor,
public PUSDistributorIF,
public AcceptsTelecommandsIF {
public:
/**
* The ctor passes \c set_apid to the checker class and calls the TcDistribution ctor with a certain object id.
* @param setApid The APID of this receiving Application.
* @param setObjectId Object ID of the distributor itself
* @param setPacketSource Object ID of the source of TC packets. Must implement CCSDSDistributorIF.
*/
PUSDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource);
/**
* The destructor is empty.
*/
virtual ~PUSDistributor();
ReturnValue_t registerService(AcceptsTelecommandsIF* service);
MessageQueueId_t getRequestQueue();
uint16_t getIdentifier();
ReturnValue_t initialize();
protected:
/**
* This attribute contains the class, that performs a formal packet check.
@ -30,15 +41,17 @@ protected:
/**
* With this class, verification messages are sent to the TC Verification service.
*/
VerificationReporter verify_channel;
VerificationReporter verifyChannel;
/**
* The currently handled packet is stored here.
*/
TcPacketStored current_packet;
TcPacketStored currentPacket;
/**
* With this variable, the current check status is stored to generate acceptance messages later.
*/
ReturnValue_t tc_status;
ReturnValue_t tcStatus;
const object_id_t packetSource;
/**
* This method reads the packet service, checks if such a service is registered and forwards the packet to the destination.
* It also initiates the formal packet check and sending of verification messages.
@ -48,24 +61,7 @@ protected:
/**
* The callback here handles the generation of acceptance success/failure messages.
*/
ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus );
public:
/**
* The ctor passes \c set_apid to the checker class and calls the TcDistribution ctor with a certain object id.
* @param set_apid The APID of this receiving Application.
*/
PUSDistributor( uint16_t set_apid );
/**
* The destructor is empty.
*/
virtual ~PUSDistributor();
ReturnValue_t registerService( AcceptsTelecommandsIF* service );
MessageQueueId_t getRequestQueue();
uint16_t getIdentifier();
ReturnValue_t initialize();
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus);
};
#endif /* PUSDISTRIBUTOR_H_ */

View File

@ -1,15 +1,8 @@
/*
* PUSDistributorIF.h
*
* Created on: 21.11.2012
* Author: baetz
*/
#ifndef PUSDISTRIBUTORIF_H_
#define PUSDISTRIBUTORIF_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/ipc/MessageQueueSenderIF.h>
/**
* This interface allows PUS Services to register themselves at a PUS Distributor.
* \ingroup tc_distribution

View File

@ -1,26 +1,26 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/ipc/MessageQueue.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tcdistribution/TcDistributor.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/ipc/QueueFactory.h>
TcDistributor::TcDistributor(object_id_t set_object_id) :
SystemObject(set_object_id), tcQueue(DISTRIBUTER_MAX_PACKETS) {
SystemObject(set_object_id), tcQueue(NULL) {
tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS);
}
TcDistributor::~TcDistributor() {
//Nothing to do in the destructor, MQ's are destroyed elsewhere.
QueueFactory::instance()->deleteMessageQueue(tcQueue);
}
ReturnValue_t TcDistributor::performOperation(void) {
ReturnValue_t TcDistributor::performOperation(uint8_t opCode) {
ReturnValue_t status = RETURN_OK;
// debug << "TcDistributor: performing Operation." << std::endl;
for (status = tcQueue.receiveMessage(&currentMessage); status == RETURN_OK;
status = tcQueue.receiveMessage(&currentMessage)) {
for (status = tcQueue->receiveMessage(&currentMessage); status == RETURN_OK;
status = tcQueue->receiveMessage(&currentMessage)) {
status = handlePacket();
}
if (status == OSAL::QUEUE_EMPTY) {
if (status == OperatingSystemIF::QUEUE_EMPTY) {
return RETURN_OK;
} else {
return status;
@ -32,7 +32,7 @@ ReturnValue_t TcDistributor::handlePacket() {
iterator_t queueMapIt = this->selectDestination();
ReturnValue_t returnValue = RETURN_FAILED;
if (queueMapIt != this->queueMap.end()) {
returnValue = this->tcQueue.sendMessage(queueMapIt->second,
returnValue = this->tcQueue->sendMessage(queueMapIt->second,
&this->currentMessage);
}
return this->callbackAfterSending(returnValue);

View File

@ -1,13 +1,13 @@
#ifndef TCDISTRIBUTOR_H_
#define TCDISTRIBUTOR_H_
#include <framework/ipc/MessageQueue.h>
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/osal/OSAL.h>
#include <framework/osal/OperatingSystemIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/ipc/MessageQueueIF.h>
#include <map>
@ -42,7 +42,7 @@ protected:
* This is the receiving queue for incoming Telecommands.
* The child classes must make its queue id public.
*/
MessageQueue tcQueue;
MessageQueueIF* tcQueue;
/**
* The last received incoming packet information is stored in this
* member.
@ -82,7 +82,7 @@ protected:
*/
virtual ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus );
public:
static const uint8_t INTERFACE_ID = PACKET_DISTRIBUTION;
static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_DISTRIBUTION;
static const ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE( 1 );
static const ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE( 2 );
/**
@ -105,7 +105,7 @@ public:
* with distribution.
* @return The error code of the message queue call.
*/
ReturnValue_t performOperation();
ReturnValue_t performOperation(uint8_t opCode);
/**
* A simple debug print, that prints all distribution information stored in
* queueMap.

View File

@ -1,11 +1,3 @@
/*
* TcPacketCheck.cpp
*
* Created on: 19.06.2012
* Author: baetz
*/
#include <framework/globalfunctions/crc_ccitt.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/storagemanager/StorageManagerIF.h>

View File

@ -1,10 +1,3 @@
/*
* TcPacketCheck.h
*
* Created on: 19.06.2012
* Author: baetz
*/
#ifndef TCPACKETCHECK_H_
#define TCPACKETCHECK_H_
@ -36,7 +29,7 @@ protected:
*/
uint16_t apid;
public:
static const uint8_t INTERFACE_ID = TC_PACKET_CHECK;
static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK;
static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE( 0 );
static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE( 1 );
static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE( 2 );