From 1aef000eff336b97917ac4c178d95749ec9cd5dc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 19 May 2020 20:24:58 +0200 Subject: [PATCH] printer improvements and fixes tc packet stored getter function --- globalfunctions/printer.cpp | 10 +++++----- globalfunctions/printer.h | 6 +++--- tmtcpacket/pus/TcPacketStored.cpp | 12 ++++++++++++ tmtcpacket/pus/TcPacketStored.h | 3 +++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/globalfunctions/printer.cpp b/globalfunctions/printer.cpp index 01ec532c..f099113c 100644 --- a/globalfunctions/printer.cpp +++ b/globalfunctions/printer.cpp @@ -1,8 +1,8 @@ #include #include -void printer::print(uint8_t *data, size_t size, OutputType type, bool printInfo, - size_t maxCharPerLine) { +void printer::print(const uint8_t *data, size_t size, OutputType type, + bool printInfo, size_t maxCharPerLine) { if(printInfo) { sif::info << "Printing data with size " << size << ": "; } @@ -15,7 +15,7 @@ void printer::print(uint8_t *data, size_t size, OutputType type, bool printInfo, } } -void printer::printHex(uint8_t *data, size_t size, size_t maxCharPerLine) { +void printer::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) { sif::info << std::hex; for(size_t i = 0; i < size; i++) { sif::info << "0x" << static_cast(data[i]); @@ -31,10 +31,10 @@ void printer::printHex(uint8_t *data, size_t size, size_t maxCharPerLine) { sif::info << "]" << std::endl; } -void printer::printDec(uint8_t *data, size_t size, size_t maxCharPerLine) { +void printer::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) { sif::info << std::dec; for(size_t i = 0; i < size; i++) { - sif::info << "0x" << static_cast(data[i]); + sif::info << static_cast(data[i]); if(i < size - 1){ sif::info << " , "; if(i > 0 and i % maxCharPerLine == 0) { diff --git a/globalfunctions/printer.h b/globalfunctions/printer.h index db9f343f..76d28e5f 100644 --- a/globalfunctions/printer.h +++ b/globalfunctions/printer.h @@ -10,10 +10,10 @@ enum class OutputType { HEX }; -void print(uint8_t* data, size_t size, OutputType type = OutputType::HEX, +void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX, bool printInfo = true, size_t maxCharPerLine = 12); -void printHex(uint8_t* data, size_t size, size_t maxCharPerLine = 12); -void printDec(uint8_t* data, size_t size, size_t maxCharPerLine = 12); +void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12); +void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12); } #endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */ diff --git a/tmtcpacket/pus/TcPacketStored.cpp b/tmtcpacket/pus/TcPacketStored.cpp index 47cf2ecd..64aa74dc 100644 --- a/tmtcpacket/pus/TcPacketStored.cpp +++ b/tmtcpacket/pus/TcPacketStored.cpp @@ -1,6 +1,7 @@ #include #include #include + #include TcPacketStored::TcPacketStored(store_address_t setAddress) : @@ -20,6 +21,8 @@ TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice, ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &p_data); if (returnValue != this->store->RETURN_OK) { + sif::warning << "TcPacketStored: Could not get free element from store!" + << std::endl; return; } this->setData(p_data); @@ -30,6 +33,15 @@ TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice, this->setErrorControl(); } +ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr, + size_t* dataSize) { + auto result = this->store->getData(storeAddress, dataPtr, dataSize); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "TcPacketStored: Could not get data!" << std::endl; + } + return result; +} + TcPacketStored::TcPacketStored() : TcPacketBase(NULL) { this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; diff --git a/tmtcpacket/pus/TcPacketStored.h b/tmtcpacket/pus/TcPacketStored.h index a9c49c2e..de3eb85f 100644 --- a/tmtcpacket/pus/TcPacketStored.h +++ b/tmtcpacket/pus/TcPacketStored.h @@ -74,6 +74,9 @@ public: * @param Size size of the packet. */ TcPacketStored( const uint8_t* data, uint32_t size); + + ReturnValue_t getData(const uint8_t ** dataPtr, + size_t* dataSize); /** * This is a getter for the current store address of the packet. * @return The current store address. The (raw) value is \c StorageManagerIF::INVALID_ADDRESS if