set sec header flag and add unit test for it

This commit is contained in:
Robin Müller 2022-07-28 15:13:27 +02:00
parent 8f6f0e1d45
commit fc3412fa35
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
15 changed files with 75 additions and 64 deletions

View File

@ -1,17 +0,0 @@
#include "CFDPMessage.h"
CFDPMessage::CFDPMessage() {}
CFDPMessage::~CFDPMessage() {}
void CFDPMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
message->setParameter(cfdpPacket.raw);
}
store_address_t CFDPMessage::getStoreId(const CommandMessage *message) {
store_address_t storeAddressCFDPPacket;
storeAddressCFDPPacket = static_cast<store_address_t>(message->getParameter());
return storeAddressCFDPPacket;
}
void CFDPMessage::clear(CommandMessage *message) {}

View File

@ -1,4 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE CFDPHandler.cpp CFDPMessage.cpp)
target_sources(${LIB_FSFW_NAME} PRIVATE CfdpHandler.cpp CfdpMessage.cpp)
add_subdirectory(pdu)
add_subdirectory(tlv)

View File

@ -1,24 +1,24 @@
#include "fsfw/cfdp/CFDPHandler.h"
#include "fsfw/cfdp/CfdpHandler.h"
#include "fsfw/cfdp/CFDPMessage.h"
#include "fsfw/cfdp/CfdpMessage.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/storagemanager/storeAddress.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
object_id_t CFDPHandler::packetSource = 0;
object_id_t CFDPHandler::packetDestination = 0;
object_id_t CfdpHandler::packetSource = 0;
object_id_t CfdpHandler::packetDestination = 0;
CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist)
CfdpHandler::CfdpHandler(object_id_t setObjectId, CFDPDistributor* dist)
: SystemObject(setObjectId) {
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
distributor = dist;
}
CFDPHandler::~CFDPHandler() {}
CfdpHandler::~CfdpHandler() = default;
ReturnValue_t CFDPHandler::initialize() {
ReturnValue_t CfdpHandler::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
return result;
@ -27,7 +27,7 @@ ReturnValue_t CFDPHandler::initialize() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "CFDPHandler::handleRequest" << std::endl;
@ -41,17 +41,17 @@ ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
return RETURN_OK;
}
ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) {
ReturnValue_t status = RETURN_OK;
CommandMessage currentMessage;
for (status = this->requestQueue->receiveMessage(&currentMessage); status == RETURN_OK;
status = this->requestQueue->receiveMessage(&currentMessage)) {
store_address_t storeId = CFDPMessage::getStoreId(&currentMessage);
store_address_t storeId = CfdpMessage::getStoreId(&currentMessage);
this->handleRequest(storeId);
}
return RETURN_OK;
}
uint16_t CFDPHandler::getIdentifier() { return 0; }
uint16_t CfdpHandler::getIdentifier() { return 0; }
MessageQueueId_t CFDPHandler::getRequestQueue() { return this->requestQueue->getId(); }
MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); }

View File

@ -12,18 +12,18 @@ namespace Factory {
void setStaticFrameworkObjectIds();
}
class CFDPHandler : public ExecutableObjectIF,
class CfdpHandler : public ExecutableObjectIF,
public AcceptsTelecommandsIF,
public SystemObject,
public HasReturnvaluesIF {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
CfdpHandler(object_id_t setObjectId, CFDPDistributor* distributor);
/**
* The destructor is empty.
*/
virtual ~CFDPHandler();
virtual ~CfdpHandler();
virtual ReturnValue_t handleRequest(store_address_t storeId);

View File

@ -0,0 +1,17 @@
#include "CfdpMessage.h"
CfdpMessage::CfdpMessage() = default;
CfdpMessage::~CfdpMessage() = default;
void CfdpMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
message->setParameter(cfdpPacket.raw);
}
store_address_t CfdpMessage::getStoreId(const CommandMessage *message) {
store_address_t storeId;
storeId = static_cast<store_address_t>(message->getParameter());
return storeId;
}
void CfdpMessage::clear(CommandMessage *message) {}

View File

@ -5,14 +5,14 @@
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
class CFDPMessage {
class CfdpMessage {
private:
CFDPMessage();
CfdpMessage();
public:
static const uint8_t MESSAGE_ID = messagetypes::CFDP;
virtual ~CFDPMessage();
virtual ~CfdpMessage();
static void setCommand(CommandMessage* message, store_address_t cfdpPacket);
static store_address_t getStoreId(const CommandMessage* message);

View File

@ -7,7 +7,7 @@ PoolManager::PoolManager(object_id_t setObjectId, const LocalPoolConfig& localPo
mutex = MutexFactory::instance()->createMutex();
}
PoolManager::~PoolManager(void) { MutexFactory::instance()->deleteMutex(mutex); }
PoolManager::~PoolManager() { MutexFactory::instance()->deleteMutex(mutex); }
ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* address,
bool ignoreFault) {
@ -17,7 +17,7 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* addr
}
ReturnValue_t PoolManager::deleteData(store_address_t storeId) {
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_VERBOSE_LEVEL >= 2 && FSFW_OBJ_EVENT_TRANSLATION == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store "
<< storeId.poolIndex << ". id is " << storeId.packetIndex << std::endl;

View File

@ -72,7 +72,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) {
uint16_t handlerId =
handler->getIdentifier(); // should be 0, because CFDPHandler does not set a set a service-ID
handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a service-ID
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId)

View File

@ -83,3 +83,5 @@ void SpacePacketCreator::setPacketType(ccsds::PacketType type) {
bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; }
SpacePacketCreator::operator bool() const { return isValid(); }
void SpacePacketCreator::setSecHeaderFlag() { params.packetId.secHeaderFlag = true; }

View File

@ -39,6 +39,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF {
SpacePacketParams &getParams();
void setParams(SpacePacketParams params);
void setSecHeaderFlag();
void setPacketType(ccsds::PacketType type);
void setApid(uint16_t apid);
void setSeqCount(uint16_t seqCount);

View File

@ -8,8 +8,7 @@
PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams)
: spCreator(std::move(spParams)), pusParams(pusParams) {
spCreator.setPacketType(ccsds::PacketType::TC);
updateSpLengthField();
setup();
}
ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
@ -111,3 +110,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max
ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const {
return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK);
}
void PusTcCreator::setup() {
spCreator.setPacketType(ccsds::PacketType::TC);
spCreator.setSecHeaderFlag();
updateSpLengthField();
}

View File

@ -61,6 +61,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF
// Forbidden to use
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
void setup();
SpacePacketCreator spCreator;
PusTcParams pusParams;
};

View File

@ -124,6 +124,7 @@ void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); }
void PusTmCreator::setup() {
updateSpLengthField();
spCreator.setPacketType(ccsds::PacketType::TM);
spCreator.setSecHeaderFlag();
}
void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) {

View File

@ -16,20 +16,21 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") {
size_t serLen = 0;
SECTION("State") {
REQUIRE(creator.isTc());
REQUIRE(creator.getService() == 17);
REQUIRE(creator.getSubService() == 1);
REQUIRE(creator.getApid() == 0x02);
REQUIRE(creator.getPusVersion() == 2);
REQUIRE(creator.getAcknowledgeFlags() == 0b1111);
REQUIRE(creator.getSourceId() == 0x00);
REQUIRE(creator.getPacketSeqCtrlRaw() == 0xc034);
CHECK(creator.isTc());
CHECK(creator.hasSecHeader());
CHECK(creator.getService() == 17);
CHECK(creator.getSubService() == 1);
CHECK(creator.getApid() == 0x02);
CHECK(creator.getPusVersion() == 2);
CHECK(creator.getAcknowledgeFlags() == 0b1111);
CHECK(creator.getSourceId() == 0x00);
CHECK(creator.getPacketSeqCtrlRaw() == 0xc034);
// bytes CCSDS header, 5 bytes secondary header, 2 bytes CRC, 3 bytes app data
REQUIRE(creator.getFullPacketLen() == 13);
CHECK(creator.getFullPacketLen() == 13);
// The data length field is the full packet length minus the primary header minus 1
REQUIRE(creator.getPacketDataLen() == 6);
CHECK(creator.getPacketDataLen() == 6);
auto& paramsLocal = creator.getSpParams();
REQUIRE(paramsLocal.packetId == packetId);
CHECK(paramsLocal.packetId == packetId);
}
SECTION("Serialized") {

View File

@ -19,22 +19,23 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {
size_t serLen = 0;
SECTION("State") {
REQUIRE(creator.isTm());
REQUIRE(creator.getApid() == 0xef);
REQUIRE(creator.getPusVersion() == 2);
REQUIRE(creator.getScTimeRefStatus() == 0);
REQUIRE(creator.getService() == 17);
REQUIRE(creator.getSubService() == 2);
REQUIRE(creator.getTimestamper() == &timeStamper);
REQUIRE(creator.getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED);
REQUIRE(creator.getSequenceCount() == 22);
CHECK(creator.isTm());
CHECK(creator.hasSecHeader());
CHECK(creator.getApid() == 0xef);
CHECK(creator.getPusVersion() == 2);
CHECK(creator.getScTimeRefStatus() == 0);
CHECK(creator.getService() == 17);
CHECK(creator.getSubService() == 2);
CHECK(creator.getTimestamper() == &timeStamper);
CHECK(creator.getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED);
CHECK(creator.getSequenceCount() == 22);
// 6 bytes CCSDS header, 7 bytes secondary header, 7 bytes CDS short timestamp,
// 0 bytes application data, 2 bytes CRC
REQUIRE(creator.getFullPacketLen() == 22);
CHECK(creator.getFullPacketLen() == 22);
// As specified in standard, the data length fields is the total size of the packet without
// the primary header minus 1
REQUIRE(creator.getPacketDataLen() == 15);
REQUIRE(timeStamper.getSizeCallCount == 1);
CHECK(creator.getPacketDataLen() == 15);
CHECK(timeStamper.getSizeCallCount == 1);
}
SECTION("SP Params") {