max tm packet size now configurable
This commit is contained in:
parent
1d2dabb4b4
commit
aa33ff2f48
@ -68,6 +68,8 @@ static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
|||||||
|
|
||||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||||
|
|
||||||
|
static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_
|
||||||
|
|
||||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||||
#include "../../serialize/SerializeAdapter.h"
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
@ -7,32 +7,32 @@
|
|||||||
|
|
||||||
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class ApidMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
private:
|
private:
|
||||||
uint16_t apid;
|
uint16_t apid;
|
||||||
public:
|
public:
|
||||||
ApidMatcher(uint16_t setApid) :
|
ApidMatcher(uint16_t setApid) :
|
||||||
apid(setApid) {
|
apid(setApid) {
|
||||||
}
|
}
|
||||||
ApidMatcher(TmPacketMinimal* test) :
|
ApidMatcher(TmPacketMinimal* test) :
|
||||||
apid(test->getAPID()) {
|
apid(test->getAPID()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getAPID() == apid) {
|
if (packet->getAPID() == apid) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&apid);
|
return SerializeAdapter::getSerializedSize(&apid);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,197 +5,194 @@
|
|||||||
|
|
||||||
// This should be configurable..
|
// This should be configurable..
|
||||||
const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = {
|
const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = {
|
||||||
{10, sizeof(ServiceMatcher)},
|
{10, sizeof(ServiceMatcher)},
|
||||||
{20, sizeof(SubServiceMatcher)},
|
{20, sizeof(SubServiceMatcher)},
|
||||||
{2, sizeof(ApidMatcher)},
|
{2, sizeof(ApidMatcher)},
|
||||||
{40, sizeof(PacketMatchTree::Node)}
|
{40, sizeof(PacketMatchTree::Node)}
|
||||||
};
|
};
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree(Node* root) :
|
PacketMatchTree::PacketMatchTree(Node* root): MatchTree<TmPacketMinimal*>(root, 2),
|
||||||
MatchTree<TmPacketMinimal*>(root, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree(iterator root) :
|
PacketMatchTree::PacketMatchTree(iterator root): MatchTree<TmPacketMinimal*>(root.element, 2),
|
||||||
MatchTree<TmPacketMinimal*>(root.element, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::PacketMatchTree() :
|
PacketMatchTree::PacketMatchTree(): MatchTree<TmPacketMinimal*>((Node*) NULL, 2),
|
||||||
MatchTree<TmPacketMinimal*>((Node*) NULL, 2),
|
factoryBackend(0, poolConfig, false, true),
|
||||||
factoryBackend(0, poolConfig, false, true),
|
factory(&factoryBackend) {
|
||||||
factory(&factoryBackend) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::~PacketMatchTree() {
|
PacketMatchTree::~PacketMatchTree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type,
|
||||||
uint8_t subtype) {
|
uint8_t subtype) {
|
||||||
//We assume adding APID is always requested.
|
//We assume adding APID is always requested.
|
||||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||||
data.data_field.service_type = type;
|
data.data_field.service_type = type;
|
||||||
data.data_field.service_subtype = subtype;
|
data.data_field.service_subtype = subtype;
|
||||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||||
testPacket.setAPID(apid);
|
testPacket.setAPID(apid);
|
||||||
iterator lastTest;
|
iterator lastTest;
|
||||||
iterator rollback;
|
iterator rollback;
|
||||||
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
ReturnValue_t result = findOrInsertMatch<TmPacketMinimal*, ApidMatcher>(
|
||||||
this->begin(), &testPacket, &lastTest);
|
this->begin(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
rollback = lastTest;
|
rollback = lastTest;
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
//Check if lastTest has no children, otherwise, delete them,
|
//Check if lastTest has no children, otherwise, delete them,
|
||||||
//as a more general check is requested.
|
//as a more general check is requested.
|
||||||
if (lastTest.left() != this->end()) {
|
if (lastTest.left() != this->end()) {
|
||||||
removeElementAndAllChildren(lastTest.left());
|
removeElementAndAllChildren(lastTest.left());
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
//Type insertion required.
|
//Type insertion required.
|
||||||
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
result = findOrInsertMatch<TmPacketMinimal*, ServiceMatcher>(
|
||||||
lastTest.left(), &testPacket, &lastTest);
|
lastTest.left(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
if (rollback == this->end()) {
|
if (rollback == this->end()) {
|
||||||
rollback = lastTest;
|
rollback = lastTest;
|
||||||
}
|
}
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
if (rollback != this->end()) {
|
if (rollback != this->end()) {
|
||||||
removeElementAndAllChildren(rollback);
|
removeElementAndAllChildren(rollback);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (subtype == 0) {
|
if (subtype == 0) {
|
||||||
if (lastTest.left() != this->end()) {
|
if (lastTest.left() != this->end()) {
|
||||||
//See above
|
//See above
|
||||||
removeElementAndAllChildren(lastTest.left());
|
removeElementAndAllChildren(lastTest.left());
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
//Subtype insertion required.
|
//Subtype insertion required.
|
||||||
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
result = findOrInsertMatch<TmPacketMinimal*, SubServiceMatcher>(
|
||||||
lastTest.left(), &testPacket, &lastTest);
|
lastTest.left(), &testPacket, &lastTest);
|
||||||
if (result == NEW_NODE_CREATED) {
|
if (result == NEW_NODE_CREATED) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
} else if (result != RETURN_OK) {
|
} else if (result != RETURN_OK) {
|
||||||
if (rollback != this->end()) {
|
if (rollback != this->end()) {
|
||||||
removeElementAndAllChildren(rollback);
|
removeElementAndAllChildren(rollback);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename VALUE_T, typename INSERTION_T>
|
template<typename VALUE_T, typename INSERTION_T>
|
||||||
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test,
|
||||||
iterator* lastTest) {
|
iterator* lastTest) {
|
||||||
bool attachToBranch = AND;
|
bool attachToBranch = AND;
|
||||||
iterator iter = startAt;
|
iterator iter = startAt;
|
||||||
while (iter != this->end()) {
|
while (iter != this->end()) {
|
||||||
bool isMatch = iter->match(test);
|
bool isMatch = iter->match(test);
|
||||||
attachToBranch = OR;
|
attachToBranch = OR;
|
||||||
*lastTest = iter;
|
*lastTest = iter;
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
//Go down OR branch.
|
//Go down OR branch.
|
||||||
iter = iter.right();
|
iter = iter.right();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Only reached if nothing was found.
|
//Only reached if nothing was found.
|
||||||
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
SerializeableMatcherIF<VALUE_T>* newContent = factory.generate<INSERTION_T>(
|
||||||
test);
|
test);
|
||||||
if (newContent == NULL) {
|
if (newContent == NULL) {
|
||||||
return FULL;
|
return FULL;
|
||||||
}
|
}
|
||||||
Node* newNode = factory.generate<Node>(newContent);
|
Node* newNode = factory.generate<Node>(newContent);
|
||||||
if (newNode == NULL) {
|
if (newNode == NULL) {
|
||||||
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
//Need to make sure partially generated content is deleted, otherwise, that's a leak.
|
||||||
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
factory.destroy<INSERTION_T>(static_cast<INSERTION_T*>(newContent));
|
||||||
return FULL;
|
return FULL;
|
||||||
}
|
}
|
||||||
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
*lastTest = insert(attachToBranch, *lastTest, newNode);
|
||||||
if (*lastTest == end()) {
|
if (*lastTest == end()) {
|
||||||
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
//This actaully never fails, so creating a dedicated returncode seems an overshoot.
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return NEW_NODE_CREATED;
|
return NEW_NODE_CREATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type,
|
||||||
uint8_t subtype) {
|
uint8_t subtype) {
|
||||||
TmPacketMinimal::TmPacketMinimalPointer data;
|
TmPacketMinimal::TmPacketMinimalPointer data;
|
||||||
data.data_field.service_type = type;
|
data.data_field.service_type = type;
|
||||||
data.data_field.service_subtype = subtype;
|
data.data_field.service_subtype = subtype;
|
||||||
TmPacketMinimal testPacket((uint8_t*) &data);
|
TmPacketMinimal testPacket((uint8_t*) &data);
|
||||||
testPacket.setAPID(apid);
|
testPacket.setAPID(apid);
|
||||||
iterator foundElement = findMatch(begin(), &testPacket);
|
iterator foundElement = findMatch(begin(), &testPacket);
|
||||||
if (foundElement == this->end()) {
|
if (foundElement == this->end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
if (foundElement.left() == end()) {
|
if (foundElement.left() == end()) {
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
} else {
|
} else {
|
||||||
return TOO_GENERAL_REQUEST;
|
return TOO_GENERAL_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Go down AND branch. Will abort if empty.
|
//Go down AND branch. Will abort if empty.
|
||||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||||
if (foundElement == this->end()) {
|
if (foundElement == this->end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
if (subtype == 0) {
|
if (subtype == 0) {
|
||||||
if (foundElement.left() == end()) {
|
if (foundElement.left() == end()) {
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
} else {
|
} else {
|
||||||
return TOO_GENERAL_REQUEST;
|
return TOO_GENERAL_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Again, go down AND branch.
|
//Again, go down AND branch.
|
||||||
foundElement = findMatch(foundElement.left(), &testPacket);
|
foundElement = findMatch(foundElement.left(), &testPacket);
|
||||||
if (foundElement == end()) {
|
if (foundElement == end()) {
|
||||||
return NO_MATCH;
|
return NO_MATCH;
|
||||||
}
|
}
|
||||||
return removeElementAndReconnectChildren(foundElement);
|
return removeElementAndReconnectChildren(foundElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt,
|
||||||
TmPacketMinimal* test) {
|
TmPacketMinimal* test) {
|
||||||
iterator iter = startAt;
|
iterator iter = startAt;
|
||||||
while (iter != end()) {
|
while (iter != end()) {
|
||||||
bool isMatch = iter->match(test);
|
bool isMatch = iter->match(test);
|
||||||
if (isMatch) {
|
if (isMatch) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
iter = iter.right(); //next OR element
|
iter = iter.right(); //next OR element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::initialize() {
|
ReturnValue_t PacketMatchTree::initialize() {
|
||||||
return factoryBackend.initialize();
|
return factoryBackend.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
ReturnValue_t PacketMatchTree::changeMatch(bool addToMatch, uint16_t apid,
|
||||||
uint8_t type, uint8_t subtype) {
|
uint8_t type, uint8_t subtype) {
|
||||||
if (addToMatch) {
|
if (addToMatch) {
|
||||||
return addMatch(apid, type, subtype);
|
return addMatch(apid, type, subtype);
|
||||||
} else {
|
} else {
|
||||||
return removeMatch(apid, type, subtype);
|
return removeMatch(apid, type, subtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
ReturnValue_t PacketMatchTree::cleanUpElement(iterator position) {
|
||||||
factory.destroy(position.element->value);
|
factory.destroy(position.element->value);
|
||||||
//Go on anyway, there's nothing we can do.
|
//Go on anyway, there's nothing we can do.
|
||||||
//SHOULDDO: Throw event, or write debug message?
|
//SHOULDDO: Throw event, or write debug message?
|
||||||
return factory.destroy(position.element);
|
return factory.destroy(position.element);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_
|
||||||
|
|
||||||
#include "../../container/PlacementFactory.h"
|
#include "../../container/PlacementFactory.h"
|
||||||
#include "../../globalfunctions/matching/MatchTree.h"
|
#include "../../globalfunctions/matching/MatchTree.h"
|
||||||
@ -8,29 +8,29 @@
|
|||||||
|
|
||||||
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
class PacketMatchTree: public MatchTree<TmPacketMinimal*>, public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
PacketMatchTree(Node* root);
|
PacketMatchTree(Node* root);
|
||||||
PacketMatchTree(iterator root);
|
PacketMatchTree(iterator root);
|
||||||
PacketMatchTree();
|
PacketMatchTree();
|
||||||
virtual ~PacketMatchTree();
|
virtual ~PacketMatchTree();
|
||||||
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0,
|
||||||
uint8_t subtype = 0);
|
uint8_t subtype = 0);
|
||||||
ReturnValue_t initialize();
|
ReturnValue_t initialize();
|
||||||
protected:
|
protected:
|
||||||
ReturnValue_t cleanUpElement(iterator position);
|
ReturnValue_t cleanUpElement(iterator position);
|
||||||
private:
|
private:
|
||||||
static const uint8_t N_POOLS = 4;
|
static const uint8_t N_POOLS = 4;
|
||||||
LocalPool factoryBackend;
|
LocalPool factoryBackend;
|
||||||
PlacementFactory factory;
|
PlacementFactory factory;
|
||||||
static const LocalPool::LocalPoolConfig poolConfig;
|
static const LocalPool::LocalPoolConfig poolConfig;
|
||||||
static const uint16_t POOL_SIZES[N_POOLS];
|
static const uint16_t POOL_SIZES[N_POOLS];
|
||||||
static const uint16_t N_ELEMENTS[N_POOLS];
|
static const uint16_t N_ELEMENTS[N_POOLS];
|
||||||
template<typename VALUE_T, typename INSERTION_T>
|
template<typename VALUE_T, typename INSERTION_T>
|
||||||
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest);
|
||||||
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
iterator findMatch(iterator startAt, TmPacketMinimal* test);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */
|
||||||
|
@ -7,32 +7,32 @@
|
|||||||
|
|
||||||
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class ServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
private:
|
private:
|
||||||
uint8_t service;
|
uint8_t service;
|
||||||
public:
|
public:
|
||||||
ServiceMatcher(uint8_t setService) :
|
ServiceMatcher(uint8_t setService) :
|
||||||
service(setService) {
|
service(setService) {
|
||||||
}
|
}
|
||||||
ServiceMatcher(TmPacketMinimal* test) :
|
ServiceMatcher(TmPacketMinimal* test) :
|
||||||
service(test->getService()) {
|
service(test->getService()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getService() == service) {
|
if (packet->getService() == service) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&service);
|
return SerializeAdapter::getSerializedSize(&service);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
#ifndef FSFW_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||||
#define FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
#define FSFW_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_
|
||||||
|
|
||||||
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
#include "../../globalfunctions/matching/SerializeableMatcherIF.h"
|
||||||
#include "../../serialize/SerializeAdapter.h"
|
#include "../../serialize/SerializeAdapter.h"
|
||||||
@ -7,32 +7,32 @@
|
|||||||
|
|
||||||
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
class SubServiceMatcher: public SerializeableMatcherIF<TmPacketMinimal*> {
|
||||||
public:
|
public:
|
||||||
SubServiceMatcher(uint8_t subService) :
|
SubServiceMatcher(uint8_t subService) :
|
||||||
subService(subService) {
|
subService(subService) {
|
||||||
}
|
}
|
||||||
SubServiceMatcher(TmPacketMinimal* test) :
|
SubServiceMatcher(TmPacketMinimal* test) :
|
||||||
subService(test->getSubService()) {
|
subService(test->getSubService()) {
|
||||||
}
|
}
|
||||||
bool match(TmPacketMinimal* packet) {
|
bool match(TmPacketMinimal* packet) {
|
||||||
if (packet->getSubService() == subService) {
|
if (packet->getSubService() == subService) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
return SerializeAdapter::getSerializedSize(&subService);
|
return SerializeAdapter::getSerializedSize(&subService);
|
||||||
}
|
}
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
uint8_t subService;
|
uint8_t subService;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,114 +19,114 @@ class TcPacketBase : public SpacePacketBase {
|
|||||||
friend class TcPacketStoredBase;
|
friend class TcPacketStoredBase;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum AckField {
|
enum AckField {
|
||||||
//! No acknowledgements are expected.
|
//! No acknowledgements are expected.
|
||||||
ACK_NONE = 0b0000,
|
ACK_NONE = 0b0000,
|
||||||
//! Acknowledgements on acceptance are expected.
|
//! Acknowledgements on acceptance are expected.
|
||||||
ACK_ACCEPTANCE = 0b0001,
|
ACK_ACCEPTANCE = 0b0001,
|
||||||
//! Acknowledgements on start are expected.
|
//! Acknowledgements on start are expected.
|
||||||
ACK_START = 0b0010,
|
ACK_START = 0b0010,
|
||||||
//! Acknowledgements on step are expected.
|
//! Acknowledgements on step are expected.
|
||||||
ACK_STEP = 0b0100,
|
ACK_STEP = 0b0100,
|
||||||
//! Acknowledfgement on completion are expected.
|
//! Acknowledfgement on completion are expected.
|
||||||
ACK_COMPLETION = 0b1000
|
ACK_COMPLETION = 0b1000
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP |
|
static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP |
|
||||||
ACK_COMPLETION;
|
ACK_COMPLETION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
||||||
* It sets its internal data pointer to the address passed and also
|
* It sets its internal data pointer to the address passed and also
|
||||||
* forwards the data pointer to the parent SpacePacketBase class.
|
* forwards the data pointer to the parent SpacePacketBase class.
|
||||||
* @param setData The position where the packet data lies.
|
* @param setData The position where the packet data lies.
|
||||||
*/
|
*/
|
||||||
TcPacketBase( const uint8_t* setData );
|
TcPacketBase( const uint8_t* setData );
|
||||||
/**
|
/**
|
||||||
* This is the empty default destructor.
|
* This is the empty default destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~TcPacketBase();
|
virtual ~TcPacketBase();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command returns the CCSDS Secondary Header Flag.
|
* This command returns the CCSDS Secondary Header Flag.
|
||||||
* It shall always be zero for PUS Packets. This is the
|
* It shall always be zero for PUS Packets. This is the
|
||||||
* highest bit of the first byte of the Data Field Header.
|
* highest bit of the first byte of the Data Field Header.
|
||||||
* @return the CCSDS Secondary Header Flag
|
* @return the CCSDS Secondary Header Flag
|
||||||
*/
|
*/
|
||||||
virtual uint8_t getSecondaryHeaderFlag() const = 0;
|
virtual uint8_t getSecondaryHeaderFlag() const = 0;
|
||||||
/**
|
/**
|
||||||
* This command returns the TC Packet PUS Version Number.
|
* This command returns the TC Packet PUS Version Number.
|
||||||
* The version number of ECSS PUS 2003 is 1.
|
* The version number of ECSS PUS 2003 is 1.
|
||||||
* It consists of the second to fourth highest bits of the
|
* It consists of the second to fourth highest bits of the
|
||||||
* first byte.
|
* first byte.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual uint8_t getPusVersionNumber() const = 0;
|
virtual uint8_t getPusVersionNumber() const = 0;
|
||||||
/**
|
/**
|
||||||
* This is a getter for the packet's Ack field, which are the lowest four
|
* This is a getter for the packet's Ack field, which are the lowest four
|
||||||
* bits of the first byte of the Data Field Header.
|
* bits of the first byte of the Data Field Header.
|
||||||
*
|
*
|
||||||
* It is packed in a uint8_t variable.
|
* It is packed in a uint8_t variable.
|
||||||
* @return The packet's PUS Ack field.
|
* @return The packet's PUS Ack field.
|
||||||
*/
|
*/
|
||||||
virtual uint8_t getAcknowledgeFlags() const = 0;
|
virtual uint8_t getAcknowledgeFlags() const = 0;
|
||||||
/**
|
/**
|
||||||
* This is a getter for the packet's PUS Service ID, which is the second
|
* This is a getter for the packet's PUS Service ID, which is the second
|
||||||
* byte of the Data Field Header.
|
* byte of the Data Field Header.
|
||||||
* @return The packet's PUS Service ID.
|
* @return The packet's PUS Service ID.
|
||||||
*/
|
*/
|
||||||
virtual uint8_t getService() const = 0;
|
virtual uint8_t getService() const = 0;
|
||||||
/**
|
/**
|
||||||
* This is a getter for the packet's PUS Service Subtype, which is the
|
* This is a getter for the packet's PUS Service Subtype, which is the
|
||||||
* third byte of the Data Field Header.
|
* third byte of the Data Field Header.
|
||||||
* @return The packet's PUS Service Subtype.
|
* @return The packet's PUS Service Subtype.
|
||||||
*/
|
*/
|
||||||
virtual uint8_t getSubService() const = 0;
|
virtual uint8_t getSubService() const = 0;
|
||||||
/**
|
/**
|
||||||
* The source ID can be used to have an additional identifier, e.g. for different ground
|
* The source ID can be used to have an additional identifier, e.g. for different ground
|
||||||
* station.
|
* station.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual uint16_t getSourceId() const = 0;
|
virtual uint16_t getSourceId() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a getter for a pointer to the packet's Application data.
|
* This is a getter for a pointer to the packet's Application data.
|
||||||
*
|
*
|
||||||
* These are the bytes that follow after the Data Field Header. They form
|
* These are the bytes that follow after the Data Field Header. They form
|
||||||
* the packet's application data.
|
* the packet's application data.
|
||||||
* @return A pointer to the PUS Application Data.
|
* @return A pointer to the PUS Application Data.
|
||||||
*/
|
*/
|
||||||
virtual const uint8_t* getApplicationData() const = 0;
|
virtual const uint8_t* getApplicationData() const = 0;
|
||||||
/**
|
/**
|
||||||
* This method calculates the size of the PUS Application data field.
|
* This method calculates the size of the PUS Application data field.
|
||||||
*
|
*
|
||||||
* It takes the information stored in the CCSDS Packet Data Length field
|
* It takes the information stored in the CCSDS Packet Data Length field
|
||||||
* and subtracts the Data Field Header size and the CRC size.
|
* and subtracts the Data Field Header size and the CRC size.
|
||||||
* @return The size of the PUS Application Data (without Error Control
|
* @return The size of the PUS Application Data (without Error Control
|
||||||
* field)
|
* field)
|
||||||
*/
|
*/
|
||||||
virtual uint16_t getApplicationDataSize() const = 0;
|
virtual uint16_t getApplicationDataSize() const = 0;
|
||||||
/**
|
/**
|
||||||
* This getter returns the Error Control Field of the packet.
|
* This getter returns the Error Control Field of the packet.
|
||||||
*
|
*
|
||||||
* The field is placed after any possible Application Data. If no
|
* The field is placed after any possible Application Data. If no
|
||||||
* Application Data is present there's still an Error Control field. It is
|
* Application Data is present there's still an Error Control field. It is
|
||||||
* supposed to be a 16bit-CRC.
|
* supposed to be a 16bit-CRC.
|
||||||
* @return The PUS Error Control
|
* @return The PUS Error Control
|
||||||
*/
|
*/
|
||||||
virtual uint16_t getErrorControl() const = 0;
|
virtual uint16_t getErrorControl() const = 0;
|
||||||
/**
|
/**
|
||||||
* With this method, the Error Control Field is updated to match the
|
* With this method, the Error Control Field is updated to match the
|
||||||
* current content of the packet.
|
* current content of the packet.
|
||||||
*/
|
*/
|
||||||
virtual void setErrorControl() = 0;
|
virtual void setErrorControl() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate full packet length from application data length.
|
* Calculate full packet length from application data length.
|
||||||
* @param appDataLen
|
* @param appDataLen
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual size_t calculateFullPacketLength(size_t appDataLen) const = 0;
|
virtual size_t calculateFullPacketLength(size_t appDataLen) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a debugging helper method that prints the whole packet content
|
* This is a debugging helper method that prints the whole packet content
|
||||||
|
@ -18,32 +18,32 @@ TcPacketStoredBase::~TcPacketStoredBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TcPacketStoredBase::getData(const uint8_t ** dataPtr,
|
ReturnValue_t TcPacketStoredBase::getData(const uint8_t ** dataPtr,
|
||||||
size_t* dataSize) {
|
size_t* dataSize) {
|
||||||
auto result = this->store->getData(storeAddress, dataPtr, dataSize);
|
auto result = this->store->getData(storeAddress, dataPtr, dataSize);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "TcPacketStoredBase: Could not get data!" << std::endl;
|
sif::warning << "TcPacketStoredBase: Could not get data!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("TcPacketStoredBase: Could not get data!\n");
|
sif::printWarning("TcPacketStoredBase: Could not get data!\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool TcPacketStoredBase::checkAndSetStore() {
|
bool TcPacketStoredBase::checkAndSetStore() {
|
||||||
if (this->store == nullptr) {
|
if (this->store == nullptr) {
|
||||||
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||||
if (this->store == nullptr) {
|
if (this->store == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found!"
|
sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
||||||
@ -68,5 +68,5 @@ void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
store_address_t TcPacketStoredBase::getStoreAddress() {
|
store_address_t TcPacketStoredBase::getStoreAddress() {
|
||||||
return this->storeAddress;
|
return this->storeAddress;
|
||||||
}
|
}
|
||||||
|
@ -34,35 +34,35 @@ public:
|
|||||||
*/
|
*/
|
||||||
TcPacketStoredBase(const uint8_t* data, uint32_t size);
|
TcPacketStoredBase(const uint8_t* data, uint32_t size);
|
||||||
|
|
||||||
virtual~ TcPacketStoredBase();
|
virtual~ TcPacketStoredBase();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter function for the raw data.
|
* Getter function for the raw data.
|
||||||
* @param dataPtr [out] Pointer to the data pointer to set
|
* @param dataPtr [out] Pointer to the data pointer to set
|
||||||
* @param dataSize [out] Address of size to set.
|
* @param dataSize [out] Address of size to set.
|
||||||
* @return -@c RETURN_OK if data was retrieved successfully.
|
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) override;
|
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) override;
|
||||||
|
|
||||||
void setStoreAddress(store_address_t setAddress) override;
|
void setStoreAddress(store_address_t setAddress) override;
|
||||||
store_address_t getStoreAddress() override;
|
store_address_t getStoreAddress() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* With this call, the packet is deleted.
|
* With this call, the packet is deleted.
|
||||||
* It removes itself from the store and sets its data pointer to NULL.
|
* It removes itself from the store and sets its data pointer to NULL.
|
||||||
* @return returncode from deleting the data.
|
* @return returncode from deleting the data.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t deletePacket() = 0;
|
virtual ReturnValue_t deletePacket() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method performs a size check.
|
* This method performs a size check.
|
||||||
* It reads the stored size and compares it with the size entered in the
|
* It reads the stored size and compares it with the size entered in the
|
||||||
* packet header. This class is the optimal place for such a check as it
|
* packet header. This class is the optimal place for such a check as it
|
||||||
* has access to both the header data and the store.
|
* has access to both the header data and the store.
|
||||||
* @return true if size is correct, false if packet is not registered in
|
* @return true if size is correct, false if packet is not registered in
|
||||||
* store or size is incorrect.
|
* store or size is incorrect.
|
||||||
*/
|
*/
|
||||||
virtual bool isSizeCorrect() = 0;
|
virtual bool isSizeCorrect() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
|
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
|
||||||
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmPacketBase::TmPacketBase(uint8_t* setData):
|
TmPacketBase::TmPacketBase(uint8_t* setData): SpacePacketBase(setData) {}
|
||||||
SpacePacketBase(setData) {
|
|
||||||
}
|
|
||||||
|
|
||||||
TmPacketBase::~TmPacketBase() {
|
TmPacketBase::~TmPacketBase() {
|
||||||
//Nothing to do.
|
//Nothing to do.
|
||||||
|
@ -23,7 +23,7 @@ struct PUSTmDataFieldHeaderPusA {
|
|||||||
uint8_t service_type;
|
uint8_t service_type;
|
||||||
uint8_t service_subtype;
|
uint8_t service_subtype;
|
||||||
uint8_t subcounter;
|
uint8_t subcounter;
|
||||||
// uint8_t destination;
|
// uint8_t destination;
|
||||||
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,8 +51,7 @@ public:
|
|||||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||||
sizeof(PUSTmDataFieldHeaderPusA) + 2);
|
sizeof(PUSTmDataFieldHeaderPusA) + 2);
|
||||||
//! Maximum size of a TM Packet in this mission.
|
//! Maximum size of a TM Packet in this mission.
|
||||||
//! TODO: Make this dependant on a config variable.
|
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE;
|
||||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
||||||
|
@ -53,8 +53,7 @@ public:
|
|||||||
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
static const uint32_t TM_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||||
sizeof(PUSTmDataFieldHeaderPusC) + 2);
|
sizeof(PUSTmDataFieldHeaderPusC) + 2);
|
||||||
//! Maximum size of a TM Packet in this mission.
|
//! Maximum size of a TM Packet in this mission.
|
||||||
//! TODO: Make this dependant on a config variable.
|
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE;
|
||||||
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor.
|
* This is the default constructor.
|
||||||
|
Loading…
Reference in New Issue
Block a user