diff --git a/globalfunctions/printer.cpp b/globalfunctions/printer.cpp new file mode 100644 index 000000000..a68a91ee2 --- /dev/null +++ b/globalfunctions/printer.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +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 << ": "; + } + sif::info << "["; + if(type == OutputType::HEX) { + printer::printHex(data, size, maxCharPerLine); + } + else if (type == OutputType::DEC) { + printer::printDec(data, size, maxCharPerLine); + } + else if(type == OutputType::BIN) { + printer::printBin(data, size); + } +} + +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]); + if(i < size - 1){ + sif::info << " , "; + if(i > 0 and i % maxCharPerLine == 0) { + sif::info << std::endl; + } + } + + } + sif::info << std::dec; + sif::info << "]" << std::endl; +} + +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 << static_cast(data[i]); + if(i < size - 1){ + sif::info << " , "; + if(i > 0 and i % maxCharPerLine == 0) { + sif::info << std::endl; + } + } + } + sif::info << "]" << std::endl; +} + +void printer::printBin(const uint8_t *data, size_t size) { + sif::info << "\n" << std::flush; + for(size_t i = 0; i < size; i++) { + sif::info << "Byte " << i + 1 << ": 0b"<< + std::bitset<8>(data[i]) << ",\n" << std::flush; + } + sif::info << "]" << std::endl; +} diff --git a/globalfunctions/printer.h b/globalfunctions/printer.h new file mode 100644 index 000000000..33a382ecc --- /dev/null +++ b/globalfunctions/printer.h @@ -0,0 +1,21 @@ +#ifndef FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ +#define FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ +#include +#include + +namespace printer { + +enum class OutputType { + DEC, + HEX, + BIN +}; + +void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX, + bool printInfo = true, 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); +void printBin(const uint8_t* data, size_t size); +} + +#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */ diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index 2d61dea51..d842294ce 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -1,3 +1,12 @@ +<<<<<<< HEAD +======= +/** + * @file LocalPool + * @date 02.02.2012 + * @author Bastian Baetz + * @brief This file contains the definition of the LocalPool class. + */ +>>>>>>> upstream/master #ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ #define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ @@ -24,7 +33,6 @@ * The local pool is NOT thread-safe. * @author Bastian Baetz */ - template class LocalPool: public SystemObject, public StorageManagerIF { public: @@ -48,9 +56,10 @@ public: * number of elements for each pool is determined. * The position of these values correspond to those in * element_sizes. - * @param registered Register the pool in object manager or not. Default is false (local pool). - * @param spillsToHigherPools - * A variable to determine whether higher n pools are used if the store is full. + * @param registered Register the pool in object manager or not. + * Default is false (local pool). + * @param spillsToHigherPools A variable to determine whether + * higher n pools are used if the store is full. */ LocalPool(object_id_t setObjectId, const uint16_t element_sizes[NUMBER_OF_POOLS], @@ -117,7 +126,7 @@ private: /** * @brief store represents the actual memory pool. * @details It is an array of pointers to memory, which was allocated with - * a \c new call on construction. + * a @c new call on construction. */ uint8_t* store[NUMBER_OF_POOLS]; /** diff --git a/storagemanager/PoolManager.h b/storagemanager/PoolManager.h index 144d073de..cbb5d54ba 100644 --- a/storagemanager/PoolManager.h +++ b/storagemanager/PoolManager.h @@ -22,11 +22,20 @@ public: //! @brief In the PoolManager's destructor all allocated memory is freed. virtual ~PoolManager(); +<<<<<<< HEAD //! @brief LocalPool overrides for thread-safety. Decorator function which //! wraps LocalPool calls with a mutex protection. ReturnValue_t deleteData(store_address_t) override; ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId = nullptr) override; +======= + //! @brief LocalPool overrides for thread-safety. + ReturnValue_t deleteData(store_address_t) override; + ReturnValue_t deleteData(uint8_t* buffer, size_t size, + store_address_t* storeId = NULL) override; + ReturnValue_t modifyData(store_address_t packet_id, uint8_t** packet_ptr, + size_t* size) override; +>>>>>>> upstream/master protected: ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address, bool ignoreFault) override;