和上面大佬的思路差不多,我个人常用的,仅参考
unsigned char code ASCLIB[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
void printf_tx_len_hextoasc(unsigned char *in_buff , unsigned int buff_len)
{
while(buff_len-- > 1)
{
printf("%c",ASCLIB[*in_buff >> 4]);
printf("%c",ASCLIB[*in_buff++ & 0x0f]);
printf("%c",0x20);
}
//最后一个字节
printf("%c",ASCLIB[*in_buff >> 4]);
printf("%c",ASCLIB[*in_buff & 0x0f]);
}
|