From 9131ca688b5071f76e141e2bd312211c5c1bf8d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 15:01:10 +0200 Subject: [PATCH 01/43] make two helper functions protected --- src/fsfw/datapoollocal/LocalDataPoolManager.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 7db079f6..8f369ea0 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -243,13 +243,14 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces LocalDataPoolManager* getPoolManagerHandle() override; ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override; ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override; - ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override; ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override; - ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); protected: + ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); + ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); + /** Core data structure for the actual pool data */ localpool::DataPool localPoolMap; /** Every housekeeping data manager has a mutex to protect access From 64a7fde30171bfd4711fb01b349184f9777817cf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 15:16:54 +0200 Subject: [PATCH 02/43] this is annoying --- src/fsfw/pus/Service11TelecommandScheduling.h | 5 +++-- src/fsfw/pus/Service11TelecommandScheduling.tpp | 14 +++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 2a14401b..57ba4982 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -38,8 +38,9 @@ class Service11TelecommandScheduling final : public PusServiceBase { static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11; static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 1); - static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 2); - static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2); + static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7f60f7e8..3cf24b11 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -571,6 +571,9 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (result != returnvalue::OK) { return result; } + if(fromTimestamp > toTimestamp) { + return INVALID_TIME_WINDOW; + } itBegin = telecommandMap.begin(); itEnd = telecommandMap.begin(); @@ -586,17 +589,6 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr default: return returnvalue::FAILED; } - - // additional security check, this should never be true - if (itBegin > itEnd) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; -#else - sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); -#endif - return returnvalue::FAILED; - } - // the map range should now be set according to the sent filter. return returnvalue::OK; } From 7345c18b0439e27169a02e4a1ce98f6837175635 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Aug 2022 16:26:18 +0200 Subject: [PATCH 03/43] small fix which allows sending action reply immediately --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 525a3dcc..c4ce7781 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1320,18 +1320,22 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); + MessageQueueId_t prevRecipient = MessageQueueIF::NO_QUEUE; if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { result = COMMAND_ALREADY_SENT; } else { + prevRecipient = iter->second.sendReplyTo; + iter->second.sendReplyTo = commandedBy; result = buildCommandFromCommand(actionId, data, size); } if (result == returnvalue::OK) { - iter->second.sendReplyTo = commandedBy; iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; cookieInfo.state = COOKIE_WRITE_READY; + } else { + iter->second.sendReplyTo = prevRecipient; } return result; } From 28ecd0e5c6304a91bae9840159d200ed8361e68a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 08:51:12 +0200 Subject: [PATCH 04/43] bugfix for SP parser --- src/fsfw/osal/common/TcpTmTcServer.cpp | 19 ++++----- src/fsfw/tmtcservices/SpacePacketParser.cpp | 45 +++++++++++---------- src/fsfw/tmtcservices/SpacePacketParser.h | 18 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index f9cb923e..f1174734 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -161,7 +161,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) { while (true) { ssize_t retval = recv(connSocket, reinterpret_cast(receptionBuffer.data()), - receptionBuffer.capacity(), tcpConfig.tcpFlags); + receptionBuffer.size(), tcpConfig.tcpFlags); if (retval == 0) { size_t availableReadData = ringBuffer.getAvailableReadData(); if (availableReadData > lastRingBufferSize) { @@ -335,31 +335,28 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.readData(receptionBuffer.data(), readAmount, true); const uint8_t* bufPtr = receptionBuffer.data(); - const uint8_t** bufPtrPtr = &bufPtr; - size_t startIdx = 0; - size_t foundSize = 0; - size_t readLen = 0; - while (readLen < readAmount) { + FoundPacketInfo info; + ParsingState parseState; + while (parseState.amountRead < readAmount) { if (spacePacketParser == nullptr) { return returnvalue::FAILED; } - result = - spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen); + result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info, parseState); switch (result) { case (SpacePacketParser::NO_PACKET_FOUND): case (SpacePacketParser::SPLIT_PACKET): { break; } case (returnvalue::OK): { - result = handleTcReception(receptionBuffer.data() + startIdx, foundSize); + result = handleTcReception(receptionBuffer.data() + info.startIdx, info.sizeFound); if (result != returnvalue::OK) { status = result; } } } - ringBuffer.deleteData(foundSize); + ringBuffer.deleteData(info.sizeFound); lastRingBufferSize = ringBuffer.getAvailableReadData(); - std::memset(receptionBuffer.data() + startIdx, 0, foundSize); + // std::memset(receptionBuffer.data() + startIdx, 0, foundSize); } return status; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index b8364138..16ee5dac 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -7,16 +7,16 @@ SpacePacketParser::SpacePacketParser(std::vector validPacketIds) : validPacketIds(validPacketIds) {} ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - size_t& startIndex, size_t& foundSize) { + FoundPacketInfo& packetInfo, + ParsingState& parsingState) { const uint8_t** tempPtr = &buffer; - size_t readLen = 0; - return parseSpacePackets(tempPtr, maxSize, startIndex, foundSize, readLen); + return parseSpacePackets(tempPtr, maxSize, packetInfo, parsingState); } ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - size_t& startIndex, size_t& foundSize, - size_t& readLen) { - if (buffer == nullptr or maxSize < 5) { + FoundPacketInfo& packetInfo, + ParsingState& parsingState) { + if (buffer == nullptr or parsingState.nextStartIdx > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl; #else @@ -26,35 +26,36 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const } const uint8_t* bufPtr = *buffer; - auto verifyLengthField = [&](size_t idx) { - uint16_t lengthField = bufPtr[idx + 4] << 8 | bufPtr[idx + 5]; + auto verifyLengthField = [&](size_t localIdx) { + uint16_t lengthField = (bufPtr[localIdx + 4] << 8) | bufPtr[localIdx + 5]; size_t packetSize = lengthField + 7; - startIndex = idx; ReturnValue_t result = returnvalue::OK; if (lengthField == 0) { // Skip whole header for now - foundSize = 6; + packetInfo.sizeFound = 6; result = NO_PACKET_FOUND; - } else if (packetSize + idx > maxSize) { + } else if (packetSize + localIdx + parsingState.amountRead > maxSize) { // Don't increment buffer and read length here, user has to decide what to do - foundSize = packetSize; + packetInfo.sizeFound = packetSize; return SPLIT_PACKET; } else { - foundSize = packetSize; + packetInfo.sizeFound = packetSize; } - *buffer += foundSize; - readLen += idx + foundSize; + *buffer += packetInfo.sizeFound; + packetInfo.startIdx = localIdx + parsingState.amountRead; + parsingState.nextStartIdx = localIdx + parsingState.amountRead + packetInfo.sizeFound; + parsingState.amountRead = parsingState.nextStartIdx; return result; }; size_t idx = 0; // Space packet ID as start marker if (validPacketIds.size() > 0) { - while (idx < maxSize - 5) { - uint16_t currentPacketId = bufPtr[idx] << 8 | bufPtr[idx + 1]; + while (idx + parsingState.amountRead < maxSize - 5) { + uint16_t currentPacketId = (bufPtr[idx] << 8) | bufPtr[idx + 1]; if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) != validPacketIds.end()) { - if (idx + 5 >= maxSize) { + if (idx + parsingState.amountRead >= maxSize - 5) { return SPLIT_PACKET; } return verifyLengthField(idx); @@ -62,10 +63,10 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const idx++; } } - startIndex = 0; - foundSize = maxSize; - *buffer += foundSize; - readLen += foundSize; + parsingState.nextStartIdx = maxSize; + packetInfo.sizeFound = maxSize; + parsingState.amountRead = maxSize; + *buffer += maxSize; return NO_PACKET_FOUND; } // Assume that the user verified a valid start of a space packet diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 93f90afe..394083b2 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -7,6 +7,16 @@ #include "fsfw/container/DynamicFIFO.h" #include "fsfw/returnvalues/FwClassIds.h" +struct FoundPacketInfo { + size_t startIdx = 0; + size_t sizeFound = 0; +}; + +struct ParsingState { + size_t nextStartIdx = 0; + size_t amountRead = 0; +}; + /** * @brief This small helper class scans a given buffer for space packets. * Can be used if space packets are serialized in a tightly packed frame. @@ -53,8 +63,8 @@ class SpacePacketParser { * will be assigned. * -@c returnvalue::OK if a packet was found */ - ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, size_t& startIndex, - size_t& foundSize, size_t& readLen); + ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, + FoundPacketInfo& packetInfo, ParsingState& parsingState); /** * Parse a given frame for space packets @@ -69,8 +79,8 @@ class SpacePacketParser { * detected packet * -@c returnvalue::OK if a packet was found */ - ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, size_t& startIndex, - size_t& foundSize); + ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, + FoundPacketInfo& packetInfo, ParsingState& parsingState); private: std::vector validPacketIds; From 7ae82a5cb4287e70ff13ef8da3f9264096c1879e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 08:58:18 +0200 Subject: [PATCH 05/43] do not cache previous recipient --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index c4ce7781..efb535a5 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1320,13 +1320,11 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); - MessageQueueId_t prevRecipient = MessageQueueIF::NO_QUEUE; if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { result = COMMAND_ALREADY_SENT; } else { - prevRecipient = iter->second.sendReplyTo; iter->second.sendReplyTo = commandedBy; result = buildCommandFromCommand(actionId, data, size); } @@ -1334,8 +1332,6 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; cookieInfo.state = COOKIE_WRITE_READY; - } else { - iter->second.sendReplyTo = prevRecipient; } return result; } From 7d3223d766bcd2b0a693885f9db899d8bd1a841a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:44:57 +0200 Subject: [PATCH 06/43] add comment blocks --- src/fsfw/devicehandlers/DeviceHandlerBase.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index ff1c7dc1..792e70ad 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1052,8 +1052,23 @@ class DeviceHandlerBase : public DeviceHandlerIF, bool isAwaitingReply(); + /** + * Wrapper function for @handleDeviceTm which wraps the raw buffer with @SerialBufferAdapter. + * For interpreted data, prefer the other function. + * @param rawData + * @param rawDataLen + * @param replyId + * @param forceDirectTm + */ void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, bool forceDirectTm = false); + /** + * Can be used to handle Service 8 replies. This will also generate the TM wiretapping + * packets accordingly. + * @param dataSet + * @param replyId + * @param forceDirectTm + */ void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); From c7f300671fd708cbea51393d24857597f964c24b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:45:10 +0200 Subject: [PATCH 07/43] update header --- src/fsfw/devicehandlers/DeviceHandlerBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 792e70ad..700e960d 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1063,7 +1063,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, bool forceDirectTm = false); /** - * Can be used to handle Service 8 replies. This will also generate the TM wiretapping + * Can be used to handle Service 8 data replies. This will also generate the TM wiretapping * packets accordingly. * @param dataSet * @param replyId From 01651f0521d851402426fd6dca4b449e103b3d4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:51:09 +0200 Subject: [PATCH 08/43] more simplfications --- src/fsfw/osal/common/TcpTmTcServer.cpp | 15 +++-- src/fsfw/tmtcservices/SpacePacketParser.cpp | 32 ++++------ src/fsfw/tmtcservices/SpacePacketParser.h | 66 +++++++-------------- 3 files changed, 40 insertions(+), 73 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index f1174734..dff959ba 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -335,13 +335,13 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.readData(receptionBuffer.data(), readAmount, true); const uint8_t* bufPtr = receptionBuffer.data(); - FoundPacketInfo info; - ParsingState parseState; - while (parseState.amountRead < readAmount) { - if (spacePacketParser == nullptr) { - return returnvalue::FAILED; - } - result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info, parseState); + SpacePacketParser::FoundPacketInfo info; + if (spacePacketParser == nullptr) { + return returnvalue::FAILED; + } + spacePacketParser->reset(); + while (spacePacketParser->getAmountRead() < readAmount) { + result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info); switch (result) { case (SpacePacketParser::NO_PACKET_FOUND): case (SpacePacketParser::SPLIT_PACKET): { @@ -356,7 +356,6 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.deleteData(info.sizeFound); lastRingBufferSize = ringBuffer.getAvailableReadData(); - // std::memset(receptionBuffer.data() + startIdx, 0, foundSize); } return status; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index 16ee5dac..75db7a4e 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -6,17 +6,9 @@ SpacePacketParser::SpacePacketParser(std::vector validPacketIds) : validPacketIds(validPacketIds) {} -ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, - ParsingState& parsingState) { - const uint8_t** tempPtr = &buffer; - return parseSpacePackets(tempPtr, maxSize, packetInfo, parsingState); -} - ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, - ParsingState& parsingState) { - if (buffer == nullptr or parsingState.nextStartIdx > maxSize) { + FoundPacketInfo& packetInfo) { + if (buffer == nullptr or nextStartIdx > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl; #else @@ -30,11 +22,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const uint16_t lengthField = (bufPtr[localIdx + 4] << 8) | bufPtr[localIdx + 5]; size_t packetSize = lengthField + 7; ReturnValue_t result = returnvalue::OK; - if (lengthField == 0) { - // Skip whole header for now - packetInfo.sizeFound = 6; - result = NO_PACKET_FOUND; - } else if (packetSize + localIdx + parsingState.amountRead > maxSize) { + if (packetSize + localIdx + amountRead > maxSize) { // Don't increment buffer and read length here, user has to decide what to do packetInfo.sizeFound = packetSize; return SPLIT_PACKET; @@ -42,20 +30,20 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const packetInfo.sizeFound = packetSize; } *buffer += packetInfo.sizeFound; - packetInfo.startIdx = localIdx + parsingState.amountRead; - parsingState.nextStartIdx = localIdx + parsingState.amountRead + packetInfo.sizeFound; - parsingState.amountRead = parsingState.nextStartIdx; + packetInfo.startIdx = localIdx + amountRead; + nextStartIdx = localIdx + amountRead + packetInfo.sizeFound; + amountRead = nextStartIdx; return result; }; size_t idx = 0; // Space packet ID as start marker if (validPacketIds.size() > 0) { - while (idx + parsingState.amountRead < maxSize - 5) { + while (idx + amountRead < maxSize - 5) { uint16_t currentPacketId = (bufPtr[idx] << 8) | bufPtr[idx + 1]; if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) != validPacketIds.end()) { - if (idx + parsingState.amountRead >= maxSize - 5) { + if (idx + amountRead >= maxSize - 5) { return SPLIT_PACKET; } return verifyLengthField(idx); @@ -63,9 +51,9 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const idx++; } } - parsingState.nextStartIdx = maxSize; + nextStartIdx = maxSize; packetInfo.sizeFound = maxSize; - parsingState.amountRead = maxSize; + amountRead = maxSize; *buffer += maxSize; return NO_PACKET_FOUND; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 394083b2..3a1b4d16 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -7,16 +7,6 @@ #include "fsfw/container/DynamicFIFO.h" #include "fsfw/returnvalues/FwClassIds.h" -struct FoundPacketInfo { - size_t startIdx = 0; - size_t sizeFound = 0; -}; - -struct ParsingState { - size_t nextStartIdx = 0; - size_t amountRead = 0; -}; - /** * @brief This small helper class scans a given buffer for space packets. * Can be used if space packets are serialized in a tightly packed frame. @@ -27,9 +17,11 @@ struct ParsingState { */ class SpacePacketParser { public: - //! The first entry is the index inside the buffer while the second index - //! is the size of the PUS packet starting at that index. - using IndexSizePair = std::pair; + + struct FoundPacketInfo { + size_t startIdx = 0; + size_t sizeFound = 0; + }; static constexpr uint8_t INTERFACE_ID = CLASS_ID::SPACE_PACKET_PARSER; static constexpr ReturnValue_t NO_PACKET_FOUND = MAKE_RETURN_CODE(0x00); @@ -46,44 +38,32 @@ class SpacePacketParser { SpacePacketParser(std::vector validPacketIds); /** - * Parse a given frame for space packets but also increment the given buffer and assign the - * total number of bytes read so far + * Parse a given frame for space packets but also increments the given buffer. * @param buffer Parser will look for space packets in this buffer * @param maxSize Maximum size of the buffer - * @param startIndex Start index of a found space packet - * @param foundSize Found size of the space packet - * @param readLen Length read so far. This value is incremented by the number of parsed - * bytes which also includes the size of a found packet - * -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is - * invalid. foundSize will be set to the size of the space packet header. buffer and - * readLen will be incremented accordingly. - * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize - * will be set to the detected packet size and startIndex will be set to the start of the - * detected packet. buffer and read length will not be incremented but the found length - * will be assigned. - * -@c returnvalue::OK if a packet was found + * @param packetInfo Information about packets found. + * -@c NO_PACKET_FOUND if no packet was found in the given buffer + * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. packetInfo + * will contain the detected packet size and start index. + * -@c returnvalue::OK if a packet was found. Packet size and start index will be set in + * packetInfo */ ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, ParsingState& parsingState); + FoundPacketInfo& packetInfo); - /** - * Parse a given frame for space packets - * @param buffer Parser will look for space packets in this buffer - * @param maxSize Maximum size of the buffer - * @param startIndex Start index of a found space packet - * @param foundSize Found size of the space packet - * -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is - * invalid. foundSize will be set to the size of the space packet header - * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize - * will be set to the detected packet size and startIndex will be set to the start of the - * detected packet - * -@c returnvalue::OK if a packet was found - */ - ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, ParsingState& parsingState); + size_t getAmountRead() { + return amountRead; + } + + void reset() { + nextStartIdx = 0; + amountRead = 0; + } private: std::vector validPacketIds; + size_t nextStartIdx = 0; + size_t amountRead = 0; }; #endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */ From 2b01e86f9c7b56d036b7bab0404a10db90bd0d76 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 1 Sep 2022 11:56:07 +0200 Subject: [PATCH 09/43] one small additional precaution --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 4 +++- unittests/CMakeLists.txt | 1 + unittests/pus/CMakeLists.txt | 3 +++ unittests/pus/testService11.cpp | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 unittests/pus/CMakeLists.txt create mode 100644 unittests/pus/testService11.cpp diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 3cf24b11..c82c1703 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -575,11 +575,13 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr return INVALID_TIME_WINDOW; } itBegin = telecommandMap.begin(); - itEnd = telecommandMap.begin(); while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) { itBegin++; } + + //start looking for end beginning at begin + itEnd = itBegin; while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { itEnd++; } diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 8c7f2463..d7c35975 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -18,6 +18,7 @@ add_subdirectory(power) add_subdirectory(util) add_subdirectory(container) add_subdirectory(osal) +add_subdirectory(pus) add_subdirectory(serialize) add_subdirectory(datapoollocal) add_subdirectory(storagemanager) diff --git a/unittests/pus/CMakeLists.txt b/unittests/pus/CMakeLists.txt new file mode 100644 index 00000000..ecd7fb49 --- /dev/null +++ b/unittests/pus/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + testService11.cpp +) diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp new file mode 100644 index 00000000..72708f09 --- /dev/null +++ b/unittests/pus/testService11.cpp @@ -0,0 +1,14 @@ +#include + +#include + +#include "objects/systemObjectList.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" + +TEST_CASE("PUS Service 11", "[pus-srvc11]") { + Service11TelecommandScheduling<13> pusService11(objects::PUS_SERVICE_11_TC_SCHEDULER, + apid::DEFAULT_APID, pus::PUS_SERVICE_11, nullptr); + + // TODO test something... +} \ No newline at end of file From 04bff7a522adf8faaae5137bf3c3b0c54a031502 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 17:51:09 +0200 Subject: [PATCH 10/43] test fix --- unittests/pus/testService11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp index 72708f09..54279543 100644 --- a/unittests/pus/testService11.cpp +++ b/unittests/pus/testService11.cpp @@ -7,8 +7,8 @@ #include "tmtc/pusIds.h" TEST_CASE("PUS Service 11", "[pus-srvc11]") { - Service11TelecommandScheduling<13> pusService11(objects::PUS_SERVICE_11_TC_SCHEDULER, - apid::DEFAULT_APID, pus::PUS_SERVICE_11, nullptr); + Service11TelecommandScheduling<13> pusService11({objects::PUS_SERVICE_11_TC_SCHEDULER, + apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); // TODO test something... } \ No newline at end of file From ebc02673ddc269f1cfdb98e061dc72c33783d3a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 08:50:39 +0200 Subject: [PATCH 11/43] provide a weak print char impl --- src/fsfw_hal/common/CMakeLists.txt | 2 ++ src/fsfw_hal/common/printChar.c | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/fsfw_hal/common/printChar.c diff --git a/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt index f1cfec52..1cd9c678 100644 --- a/src/fsfw_hal/common/CMakeLists.txt +++ b/src/fsfw_hal/common/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory(gpio) + +target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) \ No newline at end of file diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c new file mode 100644 index 00000000..6e02c1df --- /dev/null +++ b/src/fsfw_hal/common/printChar.c @@ -0,0 +1,10 @@ +#include +#include + +void __attribute__((weak)) printChar(const char* character, bool errStream) { + if (errStream) { + fprintf(stderr, "%c", *character); + } else { + printf("%c", *character); + } +} From 1e85cdadfd573052617ad25d66cbc0a67884bf10 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 08:55:33 +0200 Subject: [PATCH 12/43] remove user includes --- src/fsfw/events/Event.h | 2 -- src/fsfw/returnvalues/returnvalue.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index ecab0493..e48736bf 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -4,8 +4,6 @@ #include #include "fwSubsystemIdRanges.h" -// could be moved to more suitable location -#include using EventId_t = uint16_t; using EventSeverity_t = uint8_t; diff --git a/src/fsfw/returnvalues/returnvalue.h b/src/fsfw/returnvalues/returnvalue.h index 4f9fc092..8396cbbf 100644 --- a/src/fsfw/returnvalues/returnvalue.h +++ b/src/fsfw/returnvalues/returnvalue.h @@ -1,8 +1,6 @@ #ifndef FSFW_RETURNVALUES_RETURNVALUE_H_ #define FSFW_RETURNVALUES_RETURNVALUE_H_ -#include - #include #include "FwClassIds.h" From 04800df31eca9755c14fdb21d68b6cfca420ce8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 09:04:37 +0200 Subject: [PATCH 13/43] another user-level-include --- src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h index 3250a739..3626a2b0 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h @@ -2,7 +2,6 @@ #define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ #include "devicedefinitions/MgmLIS3HandlerDefs.h" -#include "events/subsystemIdRanges.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/globalfunctions/PeriodicOperationDivider.h" From 80355910ee6260496fdfc196230c603c0d654582 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 09:05:10 +0200 Subject: [PATCH 14/43] better warning --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5351aeb4..7b00a708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,7 @@ if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_BUILD_DOCS) message( WARNING - "${MSG_PREFIX} Flight Software Framework configuration path not set") + "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set") message( WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") From d64ad71529260c561f452a6e5dfac0f10ac4b6c0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 14:44:35 +0200 Subject: [PATCH 15/43] Some improvements for time stamper API --- .../monitoring/MonitoringMessageContent.h | 8 ++--- .../pus/Service11TelecommandScheduling.tpp | 4 +-- .../pus/Service1TelecommandVerification.cpp | 4 +-- .../pus/Service1TelecommandVerification.h | 4 +-- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 24 +++++++------ src/fsfw/timemanager/CdsShortTimeStamper.h | 13 ++----- src/fsfw/timemanager/TimeReaderIF.h | 20 +++++++++-- src/fsfw/timemanager/TimeStamperIF.h | 23 ------------- src/fsfw/timemanager/TimeWriterIF.h | 34 +++++++++++++++++++ src/fsfw/tmstorage/TmStorePackets.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 6 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 14 ++++---- src/fsfw/tmtcpacket/pus/tm/PusTmIF.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.h | 2 +- src/fsfw/tmtcservices/SpacePacketParser.h | 5 +-- src/fsfw/tmtcservices/TmStoreHelper.cpp | 6 ++-- src/fsfw/tmtcservices/TmStoreHelper.h | 8 ++--- unittests/mocks/CdsShortTimestamperMock.h | 8 ++--- unittests/pus/testService11.cpp | 4 +-- 22 files changed, 105 insertions(+), 92 deletions(-) delete mode 100644 src/fsfw/timemanager/TimeStamperIF.h create mode 100644 src/fsfw/timemanager/TimeWriterIF.h diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index aeadacdf..7a7b5440 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -8,7 +8,7 @@ #include "../serialize/SerialLinkedListAdapter.h" #include "../serialize/SerializeElement.h" #include "../serviceinterface/ServiceInterface.h" -#include "../timemanager/TimeStamperIF.h" +#include "../timemanager/TimeWriterIF.h" #include "HasMonitorsIF.h" #include "MonitoringIF.h" #include "monitoringConf.h" @@ -34,9 +34,9 @@ class MonitoringReportContent : public SerialLinkedListAdapter { SerializeElement limitValue; SerializeElement oldState; SerializeElement newState; - uint8_t rawTimestamp[TimeStamperIF::MAXIMUM_TIMESTAMP_LEN] = {}; + uint8_t rawTimestamp[TimeWriterIF::MAXIMUM_TIMESTAMP_LEN] = {}; SerializeElement> timestampSerializer; - TimeStamperIF* timeStamper; + TimeWriterIF* timeStamper; MonitoringReportContent() : SerialLinkedListAdapter(¶meterObjectId), monitorId(0), @@ -79,7 +79,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { } bool checkAndSetStamper() { if (timeStamper == nullptr) { - timeStamper = ObjectManager::instance()->get(timeStamperId); + timeStamper = ObjectManager::instance()->get(timeStamperId); if (timeStamper == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MonitoringReportContent::checkAndSetStamper: " diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 05386493..0c750d3c 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -564,7 +564,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (result != returnvalue::OK) { return result; } - if(fromTimestamp > toTimestamp) { + if (fromTimestamp > toTimestamp) { return INVALID_TIME_WINDOW; } itBegin = telecommandMap.begin(); @@ -573,7 +573,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr itBegin++; } - //start looking for end beginning at begin + // start looking for end beginning at begin itEnd = itBegin; while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { itEnd++; diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index adc00588..a3248045 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -11,7 +11,7 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj uint16_t apid, uint8_t serviceId, object_id_t targetDestination, uint16_t messageQueueDepth, - TimeStamperIF* timeStamper) + TimeWriterIF* timeStamper) : SystemObject(objectId), apid(apid), serviceId(serviceId), @@ -134,7 +134,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() { storeHelper.setTmStore(*tmStore); } if (timeStamper == nullptr) { - timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timeStamper == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index fa4aba7c..f5844995 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -47,7 +47,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, object_id_t targetDestination, uint16_t messageQueueDepth, - TimeStamperIF* timeStamper = nullptr); + TimeWriterIF* timeStamper = nullptr); ~Service1TelecommandVerification() override; /** @@ -87,7 +87,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, TmStoreHelper storeHelper; TmStoreAndSendWrapper tmHelper; InternalErrorReporterIF* errReporter = nullptr; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp index 8095e28d..8fb33f12 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -6,11 +6,6 @@ CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) { - size_t serLen = 0; - return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK); -} - ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { if (*size + getSerializedSize() > maxSize) { @@ -33,15 +28,22 @@ size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize( ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - return returnvalue::FAILED; -} - -ReturnValue_t CdsShortTimeStamper::readTimeStamp(const uint8_t *buffer, size_t maxSize) { - if (maxSize < getTimestampSize()) { + if (size == nullptr or buffer == nullptr) { + return returnvalue::FAILED; + } + if (*size < getTimestampSize()) { return SerializeIF::STREAM_TOO_SHORT; } size_t foundLen = 0; - return CCSDSTime::convertFromCcsds(&readTime, buffer, &foundLen, maxSize); + if (((**buffer >> 4) & 0b111) != CCSDSTime::TimeCodeIdentification::CDS) { + return BAD_TIMESTAMP; + } + auto res = CCSDSTime::convertFromCcsds(&readTime, *buffer, &foundLen, *size); + if (res == returnvalue::OK) { + *size -= getSerializedSize(); + *buffer += getSerializedSize(); + } + return res; } timeval &CdsShortTimeStamper::getTime() { return readTime; } diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h index 4b1f6c28..244d54b6 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -3,7 +3,7 @@ #include "CCSDSTime.h" #include "TimeReaderIF.h" -#include "TimeStamperIF.h" +#include "TimeWriterIF.h" #include "fsfw/objectmanager/SystemObject.h" /** @@ -15,7 +15,7 @@ * overriding the #addTimeStamp function. * @ingroup utility */ -class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public SystemObject { +class CdsShortTimeStamper : public TimeWriterIF, public TimeReaderIF, public SystemObject { public: static constexpr size_t TIMESTAMP_LEN = 7; /** @@ -25,20 +25,11 @@ class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public Sy */ explicit CdsShortTimeStamper(object_id_t objectId); - /** - * Adds a CCSDS CDC short 8 byte timestamp to the given buffer. - * This function can be overriden to use a custom timestamp. - * @param buffer - * @param maxSize - * @return - */ - ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override; timeval &getTime() override; [[nodiscard]] size_t getTimestampSize() const override; diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index a3343e1c..8fd7415f 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -5,12 +5,28 @@ #include "TimeStampIF.h" #include "fsfw/returnvalues/returnvalue.h" +#include "fsfw/serialize/SerializeIF.h" -class TimeReaderIF : public TimeStampIF { +class TimeReaderIF : public SerializeIF, public TimeStampIF { public: ~TimeReaderIF() override = default; - virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) = 0; virtual timeval& getTime() = 0; + + [[nodiscard]] size_t getSerializedSize() const override { return getTimestampSize(); } + + ReturnValue_t readTimeStamp(const uint8_t* buf, size_t maxSize) { + size_t dummy = 0; + return deSerialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK); + } + + private: + /** + * Forbidden, use dedicated IF @TimeWriterIF + */ + [[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override { + return returnvalue::FAILED; + } }; #endif // FSFW_TIMEMANAGER_TIMEREADERIF_H diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h deleted file mode 100644 index 9085c067..00000000 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ -#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ - -#include "TimeStampIF.h" -#include "fsfw/returnvalues/returnvalue.h" -#include "fsfw/serialize/SerializeIF.h" - -/** - * A class implementing this IF provides facilities to add a time stamp to the - * buffer provided. - * Implementors need to ensure that calling the method is thread-safe, i.e. - * addTimeStamp may be called in parallel from a different context. - */ -class TimeStamperIF : public SerializeIF, public TimeStampIF { - public: - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; - ~TimeStamperIF() override = default; - size_t getTimestampSize() const override { return getSerializedSize(); } - - protected: -}; - -#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/timemanager/TimeWriterIF.h b/src/fsfw/timemanager/TimeWriterIF.h new file mode 100644 index 00000000..bc8aacc5 --- /dev/null +++ b/src/fsfw/timemanager/TimeWriterIF.h @@ -0,0 +1,34 @@ +#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ +#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ + +#include "TimeStampIF.h" +#include "fsfw/returnvalues/returnvalue.h" +#include "fsfw/serialize/SerializeIF.h" + +/** + * A class implementing this IF provides facilities to add a time stamp to the + * buffer provided. + * Implementors need to ensure that calling the method is thread-safe, i.e. + * addTimeStamp may be called in parallel from a different context. + */ +class TimeWriterIF : public SerializeIF, public TimeStampIF { + public: + ~TimeWriterIF() override = default; + [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } + + ReturnValue_t addTimeStamp(uint8_t *buf, size_t maxSize) { + size_t dummy = 0; + return serialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK); + } + + private: + /** + * Forbidden, use dedicated IF @TimeReaderIF + */ + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + return returnvalue::FAILED; + } +}; + +#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index a5d2f5a0..e519b3b7 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -7,7 +7,7 @@ #include "fsfw/serialize/SerialLinkedListAdapter.h" #include "fsfw/serialize/SerializeElement.h" #include "fsfw/timemanager/CCSDSTime.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" #include "tmStorageConf.h" diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index b754e990..09914e09 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams) : pusParams(initPusParams), spCreator(std::move(initSpParams)) { @@ -30,7 +30,7 @@ uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subserv PusTmParams& PusTmCreator::getParams() { return pusParams; } -void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) { +void PusTmCreator::setTimeStamper(TimeWriterIF& timeStamper_) { pusParams.secHeader.timeStamper = &timeStamper_; updateSpLengthField(); } @@ -106,7 +106,7 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, return returnvalue::FAILED; } -TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } +TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 8fd4f690..09d02945 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -8,12 +8,12 @@ struct PusTmSecHeader { PusTmSecHeader() = default; - PusTmSecHeader(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + PusTmSecHeader(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : service(service), subservice(subservice), timeStamper(timeStamper) {} uint8_t service = 0; uint8_t subservice = 0; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; uint8_t pusVersion = ecss::PusVersion::PUS_C; uint8_t scTimeRefStatus = 0; uint16_t messageTypeCounter = 0; @@ -26,10 +26,10 @@ struct PusTmParams { PusTmParams(PusTmSecHeader secHeader, util::DataWrapper dataWrapper) : secHeader(secHeader), dataWrapper(dataWrapper) {} - PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} - PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper, + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, util::DataWrapper dataWrapper_) : PusTmParams(service, subservice, timeStamper) { dataWrapper = dataWrapper_; @@ -38,7 +38,7 @@ struct PusTmParams { util::DataWrapper dataWrapper{}; }; -class TimeStamperIF; +class TimeWriterIF; /** * This class provides a high-level interface to create PUS TM packets and then @serialize @@ -56,7 +56,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); ~PusTmCreator() override = default; - void setTimeStamper(TimeStamperIF& timeStamper); + void setTimeStamper(TimeWriterIF& timeStamper); /** * This function disables the CRC16 calculation on serialization. This is useful to avoid * duplicate calculation if some lower level component needs to update fields like the sequence @@ -86,7 +86,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; - [[nodiscard]] TimeStamperIF* getTimestamper() const; + [[nodiscard]] TimeWriterIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h index 356cf20b..ee3005ca 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h @@ -4,7 +4,7 @@ #include #include -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/PusIF.h" #include "fsfw/tmtcpacket/pus/defs.h" diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 46852751..63db51ff 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -104,7 +104,7 @@ ReturnValue_t CommandingServiceBase::initialize() { // This avoids duplicate calculation of the CRC16 tmStoreHelper.disableCrcCalculation(); if (tmTimeStamper == nullptr) { - tmTimeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + tmTimeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (tmTimeStamper == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 9dfbd8bf..303d6d2e 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -272,7 +272,7 @@ class CommandingServiceBase : public SystemObject, MessageQueueIF* commandQueue = nullptr; MessageQueueIF* requestQueue = nullptr; - TimeStamperIF* tmTimeStamper = nullptr; + TimeWriterIF* tmTimeStamper = nullptr; VerificationReporterIF* verificationReporter; InternalErrorReporterIF* errReporter = nullptr; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 6900a2ac..091ab2f8 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -178,7 +178,7 @@ ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelp } if (psbParams.timeStamper == nullptr) { - auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timerStamper != nullptr) { tmStoreHelper.setTimeStamper(*timerStamper); } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index ce4b03f5..8a4f3cd0 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -65,7 +65,7 @@ struct PsbParams { * register itself at that object. */ PUSDistributorIF* pusDistributor = nullptr; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; }; namespace Factory { diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 3a1b4d16..ea0a2feb 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -17,7 +17,6 @@ */ class SpacePacketParser { public: - struct FoundPacketInfo { size_t startIdx = 0; size_t sizeFound = 0; @@ -51,9 +50,7 @@ class SpacePacketParser { ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, FoundPacketInfo& packetInfo); - size_t getAmountRead() { - return amountRead; - } + size_t getAmountRead() { return amountRead; } void reset() { nextStartIdx = 0; diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 501a7840..1c8e0a92 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -11,7 +11,7 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore) : } TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, - TimeStamperIF& timeStamper) + TimeWriterIF& timeStamper) : tmStore(&tmStore) { creator.setApid(defaultApid); creator.setTimeStamper(timeStamper); @@ -59,7 +59,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { SerializeIF::Endianness::NETWORK); } -void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) { +void TmStoreHelper::setTimeStamper(TimeWriterIF& timeStamper_) { creator.setTimeStamper(timeStamper_); } @@ -67,7 +67,7 @@ void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; } -TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } +TimeWriterIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 449a2287..f73d0c8b 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -4,14 +4,14 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueMessageIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" class TmStoreHelper { public: explicit TmStoreHelper(uint16_t defaultApid); TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore); - TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper); + TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeWriterIF& timeStamper); void disableCrcCalculation(); [[nodiscard]] bool crcCalculationEnabled() const; @@ -20,8 +20,8 @@ class TmStoreHelper { PusTmCreator& getCreatorRef(); - void setTimeStamper(TimeStamperIF& timeStamper); - [[nodiscard]] TimeStamperIF* getTimeStamper() const; + void setTimeStamper(TimeWriterIF& timeStamper); + [[nodiscard]] TimeWriterIF* getTimeStamper() const; [[nodiscard]] StorageManagerIF* getTmStore() const; void setTmStore(StorageManagerIF& store); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index ca7a674c..1ce13581 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -4,9 +4,9 @@ #include #include "fsfw/timemanager/TimeReaderIF.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" -class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { +class CdsShortTimestamperMock : public TimeWriterIF, public TimeReaderIF { public: unsigned int serializeCallCount = 0; unsigned int deserializeCallCount = 0; @@ -61,7 +61,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { } [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } - ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override { return 0; } void reset() { serializeCallCount = 0; @@ -75,9 +74,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { serFailRetval = returnvalue::FAILED; } - ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { - return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); - } timeval &getTime() override { return dummyTime; } private: diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp index 54279543..bd3b22ad 100644 --- a/unittests/pus/testService11.cpp +++ b/unittests/pus/testService11.cpp @@ -7,8 +7,8 @@ #include "tmtc/pusIds.h" TEST_CASE("PUS Service 11", "[pus-srvc11]") { - Service11TelecommandScheduling<13> pusService11({objects::PUS_SERVICE_11_TC_SCHEDULER, - apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); + Service11TelecommandScheduling<13> pusService11( + {objects::PUS_SERVICE_11_TC_SCHEDULER, apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); // TODO test something... } \ No newline at end of file From f0b7a103d4412169a792c833258a7229376f3bae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 15:30:53 +0200 Subject: [PATCH 16/43] refactor ctors --- src/fsfw/serialize/SerialBufferAdapter.cpp | 7 ++++++ src/fsfw/serialize/SerialBufferAdapter.h | 12 +++++----- src/fsfw/tmtcpacket/pus/CustomUserDataIF.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 21 ++++++----------- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 25 ++++++++++++++------- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 81919f37..0893dbde 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -125,6 +125,13 @@ void SerialBufferAdapter::setBuffer(uint8_t* buffer, count_t bufferLeng this->bufferLength = bufferLength; } +template +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { + this->buffer = nullptr; + this->bufferLength = bufLen; + this->constBuffer = buf; +} + // forward Template declaration for linker template class SerialBufferAdapter; template class SerialBufferAdapter; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 3b95fa20..e53a12bc 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -21,6 +21,7 @@ template class SerialBufferAdapter : public SerializeIF { public: + SerialBufferAdapter() = default; /** * Constructor for constant uint8_t buffer. Length field can be serialized optionally. * Type of length can be supplied as template type. @@ -40,12 +41,12 @@ class SerialBufferAdapter : public SerializeIF { */ SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false); - virtual ~SerialBufferAdapter(); + ~SerialBufferAdapter() override; - virtual 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 override; - virtual size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; /** * @brief This function deserializes a buffer into the member buffer. @@ -59,12 +60,13 @@ class SerialBufferAdapter : public SerializeIF { * @param bigEndian * @return */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; uint8_t* getBuffer(); - const uint8_t* getConstBuffer() const; + [[nodiscard]] const uint8_t* getConstBuffer() const; void setBuffer(uint8_t* buffer, count_t bufferLength); + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h index 779a0414..33592ed1 100644 --- a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h +++ b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h @@ -7,6 +7,6 @@ class CustomUserDataIF { public: virtual ~CustomUserDataIF() = default; virtual ReturnValue_t setRawUserData(const uint8_t* data, size_t len) = 0; - virtual ReturnValue_t setSerializableUserData(SerializeIF& serializable) = 0; + virtual ReturnValue_t setSerializableUserData(const SerializeIF& serializable) = 0; }; #endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 09914e09..1288b6d8 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -51,7 +51,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (result != returnvalue::OK) { return result; } - size_t userDataLen = pusParams.dataWrapper.getLength(); + size_t userDataLen = pusParams.data->getSerializedSize(); **buffer = ((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F); *buffer += 1; @@ -77,15 +77,8 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max } } - if (pusParams.dataWrapper.type == util::DataTypes::RAW and - pusParams.dataWrapper.dataUnion.raw.data != nullptr) { - std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen); - *buffer += userDataLen; - *size += userDataLen; - } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and - pusParams.dataWrapper.dataUnion.serializable != nullptr) { - result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, - streamEndianness); + if (pusParams.data != nullptr) { + result = pusParams.data->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -111,7 +104,7 @@ TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader. SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() + + size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.data->getSerializedSize() + sizeof(ecss::PusChecksumT) - 1; if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); @@ -134,12 +127,12 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { - pusParams.dataWrapper.setRawData({data, len}); + pusParams.adapter.setConstBuffer(data, len); updateSpLengthField(); return returnvalue::OK; } -ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { - pusParams.dataWrapper.setSerializable(serializable); +ReturnValue_t PusTmCreator::setSerializableUserData(const SerializeIF& serializable) { + pusParams.data = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 09d02945..c108aa73 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -22,20 +22,29 @@ struct PusTmSecHeader { struct PusTmParams { PusTmParams() = default; - explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; - PusTmParams(PusTmSecHeader secHeader, util::DataWrapper dataWrapper) - : secHeader(secHeader), dataWrapper(dataWrapper) {} - + explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader) {}; + PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data) + : secHeader(secHeader), data(&data) {} + PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen) + : secHeader(secHeader), adapter(data, dataLen), data(&adapter) { + } PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, - util::DataWrapper dataWrapper_) + const SerializeIF& data_) : PusTmParams(service, subservice, timeStamper) { - dataWrapper = dataWrapper_; + data = &data_; } + + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, + const uint8_t* data, size_t dataLen) + : secHeader(service, subservice, timeStamper), + adapter(data, dataLen), + data(&adapter) {} PusTmSecHeader secHeader; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter adapter; + const SerializeIF* data = nullptr; }; class TimeWriterIF; @@ -88,7 +97,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF [[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] TimeWriterIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; + ReturnValue_t setSerializableUserData(const SerializeIF& serializable) override; // Load all big endian (network endian) helpers into scope using SerializeIF::serializeBe; From b7a1f79d5b97ad333a3d8e20f281329ee69a0114 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 15:36:12 +0200 Subject: [PATCH 17/43] update FSFWCnfig.h --- misc/defaultcfg/fsfwconfig/FSFWConfig.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/defaultcfg/fsfwconfig/FSFWConfig.h b/misc/defaultcfg/fsfwconfig/FSFWConfig.h index adf9912f..e80abf24 100644 --- a/misc/defaultcfg/fsfwconfig/FSFWConfig.h +++ b/misc/defaultcfg/fsfwconfig/FSFWConfig.h @@ -4,6 +4,10 @@ #include #include +// It is assumed the user has a subsystem and class ID list in some user header files. +// #include "events/subsystemIdRanges.h" +// #include "returnvalues/classIds.h" + //! Used to determine whether C++ ostreams are used which can increase //! the binary size significantly. If this is disabled, //! the C stdio functions can be used alternatively From 75dc7a405d566ba99cb742eb967f6261b2e0c440 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:02:32 +0200 Subject: [PATCH 18/43] del data wrapper --- src/fsfw/serialize/SerialBufferAdapter.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 28 ++++----- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 13 +++- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 20 ++++--- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 20 +++---- src/fsfw/util/dataWrapper.h | 60 ------------------- unittests/tmtcpacket/testPusTcCreator.cpp | 2 +- .../tmtcservices/testStoreAndSendHelper.cpp | 16 ++--- 9 files changed, 52 insertions(+), 113 deletions(-) delete mode 100644 src/fsfw/util/dataWrapper.h diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 0893dbde..0293191e 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -21,7 +21,7 @@ SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, count_t buffe bufferLength(bufferLength) {} template -SerialBufferAdapter::~SerialBufferAdapter() {} +SerialBufferAdapter::~SerialBufferAdapter() = default; template ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index e53a12bc..395f93d2 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -44,7 +44,7 @@ class SerialBufferAdapter : public SerializeIF { ~SerialBufferAdapter() override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; + Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; @@ -61,7 +61,7 @@ class SerialBufferAdapter : public SerializeIF { * @return */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; + Endianness streamEndianness) override; uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 14a440a0..34d8396d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -14,7 +14,6 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { const uint8_t *start = *buffer; - size_t userDataLen = pusParams.dataWrapper.getLength(); if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } @@ -37,17 +36,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max if (result != returnvalue::OK) { return result; } - if (pusParams.dataWrapper.type == util::DataTypes::RAW) { - const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data; - if (data != nullptr and userDataLen > 0) { - std::memcpy(*buffer, data, userDataLen); - *buffer += userDataLen; - *size += userDataLen; - } - } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and - pusParams.dataWrapper.dataUnion.serializable != nullptr) { - result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, - streamEndianness); + if (pusParams.appData != nullptr) { + result = pusParams.appData->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -58,8 +48,11 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } void PusTcCreator::updateSpLengthField() { - spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_SIZE + pusParams.dataWrapper.getLength() + - 1); + size_t len = ecss::PusTcDataFieldHeader::MIN_SIZE + 1; + if (pusParams.appData != nullptr) { + len += pusParams.appData->getSerializedSize(); + } + spCreator.setDataLen(len); } size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } @@ -91,14 +84,15 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.dataWrapper.setRawData({data, len}); + pusParams.bufAdapter.setConstBuffer(data, len); + pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; } -ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { +ReturnValue_t PusTcCreator::setSerializableUserData(const SerializeIF &serializable) { // TODO: Check length field? - pusParams.dataWrapper.setSerializable(serializable); + pusParams.appData = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 4b0d81c8..add8a379 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -7,16 +7,23 @@ #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" -#include "fsfw/util/dataWrapper.h" struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} + void setRawAppData(const uint8_t *data, size_t len) { + bufAdapter.setConstBuffer(data, len); + appData = &bufAdapter; + } + + void setSerializableAppData(const SerializeIF &serializable) { appData = &serializable; } + uint8_t service; uint8_t subservice; uint8_t ackFlags = ecss::ACK_ALL; uint16_t sourceId = 0; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter bufAdapter; + const SerializeIF *appData = nullptr; uint8_t pusVersion = ecss::PusVersion::PUS_C; }; @@ -52,7 +59,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF &serializable) override; + ReturnValue_t setSerializableUserData(const SerializeIF &serializable) override; // Load all big endian helpers into the class namespace using SerializeIF::serializeBe; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 1288b6d8..41512c07 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -51,7 +51,6 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (result != returnvalue::OK) { return result; } - size_t userDataLen = pusParams.data->getSerializedSize(); **buffer = ((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F); *buffer += 1; @@ -77,8 +76,8 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max } } - if (pusParams.data != nullptr) { - result = pusParams.data->serialize(buffer, size, maxSize, streamEndianness); + if (pusParams.sourceData != nullptr) { + result = pusParams.sourceData->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -104,8 +103,10 @@ TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader. SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.data->getSerializedSize() + - sizeof(ecss::PusChecksumT) - 1; + size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + sizeof(ecss::PusChecksumT) - 1; + if (pusParams.sourceData != nullptr) { + headerLen += pusParams.sourceData->getSerializedSize(); + } if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); } @@ -127,12 +128,17 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { - pusParams.adapter.setConstBuffer(data, len); + if (data == nullptr or len == 0) { + pusParams.sourceData = nullptr; + } else { + pusParams.adapter.setConstBuffer(data, len); + pusParams.sourceData = &pusParams.adapter; + } updateSpLengthField(); return returnvalue::OK; } ReturnValue_t PusTmCreator::setSerializableUserData(const SerializeIF& serializable) { - pusParams.data = &serializable; + pusParams.sourceData = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index c108aa73..caf6f219 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -4,7 +4,6 @@ #include "PusTmIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" -#include "fsfw/util/dataWrapper.h" struct PusTmSecHeader { PusTmSecHeader() = default; @@ -22,29 +21,26 @@ struct PusTmSecHeader { struct PusTmParams { PusTmParams() = default; - explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader) {}; + explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data) - : secHeader(secHeader), data(&data) {} + : secHeader(secHeader), sourceData(&data) {} PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen) - : secHeader(secHeader), adapter(data, dataLen), data(&adapter) { - } + : secHeader(secHeader), adapter(data, dataLen), sourceData(&adapter) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, const SerializeIF& data_) : PusTmParams(service, subservice, timeStamper) { - data = &data_; + sourceData = &data_; } - PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, - const uint8_t* data, size_t dataLen) - : secHeader(service, subservice, timeStamper), - adapter(data, dataLen), - data(&adapter) {} + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, const uint8_t* data, + size_t dataLen) + : secHeader(service, subservice, timeStamper), adapter(data, dataLen), sourceData(&adapter) {} PusTmSecHeader secHeader; SerialBufferAdapter adapter; - const SerializeIF* data = nullptr; + const SerializeIF* sourceData = nullptr; }; class TimeWriterIF; diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h deleted file mode 100644 index 74a9ff5f..00000000 --- a/src/fsfw/util/dataWrapper.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef FSFW_UTIL_DATAWRAPPER_H -#define FSFW_UTIL_DATAWRAPPER_H - -#include -#include -#include - -#include "fsfw/serialize.h" - -namespace util { - -struct RawData { - const uint8_t* data = nullptr; - size_t len = 0; -}; - -enum DataTypes { NONE, RAW, SERIALIZABLE }; - -union DataUnion { - RawData raw; - SerializeIF* serializable = nullptr; -}; - -struct DataWrapper { - DataTypes type = DataTypes::NONE; - DataUnion dataUnion; - using BufPairT = std::pair; - - [[nodiscard]] size_t getLength() const { - if (type == DataTypes::RAW) { - return dataUnion.raw.len; - } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { - return dataUnion.serializable->getSerializedSize(); - } - return 0; - } - - [[nodiscard]] bool isNull() const { - if ((type == DataTypes::NONE) or (type == DataTypes::RAW and dataUnion.raw.data == nullptr) or - (type == DataTypes::SERIALIZABLE and dataUnion.serializable == nullptr)) { - return true; - } - return false; - } - - void setRawData(BufPairT bufPair) { - type = DataTypes::RAW; - dataUnion.raw.data = bufPair.first; - dataUnion.raw.len = bufPair.second; - } - - void setSerializable(SerializeIF& serializable) { - type = DataTypes::SERIALIZABLE; - dataUnion.serializable = &serializable; - } -}; - -} // namespace util - -#endif // FSFW_UTIL_DATAWRAPPER_H diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index b18c4717..58f8cbf9 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -71,7 +71,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { SECTION("Test with Application Data Raw") { auto& params = creator.getPusParams(); std::array data{1, 2, 3}; - params.dataWrapper.setRawData({data.data(), data.size()}); + params.setRawAppData(data.data(), data.size()); // To get correct size information, the SP length field needs to be updated automatically REQUIRE(creator.getSerializedSize() == 13); creator.updateSpLengthField(); diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 2731b28f..46418dfe 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -44,9 +44,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(creator.getSubService() == 2); REQUIRE(creator.getService() == 17); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); - REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); - REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); + REQUIRE(params.sourceData == nullptr); REQUIRE(tmHelper.sendCounter == 0); REQUIRE(tmHelper.storeAndSendTmPacket() == returnvalue::OK); REQUIRE(tmHelper.sendCounter == 1); @@ -65,9 +63,9 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); - REQUIRE(params.dataWrapper.dataUnion.raw.data == data.data()); - REQUIRE(params.dataWrapper.dataUnion.raw.len == data.size()); + REQUIRE(params.sourceData != nullptr); + REQUIRE(params.sourceData->getSerializedSize() == data.size()); + REQUIRE(params.adapter.getConstBuffer() == data.data()); } SECTION("Serializable Helper") { @@ -75,8 +73,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); - REQUIRE(params.dataWrapper.dataUnion.serializable == &simpleSer); + REQUIRE(params.sourceData == &simpleSer); } SECTION("Object ID prefix Helper") { @@ -86,8 +83,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); - REQUIRE(params.dataWrapper.dataUnion.serializable == &dataWithObjId); + REQUIRE(params.sourceData == &dataWithObjId); } // TODO: Error handling From 4c3f9feb938b83bf2472dccbb06162543f41f853 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:06:24 +0200 Subject: [PATCH 19/43] explicit include --- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index add8a379..a61b19d2 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -6,6 +6,7 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" struct PusTcParams { From f5421e9abd389dde5e6524f76b9e579dbf494c47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:10:06 +0200 Subject: [PATCH 20/43] refactor tm helper --- CMakeLists.txt | 3 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 1 + src/fsfw/tmtcservices/tmHelpers.h | 38 +++++++---------------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708..3011b244 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,8 @@ if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_BUILD_DOCS) message( WARNING - "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set") + "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set" + ) message( WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index a61b19d2..abccef8d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -1,12 +1,12 @@ #ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H #define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" -#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" struct PusTcParams { diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index caf6f219..626d873e 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -2,6 +2,7 @@ #define FSFW_TMTCPACKET_TMPACKETCREATOR_H #include "PusTmIF.h" +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 845a73b8..be93f5ec 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -10,48 +10,33 @@ namespace telemetry { class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) - : objectId(objectId) { - dataWrapper.type = util::DataTypes::RAW; - dataWrapper.dataUnion.raw.data = srcData; - dataWrapper.dataUnion.raw.len = srcDataLen; - } + : objectId(objectId), bufAdapter(srcData, srcDataLen), userData(&bufAdapter) {} - DataWithObjectIdPrefix(object_id_t objectId, SerializeIF& serializable) : objectId(objectId) { - dataWrapper.type = util::DataTypes::SERIALIZABLE; - dataWrapper.dataUnion.serializable = &serializable; - } + DataWithObjectIdPrefix(object_id_t objectId, const SerializeIF& serializable) + : objectId(objectId), userData(&serializable) {} ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - if (dataWrapper.type != util::DataTypes::RAW) { - if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { - return returnvalue::FAILED; - } - } else if (dataWrapper.type == util::DataTypes::SERIALIZABLE) { - if (dataWrapper.dataUnion.serializable == nullptr) { - return returnvalue::FAILED; - } - } ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } - if (dataWrapper.type != util::DataTypes::RAW) { - std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len); - *buffer += dataWrapper.dataUnion.raw.len; - *size += dataWrapper.dataUnion.raw.len; - } else { - return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); + if (userData != nullptr) { + return userData->serialize(buffer, size, maxSize, streamEndianness); } return returnvalue::OK; } [[nodiscard]] size_t getSerializedSize() const override { - return sizeof(objectId) + dataWrapper.getLength(); + size_t len = 0; + if (userData != nullptr) { + len += userData->getSerializedSize(); + } + return len; } ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, @@ -63,7 +48,8 @@ class DataWithObjectIdPrefix : public SerializeIF { private: object_id_t objectId; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter bufAdapter; + const SerializeIF* userData = nullptr; }; } // namespace telemetry From 1e395dc402e2f0f5ff328ec0b89b92fcfdd17f33 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:25:02 +0200 Subject: [PATCH 21/43] set buffer expects const pointer now --- src/fsfw/serialize/SerialBufferAdapter.cpp | 9 +-------- src/fsfw/serialize/SerialBufferAdapter.h | 3 +-- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 0293191e..f387a1fc 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,14 +119,7 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(uint8_t* buffer, count_t bufferLength) { - this->buffer = buffer; - this->constBuffer = buffer; - this->bufferLength = bufferLength; -} - -template -void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { +void SerialBufferAdapter::setBuffer(const uint8_t* buf, count_t bufLen) { this->buffer = nullptr; this->bufferLength = bufLen; this->constBuffer = buf; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 395f93d2..45ac5f0f 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -65,8 +65,7 @@ class SerialBufferAdapter : public SerializeIF { uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; - void setBuffer(uint8_t* buffer, count_t bufferLength); - void setConstBuffer(const uint8_t* buf, count_t bufLen); + void setBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 34d8396d..50e75d80 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.bufAdapter.setConstBuffer(data, len); + pusParams.bufAdapter.setBuffer(data, len); pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index abccef8d..0bd210b0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -13,7 +13,7 @@ struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} void setRawAppData(const uint8_t *data, size_t len) { - bufAdapter.setConstBuffer(data, len); + bufAdapter.setBuffer(data, len); appData = &bufAdapter; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 41512c07..02955ffe 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { pusParams.sourceData = nullptr; } else { - pusParams.adapter.setConstBuffer(data, len); + pusParams.adapter.setBuffer(data, len); pusParams.sourceData = &pusParams.adapter; } updateSpLengthField(); From 3583e30ee66a06f96a36da1b8bae3bf0e581d7a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:27:20 +0200 Subject: [PATCH 22/43] rename const buf setter --- src/fsfw/cfdp/tlv/Lv.cpp | 4 ++-- src/fsfw/cfdp/tlv/Tlv.cpp | 4 ++-- src/fsfw/serialize/SerialBufferAdapter.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- unittests/serialize/testSerialBufferAdapter.cpp | 3 ++- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 9c72b260..8105ade6 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) { if (value == nullptr or otherSize == 0) { this->zeroLen = true; } - this->value.setBuffer(value, otherSize); + this->value.setConstBuffer(value, otherSize); return *this; } @@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index 3a394741..435466be 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; @@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) { if (len > 0) { zeroLen = false; } - this->value.setBuffer(value, len); + this->value.setConstBuffer(value, len); } uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index f387a1fc..cf28d2ba 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,7 +119,7 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(const uint8_t* buf, count_t bufLen) { +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { this->buffer = nullptr; this->bufferLength = bufLen; this->constBuffer = buf; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 45ac5f0f..b156bb02 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -65,7 +65,7 @@ class SerialBufferAdapter : public SerializeIF { uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; - void setBuffer(const uint8_t* buf, count_t bufLen); + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 50e75d80..34d8396d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.bufAdapter.setBuffer(data, len); + pusParams.bufAdapter.setConstBuffer(data, len); pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 0bd210b0..abccef8d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -13,7 +13,7 @@ struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} void setRawAppData(const uint8_t *data, size_t len) { - bufAdapter.setBuffer(data, len); + bufAdapter.setConstBuffer(data, len); appData = &bufAdapter; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 02955ffe..41512c07 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { pusParams.sourceData = nullptr; } else { - pusParams.adapter.setBuffer(data, len); + pusParams.adapter.setConstBuffer(data, len); pusParams.sourceData = &pusParams.adapter; } updateSpLengthField(); diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index e5ea379e..abd179e4 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { SECTION("Test set buffer function") { SerialBufferAdapter tv_serial_buffer_adapter_loc = SerialBufferAdapter((uint8_t*)nullptr, 0, true); - tv_serial_buffer_adapter_loc.setBuffer(test_serial_buffer.data(), test_serial_buffer.size()); + tv_serial_buffer_adapter_loc.setConstBuffer(test_serial_buffer.data(), + test_serial_buffer.size()); serialized_size = 0; arrayPtr = testArray.data(); SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(), From 16688316a841ffe45909427089fe0af51dc0c81f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:31:56 +0200 Subject: [PATCH 23/43] rename setBuffer to setConstBuffer --- CMakeLists.txt | 3 ++- src/fsfw/cfdp/tlv/Lv.cpp | 4 ++-- src/fsfw/cfdp/tlv/Tlv.cpp | 4 ++-- src/fsfw/pus/Service11TelecommandScheduling.tpp | 4 ++-- src/fsfw/serialize/SerialBufferAdapter.cpp | 10 +++++----- src/fsfw/serialize/SerialBufferAdapter.h | 17 +++++++++-------- src/fsfw/tmtcservices/SpacePacketParser.h | 5 +---- unittests/serialize/testSerialBufferAdapter.cpp | 3 ++- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708..3011b244 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,8 @@ if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_BUILD_DOCS) message( WARNING - "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set") + "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set" + ) message( WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 9c72b260..33c0e381 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) { if (value == nullptr or otherSize == 0) { this->zeroLen = true; } - this->value.setBuffer(value, otherSize); + this->value.setConstBuffer(value, otherSize); return *this; } @@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(*buffer + 1, lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index 3a394741..9d5f7f15 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(*buffer + 1, lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; @@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) { if (len > 0) { zeroLen = false; } - this->value.setBuffer(value, len); + this->value.setConstBuffer(value, len); } uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index c82c1703..cb2f227f 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -571,7 +571,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (result != returnvalue::OK) { return result; } - if(fromTimestamp > toTimestamp) { + if (fromTimestamp > toTimestamp) { return INVALID_TIME_WINDOW; } itBegin = telecommandMap.begin(); @@ -580,7 +580,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr itBegin++; } - //start looking for end beginning at begin + // start looking for end beginning at begin itEnd = itBegin; while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { itEnd++; diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 81919f37..cf28d2ba 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -21,7 +21,7 @@ SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, count_t buffe bufferLength(bufferLength) {} template -SerialBufferAdapter::~SerialBufferAdapter() {} +SerialBufferAdapter::~SerialBufferAdapter() = default; template ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, @@ -119,10 +119,10 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(uint8_t* buffer, count_t bufferLength) { - this->buffer = buffer; - this->constBuffer = buffer; - this->bufferLength = bufferLength; +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { + this->buffer = nullptr; + this->bufferLength = bufLen; + this->constBuffer = buf; } // forward Template declaration for linker diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 3b95fa20..b156bb02 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -21,6 +21,7 @@ template class SerialBufferAdapter : public SerializeIF { public: + SerialBufferAdapter() = default; /** * Constructor for constant uint8_t buffer. Length field can be serialized optionally. * Type of length can be supplied as template type. @@ -40,12 +41,12 @@ class SerialBufferAdapter : public SerializeIF { */ SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false); - virtual ~SerialBufferAdapter(); + ~SerialBufferAdapter() override; - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; - virtual size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; /** * @brief This function deserializes a buffer into the member buffer. @@ -59,12 +60,12 @@ class SerialBufferAdapter : public SerializeIF { * @param bigEndian * @return */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; uint8_t* getBuffer(); - const uint8_t* getConstBuffer() const; - void setBuffer(uint8_t* buffer, count_t bufferLength); + [[nodiscard]] const uint8_t* getConstBuffer() const; + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 3a1b4d16..ea0a2feb 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -17,7 +17,6 @@ */ class SpacePacketParser { public: - struct FoundPacketInfo { size_t startIdx = 0; size_t sizeFound = 0; @@ -51,9 +50,7 @@ class SpacePacketParser { ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, FoundPacketInfo& packetInfo); - size_t getAmountRead() { - return amountRead; - } + size_t getAmountRead() { return amountRead; } void reset() { nextStartIdx = 0; diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index e5ea379e..abd179e4 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { SECTION("Test set buffer function") { SerialBufferAdapter tv_serial_buffer_adapter_loc = SerialBufferAdapter((uint8_t*)nullptr, 0, true); - tv_serial_buffer_adapter_loc.setBuffer(test_serial_buffer.data(), test_serial_buffer.size()); + tv_serial_buffer_adapter_loc.setConstBuffer(test_serial_buffer.data(), + test_serial_buffer.size()); serialized_size = 0; arrayPtr = testArray.data(); SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(), From 07ef9a0ec3d9050f518eed7f0bf363716d0603af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 15:47:04 +0200 Subject: [PATCH 24/43] bump catch2 version --- CMakeLists.txt | 2 +- automation/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708..36b3082b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING "Catch2 library major version requirement") set(FSFW_CATCH2_LIB_VERSION - v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 + v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0 CACHE STRING "Catch2 library exact version requirement") # Keep this off by default for now. See PR: diff --git a/automation/Dockerfile b/automation/Dockerfile index 2ed2a7d9..318619f8 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping RUN git clone https://github.com/catchorg/Catch2.git && \ cd Catch2 && \ - git checkout v3.0.0-preview5 && \ + git checkout v3.1.0 && \ cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ cmake --build build/ --target install From 282704e0fd186f1f13b5ca5046f207afdf49b2f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:54:04 +0200 Subject: [PATCH 25/43] remove bsp specific code --- .../ServiceInterfaceBuffer.cpp | 91 +------------------ 1 file changed, 1 insertion(+), 90 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index dd928efe..076ab1d2 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -2,7 +2,7 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 -#include +#include #include @@ -16,8 +16,6 @@ // to be implemented by bsp extern "C" void printChar(const char*, bool errStream); -#ifndef UT699 - ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addCrToPreamble, bool buffered, bool errStream, uint16_t port) : isActive(true), @@ -168,90 +166,3 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) { this->colorPrefix = colorPrefix; } #endif - -#ifdef UT699 -#include "../osal/rtems/Interrupt.h" - -ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) { - this->log_message = set_message; - this->isActive = true; - setp(buf, buf + BUF_SIZE); -} - -void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { - char array[BUF_SIZE]; - uint32_t length = end - begin; - if (length > sizeof(array)) { - length = sizeof(array); - } - memcpy(array, begin, length); - - if (!Interrupt::isInterruptInProgress()) { - std::cout << array; - } else { - // Uncomment the following line if you need ISR debug output. - // printk(array); - } -} -#endif // UT699 - -#ifdef ML505 -#include -ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) - : isActive(true), - log_message(set_message), - udpSocket(0), - remoteAddressLength(sizeof(remoteAddress)) { - setp(buf, buf + BUF_SIZE); - memset((uint8_t*)&remoteAddress, 0, sizeof(remoteAddress)); - remoteAddress.sin_family = AF_INET; - remoteAddress.sin_port = htons(port); - remoteAddress.sin_addr.s_addr = htonl(inet_addr("192.168.250.100")); -} - -void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { - char array[BUF_SIZE]; - uint32_t length = end - begin; - if (length > sizeof(array)) { - length = sizeof(array); - } - memcpy(array, begin, length); - - if (udpSocket <= 0) { - initSocket(); - } - - if (udpSocket > 0) { - sendto(udpSocket, array, length, 0, (sockaddr*)&remoteAddress, sizeof(remoteAddress)); - } -} - -void ServiceInterfaceBuffer::initSocket() { - sockaddr_in address; - memset((uint8_t*)&address, 0, sizeof(address)); - address.sin_family = AF_INET; - address.sin_port = htons(0); - address.sin_addr.s_addr = htonl(INADDR_ANY); - - udpSocket = socket(PF_INET, SOCK_DGRAM, 0); - if (socket < 0) { - printf("Error opening socket!\n"); - return; - } - timeval timeout = {0, 20}; - if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) { - printf("Error setting SO_RCVTIMEO socket options!\n"); - return; - } - if (setsockopt(udpSocket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) { - printf("Error setting SO_SNDTIMEO socket options!\n"); - return; - } - if (bind(udpSocket, (sockaddr*)&address, sizeof(address)) < 0) { - printf("Error binding socket!\n"); - } -} - -#endif // ML505 - -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ From 04b619a15cd8dc7b26ccd85d78c94134828364ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:58:49 +0200 Subject: [PATCH 26/43] update header as well --- .../ServiceInterfaceBuffer.cpp | 6 +- .../serviceinterface/ServiceInterfaceBuffer.h | 86 +------------------ 2 files changed, 5 insertions(+), 87 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 076ab1d2..890912c2 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,4 +1,4 @@ -#include "fsfw/serviceinterface/ServiceInterfaceBuffer.h" +#include "ServiceInterfaceBuffer.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -72,8 +72,6 @@ void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { } } -#endif - int ServiceInterfaceBuffer::overflow(int c) { if (not buffered and this->isActive) { if (c != Traits::eof()) { @@ -166,3 +164,5 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) { this->colorPrefix = colorPrefix; } #endif + +#endif diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h index 2ecf88d8..682332c9 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h @@ -1,9 +1,8 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ -#include - -#include "../returnvalues/returnvalue.h" +#include "fsfw/FSFW.h" +#include "fsfw/returnvalues/returnvalue.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -11,8 +10,6 @@ #include #include -#ifndef UT699 - /** * @brief This is the underlying stream buffer which implements the * streambuf class and overloads the overflow() and sync() methods @@ -77,85 +74,6 @@ class ServiceInterfaceBuffer : public std::streambuf { bool crAdditionEnabled() const; }; -#endif - -#ifdef UT699 -class ServiceInterfaceBuffer : public std::basic_streambuf > { - friend class ServiceInterfaceStream; - - public: - ServiceInterfaceBuffer(std::string set_message, uint16_t port); - - protected: - bool isActive; - // This is called when buffer becomes full. If - // buffer is not used, then this is called every - // time when characters are put to stream. - virtual int overflow(int c = Traits::eof()); - - // This function is called when stream is flushed, - // for example when std::endl is put to stream. - virtual int sync(void); - - private: - // For additional message information - std::string log_message; - // For EOF detection - typedef std::char_traits Traits; - - // Work in buffer mode. It is also possible to work without buffer. - static size_t const BUF_SIZE = 128; - char buf[BUF_SIZE]; - - // In this function, the characters are parsed. - void putChars(char const* begin, char const* end); -}; -#endif // UT699 - -#ifdef ML505 -#include -#include -#include -#include -#include - -class ServiceInterfaceBuffer : public std::basic_streambuf > { - friend class ServiceInterfaceStream; - - public: - ServiceInterfaceBuffer(std::string set_message, uint16_t port); - - protected: - bool isActive; - // This is called when buffer becomes full. If - // buffer is not used, then this is called every - // time when characters are put to stream. - virtual int overflow(int c = Traits::eof()); - - // This function is called when stream is flushed, - // for example when std::endl is put to stream. - virtual int sync(void); - - private: - // For additional message information - std::string log_message; - // For EOF detection - typedef std::char_traits Traits; - - // Work in buffer mode. It is also possible to work without buffer. - static size_t const BUF_SIZE = 128; - char buf[BUF_SIZE]; - - // In this function, the characters are parsed. - void putChars(char const* begin, char const* end); - - int udpSocket; - sockaddr_in remoteAddress; - socklen_t remoteAddressLength; - void initSocket(); -}; -#endif // ML505 - #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */ From d52f3354552371db87b881d6100dcdabc14598ce Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 8 Sep 2022 11:47:40 +0200 Subject: [PATCH 27/43] sif::buffer: if disabeld do not print --- src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index dd928efe..092c234c 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -58,6 +58,9 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addC } void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { + if (not isActive) { + return; + } char array[BUF_SIZE]; uint32_t length = end - begin; if (length > sizeof(array)) { From 003a6d00fa5cca7450f9bab77244ee2b99106fe2 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 13:13:18 +0200 Subject: [PATCH 28/43] Documentation build tools in docker --- automation/Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 318619f8..81e3e14a 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -5,16 +5,18 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping +RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz + +RUN python3 -m pip install sphinx breathe RUN git clone https://github.com/catchorg/Catch2.git && \ - cd Catch2 && \ - git checkout v3.1.0 && \ - cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ - cmake --build build/ --target install + cd Catch2 && \ + git checkout v3.1.0 && \ + cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ + cmake --build build/ --target install RUN git clone https://github.com/ETLCPP/etl.git && \ - cd etl && \ - git checkout 20.28.0 && \ - cmake -B build . && \ - cmake --install build/ + cd etl && \ + git checkout 20.28.0 && \ + cmake -B build . && \ + cmake --install build/ \ No newline at end of file From 92e3ab04f3eaf0b560195407b94d772bd63c4956 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 13:54:23 +0200 Subject: [PATCH 29/43] testing Jenkinsfile --- automation/Jenkinsfile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 02340190..8cdf68aa 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,9 +1,10 @@ pipeline { environment { BUILDDIR = 'cmake-build-tests' + DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d3'} + docker { image 'fsfw-ci:d4'} } stages { stage('Clean') { @@ -39,5 +40,17 @@ pipeline { } } } + stage('Documentation') { + steps { + dir(DOCDDIR) { + sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' + sh 'make Sphinx' + sh 'cd docs/sphinx' + sshagent(credentials: ['documentation-buildfix']) { + sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + } + } + } + } } } From d79b5348d85ab4415f985fa1ef0275b5097d753e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:00:36 +0200 Subject: [PATCH 30/43] testing Jenkinsfile --- automation/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8cdf68aa..dcd98d5b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -47,6 +47,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -vvv buildfix@documents.intra.irs.uni-stuttgart.de uname -a' sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } From 8bbde054136bb61c63f1f0715994efa552f2620b Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:08:04 +0200 Subject: [PATCH 31/43] add jenkins user in docker so that ssh will work --- automation/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 81e3e14a..ce7088fb 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -19,4 +19,7 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ cd etl && \ git checkout 20.28.0 && \ cmake -B build . && \ - cmake --install build/ \ No newline at end of file + cmake --install build/ + +#ssh needs a valid user to work +RUN adduser -m -u 114 jenkins From ecf51b29139953c25e2347b41dcd648b0ceddb43 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:09:08 +0200 Subject: [PATCH 32/43] testing Jenkinsfile --- automation/Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index dcd98d5b..6bc5b0a6 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d4'} + docker { image 'fsfw-ci:d5'} } stages { stage('Clean') { @@ -42,6 +42,7 @@ pipeline { } stage('Documentation') { steps { + echo env.BRANCH_NAME dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' From 9c7248e78e38659005b082b9946211c5a868684d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:20:30 +0200 Subject: [PATCH 33/43] typo in Dockerfile --- automation/Dockerfile | 2 +- automation/Jenkinsfile | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index ce7088fb..5bd7d382 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -22,4 +22,4 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ cmake --install build/ #ssh needs a valid user to work -RUN adduser -m -u 114 jenkins +RUN adduser --uid 114 jenkins diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 6bc5b0a6..54b21b36 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -41,18 +41,34 @@ pipeline { } } stage('Documentation') { + when { + branch 'development' + } steps { - echo env.BRANCH_NAME dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -vvv buildfix@documents.intra.irs.uni-stuttgart.de uname -a' sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } } + stage('Master Documentation') { + when { + branch 'master' + } + steps { + dir(DOCDDIR) { + sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' + sh 'make Sphinx' + sh 'cd docs/sphinx' + sshagent(credentials: ['documentation-buildfix']) { + sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + } + } + } + } } } From 9bd600c4882415f2c0d2a083d60403fdebeb88f8 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:32:10 +0200 Subject: [PATCH 34/43] testing Jenkinsfile --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 54b21b36..3dfc083a 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -42,7 +42,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 8e835be55fe088e6fba19cc98a12d109f8071a57 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:46:12 +0200 Subject: [PATCH 35/43] testing Jenkinsfile --- automation/Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 3dfc083a..84133c43 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -4,7 +4,10 @@ pipeline { DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d5'} + docker { + image 'fsfw-ci:d5' + args '--network host' + } } stages { stage('Clean') { @@ -41,6 +44,7 @@ pipeline { } } stage('Documentation') { + agent any when { branch 'mohr/documentation_ci' } @@ -50,7 +54,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } From fa5605c959fef28b285d26ed074439774fb5373d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:50:37 +0200 Subject: [PATCH 36/43] testing Jenkinsfile --- automation/Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 84133c43..8deeb994 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -44,7 +44,6 @@ pipeline { } } stage('Documentation') { - agent any when { branch 'mohr/documentation_ci' } @@ -69,7 +68,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 6451a16888fb2a465dd4fcaff7fe49fc7ab352b7 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 17:51:01 +0200 Subject: [PATCH 37/43] fixing scp command --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8deeb994..d3bb31be 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -68,7 +68,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 24ecf125a3979f77baa502fbbabacaf94d262c99 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 17:55:12 +0200 Subject: [PATCH 38/43] fixing scp command again --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index d3bb31be..5fe38b03 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -53,7 +53,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } From f34cf9095dbe72a865881af1267b2e4523917295 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:02:38 +0200 Subject: [PATCH 39/43] fixing scp yet again --- automation/Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 5fe38b03..3095a27c 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -51,9 +51,8 @@ pipeline { dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' - sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } @@ -66,9 +65,8 @@ pipeline { dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' - sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 3257935150a26dcca09282c04fbc432738cd6831 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:06:16 +0200 Subject: [PATCH 40/43] fixing scp yet again again --- automation/Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 3095a27c..ac0f54be 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -52,6 +52,7 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/development/*' sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } @@ -66,6 +67,7 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/master/*' sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } From 21a9d89fb36a9838961b9d9b3e6137b67af665a2 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:14:26 +0200 Subject: [PATCH 41/43] pushing code coverage report to documentation server --- automation/Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ac0f54be..cc61a320 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -56,6 +56,12 @@ pipeline { sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } + dir(BUILDDIR) { + sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/development/*' + sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/development' + } + } } } stage('Master Documentation') { @@ -71,6 +77,12 @@ pipeline { sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } + dir(BUILDDIR) { + sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/master/*' + sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/master' + } + } } } } From af282c7d3ee9e9e2d5f6b0d03e411a267b6115c9 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:17:56 +0200 Subject: [PATCH 42/43] reverting to only publish development --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index cc61a320..8b123fa9 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 6970068d568bd693282ddd7fef066bd8a9dc6ecc Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:19:35 +0200 Subject: [PATCH 43/43] small fix in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b2ca52d..7094e5dc 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host .. Then you can generate the documentation using ```sh -cmake --build . -j +cmake --build . -- Sphinx -j ``` You can find the generated documentation inside the `docs/sphinx` folder inside the build