From 93acac02f561fe61dfe05904261d15ee715f1249 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:06:23 +0200 Subject: [PATCH] tests running again --- src/fsfw/pus/Service1TelecommandVerification.cpp | 12 +++++++----- src/fsfw/serialize/SerializeIF.h | 4 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 8 ++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 3 +++ src/fsfw/tmtcservices/PusServiceBase.cpp | 11 ++++++----- unittests/mocks/CdsShortTimestamperMock.h | 1 - unittests/tmtcpacket/testCcsds.cpp | 2 +- unittests/tmtcpacket/testPusTmCreator.cpp | 9 ++++++--- unittests/tmtcpacket/testPusTmReader.cpp | 2 +- unittests/tmtcservices/testSendHelper.cpp | 2 +- 10 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 9d8ca111..0e6e302c 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -50,13 +50,15 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( PusVerificationMessage* message) { ReturnValue_t result; uint8_t reportId = message->getReportId(); - if(reportId == 0 or reportId > 8) { + if (reportId == 0 or reportId > 8) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " << - static_cast(reportId) << " detected" << std::endl; + sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " + << static_cast(reportId) << " detected" << std::endl; #else - sif::printError("Service1TelecommandVerification::sendVerificationReport: Invalid report ID " - "%d detected\n", reportId); + sif::printError( + "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " + "%d detected\n", + reportId); #endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 136bd419..e33adb96 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -64,13 +64,13 @@ class SerializeIF { /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) { + virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 348308d1..6253bc24 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -146,3 +146,11 @@ void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; } bool PusTmCreator::crcCalculationEnabled() const { return calculateCrcOnSerialization; } + +ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} + +ReturnValue_t PusTmCreator::serialize(uint8_t* buffer, size_t maxSize) const { + return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); +} \ No newline at end of file diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 0e7988f1..75760968 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -72,6 +72,9 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; + // Override these to use default big endianness + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const override; + ReturnValue_t serialize(uint8_t* buffer, size_t maxSize) const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index f8cc7cb8..b555449b 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -140,9 +140,10 @@ void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { psbParams.errReporter = &errReporter_; } -ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { +ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, + TmStoreHelper& tmStoreHelper) { ReturnValue_t result = initializeTmSendHelper(tmSendHelper); - if(result != HasReturnvaluesIF::RETURN_OK) { + if (result != HasReturnvaluesIF::RETURN_OK) { return result; } return initializeTmStoreHelper(tmStoreHelper); @@ -166,11 +167,11 @@ ReturnValue_t PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) return RETURN_OK; } -ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { +ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(psbParams.apid); - if(tmStoreHelper.getTmStore() == nullptr) { + if (tmStoreHelper.getTmStore() == nullptr) { auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { + if (tmStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } tmStoreHelper.setTmStore(*tmStore); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index 784ef7f4..d19385cd 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -78,7 +78,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); } - size_t getTimestampLen() override { return getSerializedSize(); } timeval &getTime() override { return dummyTime; } private: diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index e40db1c6..9be2b8af 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -24,7 +24,7 @@ TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { uint16_t packetIdRaw = 0x3ff; ccsds::setPacketId(header, packetIdRaw); ccsds::setApid(header, 0x1ff); - REQUIRE(ccsds::getPacketId(header) == 0x1ff); + REQUIRE(ccsds::getPacketId(header) == 0x3ff); } SECTION("Lowlevel Packet Length Test") { diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index ad8a1d4d..97f3d893 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -44,7 +44,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { } SECTION("Serialization") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.SerializeIF::serializeBe(&dataPtr, &serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x08); REQUIRE(buf[1] == 0xef); // Unsegmented is the default @@ -105,7 +106,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.getFullPacketLen() == 25); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -139,7 +141,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, maxSize) == + SerializeIF::BUFFER_TOO_SHORT); } } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 7a61b731..3914db48 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -22,7 +22,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { bool deleteReader = false; dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(not(*readerPtr)); REQUIRE(readerPtr->isNull()); diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index b857776b..78ca9f0e 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -57,7 +57,7 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { SECTION("Two Arg CTOR") { TmSendHelper helper(msgQueue, errReporter); REQUIRE(helper.getInternalErrorReporter() == &errReporter); - REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); + REQUIRE(helper.getDefaultDestination() == 2); REQUIRE(helper.getMsgQueue() == &msgQueue); } SECTION("Send") {