Merge pull request 'Space Packet Parser CRC Check' (#41) from meier/space-packet-crc-check into main

Reviewed-on: #41
This commit is contained in:
Jakob Meier 2024-11-15 10:21:28 +01:00
commit c740721e34
46 changed files with 107 additions and 80 deletions

View File

@ -11,12 +11,12 @@ PduHeaderReader::PduHeaderReader(const uint8_t *pduBuf, size_t maxSize) {
} }
ReturnValue_t PduHeaderReader::parseData() { ReturnValue_t PduHeaderReader::parseData() {
if (pointers.rawPtr == nullptr) {
return returnvalue::FAILED;
}
if (maxSize < 7) { if (maxSize < 7) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
if (pointers.rawPtr == nullptr) {
return returnvalue::FAILED;
}
pointers.fixedHeader = pointers.fixedHeader =
reinterpret_cast<PduHeaderFixedStruct *>(const_cast<uint8_t *>(pointers.rawPtr)); reinterpret_cast<PduHeaderFixedStruct *>(const_cast<uint8_t *>(pointers.rawPtr));
sourceIdRaw = &pointers.fixedHeader->variableFieldsStart; sourceIdRaw = &pointers.fixedHeader->variableFieldsStart;

View File

@ -66,9 +66,9 @@ static constexpr uint8_t FSR_DENY_DIR_NOT_ALLOWED = 0b0010;
class FilestoreTlvBase : public TlvIF { class FilestoreTlvBase : public TlvIF {
public: public:
explicit FilestoreTlvBase(cfdp::StringLv& firstFileName) : firstFileName(firstFileName) {}; explicit FilestoreTlvBase(cfdp::StringLv& firstFileName) : firstFileName(firstFileName){};
FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::StringLv& firstFileName) FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::StringLv& firstFileName)
: actionCode(actionCode), firstFileName(firstFileName) {}; : actionCode(actionCode), firstFileName(firstFileName){};
ReturnValue_t commonSerialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t commonSerialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness, bool isResponse = false, Endianness streamEndianness, bool isResponse = false,

View File

@ -5,7 +5,7 @@
class TlvIF : public SerializeIF { class TlvIF : public SerializeIF {
public: public:
virtual ~TlvIF() {}; virtual ~TlvIF(){};
virtual uint8_t getLengthField() const = 0; virtual uint8_t getLengthField() const = 0;
virtual cfdp::TlvType getType() const = 0; virtual cfdp::TlvType getType() const = 0;

View File

@ -29,7 +29,7 @@ class Jgm3Model {
lastExecutionTime.tv_sec = 0; lastExecutionTime.tv_sec = 0;
lastExecutionTime.tv_usec = 0; lastExecutionTime.tv_usec = 0;
} }
virtual ~Jgm3Model() {}; virtual ~Jgm3Model(){};
// double acsNavOrbit(double posECF[3],double velECF[3],timeval gpsTime); // double acsNavOrbit(double posECF[3],double velECF[3],timeval gpsTime);

View File

@ -10,7 +10,7 @@
*/ */
class PoolDataSetIF : virtual public DataSetIF, virtual public ReadCommitIF { class PoolDataSetIF : virtual public DataSetIF, virtual public ReadCommitIF {
public: public:
virtual ~PoolDataSetIF() {}; virtual ~PoolDataSetIF(){};
/** /**
* @brief Most underlying data structures will have a pool like structure * @brief Most underlying data structures will have a pool like structure

View File

@ -5,7 +5,7 @@
class SharedDataSetIF { class SharedDataSetIF {
public: public:
virtual ~SharedDataSetIF() {}; virtual ~SharedDataSetIF(){};
private: private:
virtual ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType, virtual ReturnValue_t lockDataset(MutexIF::TimeoutType timeoutType,

View File

@ -9,7 +9,7 @@ class MutexIF;
*/ */
class AccessPoolManagerIF { class AccessPoolManagerIF {
public: public:
virtual ~AccessPoolManagerIF() {}; virtual ~AccessPoolManagerIF(){};
virtual MutexIF* getLocalPoolMutex() = 0; virtual MutexIF* getLocalPoolMutex() = 0;

View File

@ -44,7 +44,7 @@ class HasLocalDataPoolIF {
friend class HasLocalDpIFUserAttorney; friend class HasLocalDpIFUserAttorney;
public: public:
virtual ~HasLocalDataPoolIF() {}; virtual ~HasLocalDataPoolIF(){};
static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID; static constexpr uint32_t INVALID_LPID = localpool::INVALID_LPID;

View File

@ -257,7 +257,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE; MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE;
union DataId { union DataId {
DataId() : sid() {}; DataId() : sid(){};
sid_t sid; sid_t sid;
lp_id_t localPoolId; lp_id_t localPoolId;
}; };

View File

@ -17,7 +17,8 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t
if (hkOwner == nullptr) { if (hkOwner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl; sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
<< "invalid!" << std::endl;
#else #else
sif::printError( sif::printError(
"LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
@ -186,8 +187,8 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size
SerializeAdapter::serialize(&currentPoolId, buffer, size, maxSize, streamEndianness); SerializeAdapter::serialize(&currentPoolId, buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " << "Serialization error!" sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
<< std::endl; << "Serialization error!" << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"LocalPoolDataSetBase::serializeLocalPoolIds: " "LocalPoolDataSetBase::serializeLocalPoolIds: "

View File

@ -17,8 +17,8 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO
} }
if (hkOwner == nullptr) { if (hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool " << "owner is a invalid!" sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
<< std::endl; << "owner is a invalid!" << std::endl;
#endif #endif
return; return;
} }

View File

@ -76,7 +76,7 @@ class LocalPoolVariable : public LocalPoolObjectBase {
LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr, LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
virtual ~LocalPoolVariable() {}; virtual ~LocalPoolVariable(){};
/** /**
* @brief This is the local copy of the data pool entry. * @brief This is the local copy of the data pool entry.

View File

@ -88,7 +88,7 @@ class LocalPoolVector : public LocalPoolObjectBase {
* @details If commit() was not called, the local value is * @details If commit() was not called, the local value is
* discarded and not written back to the data pool. * discarded and not written back to the data pool.
*/ */
~LocalPoolVector() {}; ~LocalPoolVector(){};
/** /**
* @brief The operation returns the number of array entries * @brief The operation returns the number of array entries
* in this variable. * in this variable.

View File

@ -6,7 +6,7 @@
*/ */
class MarkChangedIF { class MarkChangedIF {
public: public:
virtual ~MarkChangedIF() {}; virtual ~MarkChangedIF(){};
virtual bool hasChanged() const = 0; virtual bool hasChanged() const = 0;
virtual void setChanged(bool changed) = 0; virtual void setChanged(bool changed) = 0;

View File

@ -28,7 +28,7 @@ using address_t = uint32_t;
*/ */
class CookieIF { class CookieIF {
public: public:
virtual ~CookieIF() {}; virtual ~CookieIF(){};
}; };
#endif /* FSFW_DEVICEHANDLER_COOKIE_H_ */ #endif /* FSFW_DEVICEHANDLER_COOKIE_H_ */

View File

@ -243,8 +243,8 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(EventMessage* ev
if (owner == nullptr) { if (owner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::" << "isFdirInActionOrAreWeFaulty: Owner not set!" sif::error << "DeviceHandlerFailureIsolation::"
<< std::endl; << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl;
#endif #endif
return false; return false;
} }

View File

@ -62,7 +62,8 @@ ReturnValue_t FailureIsolationBase::initialize() {
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent); ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
if (parentIF == nullptr) { if (parentIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Parent object " << "invalid" << std::endl; sif::error << "FailureIsolationBase::intialize: Parent object "
<< "invalid" << std::endl;
sif::error << "Make sure it implements ConfirmsFailuresIF" << std::endl; sif::error << "Make sure it implements ConfirmsFailuresIF" << std::endl;
#else #else
sif::printError("FailureIsolationBase::intialize: Parent object invalid\n"); sif::printError("FailureIsolationBase::intialize: Parent object invalid\n");

View File

@ -23,7 +23,7 @@ class HousekeepingSnapshot : public SerializeIF {
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolDataSetBase* dataSetPtr) HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolDataSetBase* dataSetPtr)
: timeStamp(reinterpret_cast<uint8_t*>(cdsShort)), : timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
timeStampSize(sizeof(CCSDSTime::CDS_short)), timeStampSize(sizeof(CCSDSTime::CDS_short)),
updateData(dataSetPtr) {}; updateData(dataSetPtr){};
/** /**
* Update packet constructor for datasets. * Update packet constructor for datasets.
@ -32,7 +32,7 @@ class HousekeepingSnapshot : public SerializeIF {
* @param dataSetPtr Pointer to the dataset instance to deserialize the data into * @param dataSetPtr Pointer to the dataset instance to deserialize the data into
*/ */
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolDataSetBase* dataSetPtr) HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolDataSetBase* dataSetPtr)
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr) {}; : timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
/** /**
* Update packet constructor for pool variables. * Update packet constructor for pool variables.
@ -43,7 +43,7 @@ class HousekeepingSnapshot : public SerializeIF {
HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolObjectBase* dataSetPtr) HousekeepingSnapshot(CCSDSTime::CDS_short* cdsShort, LocalPoolObjectBase* dataSetPtr)
: timeStamp(reinterpret_cast<uint8_t*>(cdsShort)), : timeStamp(reinterpret_cast<uint8_t*>(cdsShort)),
timeStampSize(sizeof(CCSDSTime::CDS_short)), timeStampSize(sizeof(CCSDSTime::CDS_short)),
updateData(dataSetPtr) {}; updateData(dataSetPtr){};
/** /**
* Update packet constructor for pool variables. * Update packet constructor for pool variables.
@ -52,7 +52,7 @@ class HousekeepingSnapshot : public SerializeIF {
* @param dataSetPtr * @param dataSetPtr
*/ */
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolObjectBase* dataSetPtr) HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolObjectBase* dataSetPtr)
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr) {}; : timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {

View File

@ -37,7 +37,7 @@ class CommandMessageIF {
//! Parameter 1 should contain the error code //! Parameter 1 should contain the error code
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2); static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2);
virtual ~CommandMessageIF() {}; virtual ~CommandMessageIF(){};
/** /**
* A command message shall have a uint16_t command ID field. * A command message shall have a uint16_t command ID field.

View File

@ -5,7 +5,7 @@
#include <fsfw/objectmanager/frameworkObjects.h> #include <fsfw/objectmanager/frameworkObjects.h>
struct MqArgs { struct MqArgs {
MqArgs() {}; MqArgs(){};
MqArgs(object_id_t objectId, void* args = nullptr) : objectId(objectId), args(args) {} MqArgs(object_id_t objectId, void* args = nullptr) : objectId(objectId), args(args) {}
object_id_t objectId = objects::NO_OBJECT; object_id_t objectId = objects::NO_OBJECT;
void* args = nullptr; void* args = nullptr;

View File

@ -40,7 +40,7 @@ class ObjectManagerIF {
/** /**
* @brief This is the empty virtual destructor as requested by C++ interfaces. * @brief This is the empty virtual destructor as requested by C++ interfaces.
*/ */
virtual ~ObjectManagerIF(void) {}; virtual ~ObjectManagerIF(void){};
/** /**
* @brief With this call, new objects are inserted to the list. * @brief With this call, new objects are inserted to the list.
* @details The implementation shall return an error code in case the * @details The implementation shall return an error code in case the

View File

@ -321,8 +321,8 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
// Possible configuration error, too much data or/and data coming in too fast, // Possible configuration error, too much data or/and data coming in too fast,
// requiring larger buffers // requiring larger buffers
sif::warning << "TcpTmTcServer::handleServerOperation: Ring buffer reached " << "fill count" sif::warning << "TcpTmTcServer::handleServerOperation: Ring buffer reached "
<< std::endl; << "fill count" << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"TcpTmTcServer::handleServerOperation: Ring buffer reached " "TcpTmTcServer::handleServerOperation: Ring buffer reached "

View File

@ -49,8 +49,8 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t*
if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG) != returnvalue::OK) { SerializeIF::Endianness::BIG) != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " << "Invalid data." sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: "
<< std::endl; << "Invalid data." << std::endl;
#else #else
sif::printError( sif::printError(
"Service20ParameterManagement::" "Service20ParameterManagement::"

View File

@ -196,8 +196,8 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Service3Housekeeping::handleReply: Invalid reply with " << "reply command " sif::warning << "Service3Housekeeping::handleReply: Invalid reply with "
<< command << std::endl; << "reply command " << command << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"Service3Housekeeping::handleReply: Invalid reply with " "Service3Housekeeping::handleReply: Invalid reply with "

View File

@ -9,7 +9,7 @@
class RMAPChannelIF { class RMAPChannelIF {
public: public:
virtual ~RMAPChannelIF() {}; virtual ~RMAPChannelIF(){};
/** /**
* Reset an RMAP channel * Reset an RMAP channel
* *

View File

@ -12,7 +12,8 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig,
spillsToHigherPools(spillsToHigherPools) { spillsToHigherPools(spillsToHigherPools) {
if (NUMBER_OF_SUBPOOLS == 0) { if (NUMBER_OF_SUBPOOLS == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPool::LocalPool: Passed pool configuration is " << " invalid!" << std::endl; sif::error << "LocalPool::LocalPool: Passed pool configuration is "
<< " invalid!" << std::endl;
#endif #endif
} }
max_subpools_t index = 0; max_subpools_t index = 0;

View File

@ -38,9 +38,10 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator<ModeListEntry> iter,
if (!existsModeTable(iter->getTableId())) { if (!existsModeTable(iter->getTableId())) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
using namespace std; using namespace std;
sif::warning << "Subsystem::checkSequence: " << "Object " << setfill('0') << hex << "0x" sif::warning << "Subsystem::checkSequence: "
<< setw(8) << getObjectId() << setw(0) << ": Mode table for mode ID " << "0x" << "Object " << setfill('0') << hex << "0x" << setw(8) << getObjectId()
<< setw(8) << iter->getTableId() << " does not exist" << dec << endl; << setw(0) << ": Mode table for mode ID "
<< "0x" << setw(8) << iter->getTableId() << " does not exist" << dec << endl;
#endif #endif
return TABLE_DOES_NOT_EXIST; return TABLE_DOES_NOT_EXIST;
} else { } else {

View File

@ -12,7 +12,7 @@
struct TableSequenceBase { struct TableSequenceBase {
public: public:
TableSequenceBase(Mode_t mode, ArrayList<ModeListEntry> *table) : mode(mode), table(table) {}; TableSequenceBase(Mode_t mode, ArrayList<ModeListEntry> *table) : mode(mode), table(table){};
Mode_t mode; Mode_t mode;
ArrayList<ModeListEntry> *table; ArrayList<ModeListEntry> *table;
bool inStore = false; bool inStore = false;
@ -21,7 +21,7 @@ struct TableSequenceBase {
struct TableEntry : public TableSequenceBase { struct TableEntry : public TableSequenceBase {
public: public:
TableEntry(Mode_t mode, ArrayList<ModeListEntry> *table) : TableSequenceBase(mode, table) {}; TableEntry(Mode_t mode, ArrayList<ModeListEntry> *table) : TableSequenceBase(mode, table){};
}; };
struct SequenceEntry : public TableSequenceBase { struct SequenceEntry : public TableSequenceBase {

View File

@ -34,7 +34,7 @@ class ExecutableObjectIF {
* a reference to the executing task * a reference to the executing task
* @param task_ Pointer to the taskIF of this task * @param task_ Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task_) {}; virtual void setTaskIF(PeriodicTaskIF* task_){};
/** /**
* This function should be called after the object was assigned to a * This function should be called after the object was assigned to a

View File

@ -101,7 +101,8 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
// Continue for now but print error output. // Continue for now but print error output.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedSlotSequence::checkSequence:" << " Custom check failed!" << std::endl; sif::error << "FixedSlotSequence::checkSequence:"
<< " Custom check failed!" << std::endl;
#endif #endif
} }
} }

View File

@ -30,7 +30,7 @@ class SemaphoreIF {
BLOCKING //!< Block indefinitely until the mutex becomes available. BLOCKING //!< Block indefinitely until the mutex becomes available.
}; };
virtual ~SemaphoreIF() {}; virtual ~SemaphoreIF(){};
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF; static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
//! Semaphore timeout //! Semaphore timeout

View File

@ -212,8 +212,8 @@ class CCSDSTime {
static uint32_t subsecondsToMicroseconds(uint16_t subseconds); static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
private: private:
CCSDSTime() {}; CCSDSTime(){};
virtual ~CCSDSTime() {}; virtual ~CCSDSTime(){};
/** /**
* checks a ccs time stream for validity * checks a ccs time stream for validity
* *

View File

@ -22,7 +22,7 @@ struct PusTmSecHeader {
struct PusTmParams { struct PusTmParams {
PusTmParams() = default; PusTmParams() = default;
explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader) {}; explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){};
PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data) PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data)
: secHeader(secHeader), sourceData(&data) {} : secHeader(secHeader), sourceData(&data) {}
PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen) PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen)

View File

@ -1,3 +1,4 @@
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/serviceinterface/ServiceInterface.h> #include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcservices/SpacePacketParser.h> #include <fsfw/tmtcservices/SpacePacketParser.h>
@ -6,6 +7,8 @@
SpacePacketParser::SpacePacketParser(std::vector<uint16_t> validPacketIds) SpacePacketParser::SpacePacketParser(std::vector<uint16_t> validPacketIds)
: validPacketIds(validPacketIds) {} : validPacketIds(validPacketIds) {}
void SpacePacketParser::enableCrcCheck() { checkCrc = true; }
ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize, ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize,
FoundPacketInfo& packetInfo) { FoundPacketInfo& packetInfo) {
if (buffer == nullptr or nextStartIdx > maxSize) { if (buffer == nullptr or nextStartIdx > maxSize) {
@ -31,6 +34,11 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const
} }
*buffer += packetInfo.sizeFound; *buffer += packetInfo.sizeFound;
packetInfo.startIdx = localIdx + amountRead; packetInfo.startIdx = localIdx + amountRead;
if (checkCrc) {
if (CRC::crc16ccitt(bufPtr + localIdx, packetSize) != 0) {
return CRC_CHECK_FAILED;
}
}
nextStartIdx = localIdx + amountRead + packetInfo.sizeFound; nextStartIdx = localIdx + amountRead + packetInfo.sizeFound;
amountRead = nextStartIdx; amountRead = nextStartIdx;
return result; return result;

View File

@ -25,6 +25,13 @@ class SpacePacketParser {
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SPACE_PACKET_PARSER; static constexpr uint8_t INTERFACE_ID = CLASS_ID::SPACE_PACKET_PARSER;
static constexpr ReturnValue_t NO_PACKET_FOUND = MAKE_RETURN_CODE(0x00); static constexpr ReturnValue_t NO_PACKET_FOUND = MAKE_RETURN_CODE(0x00);
static constexpr ReturnValue_t SPLIT_PACKET = MAKE_RETURN_CODE(0x01); static constexpr ReturnValue_t SPLIT_PACKET = MAKE_RETURN_CODE(0x01);
static constexpr ReturnValue_t CRC_CHECK_FAILED = MAKE_RETURN_CODE(0x02);
/**
* brief If the last to bytes of a space packet hold a CRC16, this function can be used to enable
* the CRC16 check when parsing the data.
*/
void enableCrcCheck();
/** /**
* @brief Parser constructor. * @brief Parser constructor.
@ -61,6 +68,7 @@ class SpacePacketParser {
std::vector<uint16_t> validPacketIds; std::vector<uint16_t> validPacketIds;
size_t nextStartIdx = 0; size_t nextStartIdx = 0;
size_t amountRead = 0; size_t amountRead = 0;
bool checkCrc = false;
}; };
#endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */ #endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */

View File

@ -34,7 +34,8 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(unsigned int maxNumberOfPa
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of "
<< "packets stored exceeds limits. " << "Keeping default value." << std::endl; << "packets stored exceeds limits. "
<< "Keeping default value." << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -78,13 +79,15 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) {
result = handleTc(); result = handleTc();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl; sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TCs" << std::endl;
#endif #endif
} }
result = handleTm(); result = handleTm();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl; sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TMs" << std::endl;
#endif #endif
} }
return result; return result;

View File

@ -15,7 +15,7 @@ class GpioCookie;
*/ */
class GpioIF { class GpioIF {
public: public:
virtual ~GpioIF() {}; virtual ~GpioIF(){};
/** /**
* @brief Called by the GPIO using object. * @brief Called by the GPIO using object.

View File

@ -60,7 +60,7 @@ class GpioBase {
gpio::Levels initValue) gpio::Levels initValue)
: gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {} : gpioType(gpioType), consumer(consumer), direction(direction), initValue(initValue) {}
virtual ~GpioBase() {}; virtual ~GpioBase(){};
// Can be used to cast GpioBase to a concrete child implementation // Can be used to cast GpioBase to a concrete child implementation
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;

View File

@ -418,8 +418,8 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO " sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO "
"definition with ID " "definition with ID "
<< gpioIdToCheck << " detected. " << "Duplicate will be removed from map to add" << gpioIdToCheck << " detected. "
<< std::endl; << "Duplicate will be removed from map to add" << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition " "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition "

View File

@ -49,7 +49,8 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
if (not statusPair.second) { if (not statusPair.second) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::initializeInterface: Failed to insert device with address " sif::error << "I2cComIF::initializeInterface: Failed to insert device with address "
<< i2cAddress << "to I2C device " << "map" << std::endl; << i2cAddress << "to I2C device "
<< "map" << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -90,8 +91,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
<< std::endl; << "registered in i2cDeviceMap" << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }

View File

@ -197,8 +197,9 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
if (result == MutexIF::MUTEX_TIMEOUT) { if (result == MutexIF::MUTEX_TIMEOUT) {
sif::error << "SpiComIF::sendMessage: Lock timeout" << std::endl; sif::error << "SpiComIF::sendMessage: Lock timeout" << std::endl;
} else { } else {
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " << "0x" << std::hex sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code "
<< std::setfill('0') << std::setw(4) << result << std::dec << std::endl; << "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec
<< std::endl;
} }
#else #else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result); sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result);
@ -306,8 +307,9 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " << "0x" << std::hex sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code "
<< std::setfill('0') << std::setw(4) << result << std::dec << std::endl; << "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec
<< std::endl;
#else #else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result); sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result);
#endif #endif

View File

@ -12,10 +12,10 @@ namespace stm32h7 {
* and the second entry is the pin number * and the second entry is the pin number
*/ */
struct GpioCfg { struct GpioCfg {
GpioCfg() : port(nullptr), pin(0), altFnc(0) {}; GpioCfg() : port(nullptr), pin(0), altFnc(0){};
GpioCfg(GPIO_TypeDef* port, uint16_t pin, uint8_t altFnc = 0) GpioCfg(GPIO_TypeDef* port, uint16_t pin, uint8_t altFnc = 0)
: port(port), pin(pin), altFnc(altFnc) {}; : port(port), pin(pin), altFnc(altFnc){};
GPIO_TypeDef* port; GPIO_TypeDef* port;
uint16_t pin; uint16_t pin;
uint8_t altFnc; uint8_t altFnc;

View File

@ -37,7 +37,7 @@ struct MspCfgBase {
}; };
struct MspPollingConfigStruct : public MspCfgBase { struct MspPollingConfigStruct : public MspCfgBase {
MspPollingConfigStruct() : MspCfgBase() {}; MspPollingConfigStruct() : MspCfgBase(){};
MspPollingConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso, MspPollingConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso,
mspCb cleanupCb = nullptr, mspCb setupCb = nullptr) mspCb cleanupCb = nullptr, mspCb setupCb = nullptr)
: MspCfgBase(sck, mosi, miso, cleanupCb, setupCb) {} : MspCfgBase(sck, mosi, miso, cleanupCb, setupCb) {}
@ -46,7 +46,7 @@ struct MspPollingConfigStruct : public MspCfgBase {
/* A valid instance of this struct must be passed to the MSP initialization function as a void* /* A valid instance of this struct must be passed to the MSP initialization function as a void*
argument */ argument */
struct MspIrqConfigStruct : public MspPollingConfigStruct { struct MspIrqConfigStruct : public MspPollingConfigStruct {
MspIrqConfigStruct() : MspPollingConfigStruct() {}; MspIrqConfigStruct() : MspPollingConfigStruct(){};
MspIrqConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso, MspIrqConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso,
mspCb cleanupCb = nullptr, mspCb setupCb = nullptr) mspCb cleanupCb = nullptr, mspCb setupCb = nullptr)
: MspPollingConfigStruct(sck, mosi, miso, cleanupCb, setupCb) {} : MspPollingConfigStruct(sck, mosi, miso, cleanupCb, setupCb) {}
@ -64,7 +64,7 @@ struct MspIrqConfigStruct : public MspPollingConfigStruct {
/* A valid instance of this struct must be passed to the MSP initialization function as a void* /* A valid instance of this struct must be passed to the MSP initialization function as a void*
argument */ argument */
struct MspDmaConfigStruct : public MspIrqConfigStruct { struct MspDmaConfigStruct : public MspIrqConfigStruct {
MspDmaConfigStruct() : MspIrqConfigStruct() {}; MspDmaConfigStruct() : MspIrqConfigStruct(){};
MspDmaConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso, MspDmaConfigStruct(stm32h7::GpioCfg sck, stm32h7::GpioCfg mosi, stm32h7::GpioCfg miso,
mspCb cleanupCb = nullptr, mspCb setupCb = nullptr) mspCb cleanupCb = nullptr, mspCb setupCb = nullptr)
: MspIrqConfigStruct(sck, mosi, miso, cleanupCb, setupCb) {} : MspIrqConfigStruct(sck, mosi, miso, cleanupCb, setupCb) {}

View File

@ -13,8 +13,8 @@ TEST_CASE("Array List", "[containers]") {
ArrayList<uint16_t> list(20); ArrayList<uint16_t> list(20);
struct TestClass { struct TestClass {
public: public:
TestClass() {}; TestClass(){};
TestClass(uint32_t number1, uint64_t number2) : number1(number1), number2(number2) {}; TestClass(uint32_t number1, uint64_t number2) : number1(number1), number2(number2){};
uint32_t number1 = -1; uint32_t number1 = -1;
uint64_t number2 = -1; uint64_t number2 = -1;
bool operator==(const TestClass& other) { bool operator==(const TestClass& other) {

View File

@ -97,9 +97,9 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon
class TestClass { class TestClass {
public: public:
TestClass() {}; TestClass(){};
TestClass(uint32_t number1, uint64_t number2) : number1(number1), number2(number2) {}; TestClass(uint32_t number1, uint64_t number2) : number1(number1), number2(number2){};
~TestClass() {}; ~TestClass(){};
bool operator==(const TestClass& lhs) { bool operator==(const TestClass& lhs) {
return ((this->number1 == lhs.number1) and (this->number2 == lhs.number2)); return ((this->number1 == lhs.number1) and (this->number2 == lhs.number2));