updated printer
This commit is contained in:
parent
effac0e9b7
commit
e92c324c7e
@ -1,13 +1,34 @@
|
|||||||
#include <framework/globalfunctions/printer.h>
|
#include <framework/globalfunctions/printer.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
void printer::print(uint8_t *data, size_t size) {
|
void printer::print(uint8_t *data, size_t size, OutputType type) {
|
||||||
sif::info << "StorageAccessor: Printing data: [";
|
sif::info << "StorageAccessor: Printing data: [";
|
||||||
|
if(type == OutputType::HEX) {
|
||||||
|
printer::printHex(data, size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printer::printDec(data, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printer::printHex(uint8_t *data, size_t size) {
|
||||||
|
sif::info << std::hex;
|
||||||
for(size_t i = 0; i < size; i++) {
|
for(size_t i = 0; i < size; i++) {
|
||||||
sif::info << std::hex << (int)data[i];
|
sif::info << "0x" << static_cast<int>(data[i]);
|
||||||
if(i < size - 1){
|
if(i < size - 1){
|
||||||
sif::info << " , ";
|
sif::info << " , ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sif::info << std::dec;
|
||||||
sif::info << " ] " << std::endl;
|
sif::info << " ] " << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printer::printDec(uint8_t *data, size_t size) {
|
||||||
|
for(size_t i = 0; i < size; i++) {
|
||||||
|
sif::info << "0x" << static_cast<int>(data[i]);
|
||||||
|
if(i < size - 1){
|
||||||
|
sif::info << " , ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,15 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace printer {
|
namespace printer {
|
||||||
void print(uint8_t *data, size_t size);
|
|
||||||
|
enum class OutputType {
|
||||||
|
DEC,
|
||||||
|
HEX
|
||||||
|
};
|
||||||
|
|
||||||
|
void print(uint8_t* data, size_t size, OutputType type = OutputType::HEX);
|
||||||
|
void printHex(uint8_t* data, size_t size);
|
||||||
|
void printDec(uint8_t* data, size_t size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user