1
0
forked from fsfw/fsfw

binary printer added

This commit is contained in:
2020-05-19 23:07:28 +02:00
parent 9b53e2b64f
commit 338651af2f
2 changed files with 17 additions and 2 deletions

View File

@ -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;
}