From e2e6ec28c0cac7f79ff301481cd803fbfe8bbc7f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 19 May 2020 20:26:12 +0200 Subject: [PATCH] printer fixes and improvements --- globalfunctions/printer.cpp | 12 +++++++----- globalfunctions/printer.h | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/globalfunctions/printer.cpp b/globalfunctions/printer.cpp index 01ec532c..b71d70b8 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,8 @@ 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 +32,11 @@ 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_ */