You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
849 B

#include "logger.hpp"
#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QFile>
void zos_log(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
char buf[1024] = {0};
vsnprintf(buf, sizeof(buf), fmt, args);
qInfo() << buf;
va_end(args);
}
int32_t zos_get_ticket() { return (int32_t)QDateTime::currentMSecsSinceEpoch(); }
std::string zhex2str(const uint8_t* hex, size_t len) {
std::string str;
for (size_t i = 0; i < len; i++) {
char buf[10] = {0};
if(i == len - 1) {
snprintf(buf, sizeof(buf), "0x%02x", hex[i]);
} else {
snprintf(buf, sizeof(buf), "0x%02x,", hex[i]);
}
str += buf;
}
return str;
}
std::string zhex2binary(uint8_t hex) {
std::string str;
for (int i = 0; i < 8; i++) {
str += (hex & 0x80) ? "1" : "0";
hex <<= 1;
}
return str;
}