Merge pull request 'renamed printer to arrayprinter' (#98) from KSat/fsfw:mueller_globPrinterRenaming into master

This commit is contained in:
Steffen Gaisser 2020-06-08 12:09:17 +02:00
commit 514ff4f420
2 changed files with 12 additions and 13 deletions

View File

@ -1,25 +1,25 @@
#include <framework/globalfunctions/printer.h> #include <framework/globalfunctions/arrayprinter.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <bitset> #include <bitset>
void printer::print(const uint8_t *data, size_t size, OutputType type, void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
bool printInfo, size_t maxCharPerLine) { bool printInfo, size_t maxCharPerLine) {
if(printInfo) { if(printInfo) {
sif::info << "Printing data with size " << size << ": "; sif::info << "Printing data with size " << size << ": ";
} }
sif::info << "["; sif::info << "[";
if(type == OutputType::HEX) { if(type == OutputType::HEX) {
printer::printHex(data, size, maxCharPerLine); arrayprinter::printHex(data, size, maxCharPerLine);
} }
else if (type == OutputType::DEC) { else if (type == OutputType::DEC) {
printer::printDec(data, size, maxCharPerLine); arrayprinter::printDec(data, size, maxCharPerLine);
} }
else if(type == OutputType::BIN) { else if(type == OutputType::BIN) {
printer::printBin(data, size); arrayprinter::printBin(data, size);
} }
} }
void printer::printHex(const uint8_t *data, size_t size, void arrayprinter::printHex(const uint8_t *data, size_t size,
size_t maxCharPerLine) { size_t maxCharPerLine) {
sif::info << std::hex; sif::info << std::hex;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
@ -36,7 +36,7 @@ void printer::printHex(const uint8_t *data, size_t size,
sif::info << "]" << std::endl; sif::info << "]" << std::endl;
} }
void printer::printDec(const uint8_t *data, size_t size, void arrayprinter::printDec(const uint8_t *data, size_t size,
size_t maxCharPerLine) { size_t maxCharPerLine) {
sif::info << std::dec; sif::info << std::dec;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
@ -51,7 +51,7 @@ void printer::printDec(const uint8_t *data, size_t size,
sif::info << "]" << std::endl; sif::info << "]" << std::endl;
} }
void printer::printBin(const uint8_t *data, size_t size) { void arrayprinter::printBin(const uint8_t *data, size_t size) {
sif::info << "\n" << std::flush; sif::info << "\n" << std::flush;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
sif::info << "Byte " << i + 1 << ": 0b"<< sif::info << "Byte " << i + 1 << ": 0b"<<

View File

@ -1,16 +1,15 @@
#ifndef FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ #ifndef FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
#define FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ #define FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
namespace printer {
enum class OutputType { enum class OutputType {
DEC, DEC,
HEX, HEX,
BIN BIN
}; };
namespace arrayprinter {
void print(const 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); bool printInfo = true, size_t maxCharPerLine = 12);
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12); void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
@ -18,4 +17,4 @@ void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
void printBin(const uint8_t* data, size_t size); void printBin(const uint8_t* data, size_t size);
} }
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */ #endif /* FRAMEWORK_GLOBALFUNCTIONS_ARRAYPRINTER_H_ */