bin printer added
This commit is contained in:
parent
e2e6ec28c0
commit
6961b5e866
@ -1,5 +1,6 @@
|
||||
#include <framework/globalfunctions/printer.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <bitset>
|
||||
|
||||
void printer::print(const uint8_t *data, size_t size, OutputType type,
|
||||
bool printInfo, size_t maxCharPerLine) {
|
||||
@ -10,9 +11,12 @@ void printer::print(const uint8_t *data, size_t size, OutputType type,
|
||||
if(type == OutputType::HEX) {
|
||||
printer::printHex(data, size, maxCharPerLine);
|
||||
}
|
||||
else {
|
||||
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,
|
||||
@ -46,3 +50,12 @@ void printer::printDec(const uint8_t *data, size_t size,
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -7,13 +7,15 @@ namespace printer {
|
||||
|
||||
enum class OutputType {
|
||||
DEC,
|
||||
HEX
|
||||
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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user