c++ 打印串

【摘要】 __attribute__((unused))  __maybe_unused static std::string print_sha1(const uint8_t* sha1, size_t len) {   const char* hex = “0123456789abcdef”;   std::string result = “”;   for (size_t i =…

__attribute__((unused))__maybe_unused
static std::string print_sha1(const uint8_t* sha1, size_t len) {
const char* hex = “0123456789abcdef”;
std::string result = “”;
for (size_t i = 0; i < len; ++i) {
result.push_back(hex[(sha1[i] >> 4) & 0xf]);
result.push_back(hex[sha1[i] & 0xf]);
}
return result;
}

static std::string print_a_char( uint8_t input_char )
{
const char* hex = “0123456789abcdef”;
std::string result = “”;
result.push_back( hex[(input_char >> 0x04) & 0xf] );
result.push_back( hex[(input_char >> 0x00) & 0xf] );
return result;
}

uint8_t *p;

p = (uint8_t *)data.data();

if( (int)p[16] == 17 ){
;
} else{
LOG(ERROR) << “\n\nSendMessageInternal: packet = ” << data.size();
LOG(ERROR) << “SendMessageInternal: fd = ” << fd;
LOG(ERROR) << “SendMessageInternal: cmd1 = ” << print_a_char( p[16] );
LOG(ERROR) << “SendMessageInternal: cmd2 = ” << std::hex << (int)p[16];
LOG(ERROR) << “SendMessageInternal: cmd2 = ” << std::dec << (int)p[16];
LOG(ERROR) << “send buffer:” << print_sha1(data.data(), data.size());

//android 日志一次性能打印1024字符,超过部分应该分开来打印
}

文章来源: blog.csdn.net,作者:dddddppppp123,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/dp__mcu/article/details/116449005

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享