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.

38 lines
750 B

2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
  1. #include "logger.hpp"
  2. #include <QApplication>
  3. #include <QDateTime>
  4. #include <QDebug>
  5. #include <QFile>
  6. void zos_log(const char* fmt, ...) {
  7. va_list args;
  8. va_start(args, fmt);
  9. char buf[1024] = {0};
  10. vsnprintf(buf, sizeof(buf), fmt, args);
  11. qInfo() << buf;
  12. va_end(args);
  13. }
  14. int32_t zos_get_ticket() { return (int32_t)QDateTime::currentMSecsSinceEpoch(); }
  15. std::string zhex2str(const uint8_t* hex, size_t len) {
  16. std::string str;
  17. for (size_t i = 0; i < len; i++) {
  18. char buf[3] = {0};
  19. snprintf(buf, sizeof(buf), "%02x ", hex[i]);
  20. str += buf;
  21. }
  22. return str;
  23. }
  24. std::string zhex2binary(uint8_t hex) {
  25. std::string str;
  26. for (int i = 0; i < 8; i++) {
  27. str += (hex & 0x80) ? "1" : "0";
  28. hex <<= 1;
  29. }
  30. return str;
  31. }