From ea1d55b0336dd860c7c5ab7a2a6b62d408d3244c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 18 Apr 2020 13:16:00 +0200 Subject: [PATCH] null replaced by nullptr. storeID initialization added, all nullptr/0 initializations in header --- tmtcservices/TmTcBridge.cpp | 19 +++++++++---------- tmtcservices/TmTcBridge.h | 25 ++++++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index 8450494a..38d900dd 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -11,17 +11,15 @@ #include #include -TmTcBridge::TmTcBridge(object_id_t objectId_, object_id_t ccsdsPacketDistributor_): - SystemObject(objectId_),tcStore(NULL), tmStore(NULL), - ccsdsPacketDistributor(ccsdsPacketDistributor_), communicationLinkUp(false), - tmStored(false),recvBuffer(NULL), size(0) { - TmTcReceptionQueue = QueueFactory::instance()-> +TmTcBridge::TmTcBridge(object_id_t objectId_, + object_id_t ccsdsPacketDistributor_): SystemObject(objectId_), + ccsdsPacketDistributor(ccsdsPacketDistributor_) +{ + TmTcReceptionQueue = QueueFactory::instance()-> createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH); - } -TmTcBridge::~TmTcBridge() { -} +TmTcBridge::~TmTcBridge() {} ReturnValue_t TmTcBridge::initialize() { tcStore = objectManager->get(objects::TC_STORE); @@ -75,8 +73,9 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t TmTcBridge::readTmQueue() { TmTcMessage message; - const uint8_t* data = NULL; + const uint8_t* data = nullptr; size_t size = 0; + for (ReturnValue_t result = TmTcReceptionQueue->receiveMessage(&message); result == RETURN_OK; result = TmTcReceptionQueue->receiveMessage(&message)) { @@ -105,7 +104,7 @@ ReturnValue_t TmTcBridge::readTmQueue() { ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { info << "TMTC Bridge: Comm Link down. " "Saving packet ID to be sent later\r\n" << std::flush; - store_address_t storeId; + store_address_t storeId = 0; if(fifo.full()) { info << "TMTC Bridge: TM downlink max. number of stored packet IDs reached." diff --git a/tmtcservices/TmTcBridge.h b/tmtcservices/TmTcBridge.h index 8e4124e0..e0634098 100644 --- a/tmtcservices/TmTcBridge.h +++ b/tmtcservices/TmTcBridge.h @@ -48,12 +48,15 @@ public: void registerCommConnect(); void registerCommDisconnect(); protected: - MessageQueueIF* TmTcReceptionQueue; //!< Used to send and receive TMTC messages. TmTcMessage is used to transport messages between tasks. - StorageManagerIF* tcStore; - StorageManagerIF* tmStore; - object_id_t ccsdsPacketDistributor; - bool communicationLinkUp; //!< Used to specify whether communication link is up - bool tmStored; + //! Used to send and receive TMTC messages. + //! TmTcMessage is used to transport messages between tasks. + MessageQueueIF* TmTcReceptionQueue = nullptr; + StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tmStore = nullptr; + object_id_t ccsdsPacketDistributor = 0; + //! Used to specify whether communication link is up + bool communicationLinkUp = false; + bool tmStored = false; /** * Handle TC reception. Default implementation provided @@ -113,13 +116,13 @@ protected: void printData(uint8_t * data, uint32_t dataLen); private: - static const uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20; - static const uint8_t MAX_STORED_DATA_SENT_PER_CYCLE = 10; - static const uint8_t MAX_DOWNLINK_PACKETS_STORED = 15; + static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20; + static constexpr uint8_t MAX_STORED_DATA_SENT_PER_CYCLE = 10; + static constexpr uint8_t MAX_DOWNLINK_PACKETS_STORED = 15; FIFO fifo; - uint8_t * recvBuffer; - uint32_t size; + uint8_t * recvBuffer = nullptr; + uint32_t size = 0; };