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

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 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[10] = {0};
  19. if(i == len - 1) {
  20. snprintf(buf, sizeof(buf), "0x%02x", hex[i]);
  21. } else {
  22. snprintf(buf, sizeof(buf), "0x%02x,", hex[i]);
  23. }
  24. str += buf;
  25. }
  26. return str;
  27. }
  28. std::string zhex2binary(uint8_t hex) {
  29. std::string str;
  30. for (int i = 0; i < 8; i++) {
  31. str += (hex & 0x80) ? "1" : "0";
  32. hex <<= 1;
  33. }
  34. return str;
  35. }