char 转二进制string 打印出来
#define MESSAGE_MAX_COUNT 32
static void audio_message_to_string(char* dest_str, const char* msg, int msg_length)
{
int str_idx = 0, i = 0;
int uiMsgLen = (msg_length <= MESSAGE_MAX_COUNT ? msg_length : MESSAGE_MAX_COUNT);
for (; i < uiMsgLen; ++i) {
if (str_idx < AUDIO_MESSAGE_MAX_COUNT - 4) {
snprintf(dest_str + str_idx, 4, "%02X ", msg[i]);
str_idx += 3;
}
}
if (str_idx < AUDIO_MESSAGE_MAX_COUNT){
dest_str[str_idx] = 0;
} else {
dest_str[AUDIO_MESSAGE_MAX_COUNT - 1] = 0;
}
}
char acMsg[MESSAGE_MAX_COUNT] = {0};
audio_message_to_string(acMsg, buf, count);
pr_info("write: %s" , acMsg);