打印代码如下,并且打印时会出现乱码不知是何原因?
void TaskUARTdoWrite(uint8_t *buf, uint16_t len, const char* format, …)
{
if(buf == NULL)
{
va_list arg;
va_start(arg,format);
uint8_t pbuf[200];
uint16_t plen;
plen = vsprintf((char*)pbuf, format, arg);
Uart_TxTempLen = plen;
memcpy(Uart_TxTempBuf, pbuf, plen);
}
else
{
Uart_TxTempLen = len;
memcpy(Uart_TxTempBuf, buf, len);
}
Event_post(hUartEvent, UARTTASK_TX_EVENT);
}
乱码打印出的如下所示:
12
0253
0251
0橫R0231
0252
0252
0250
0252
0252
0247
0252
0251
?51
0252
0252
02ML?252
0251
02?
0252
0253
11
0253
0252
0252
0251
0252
Viki Shi:
用System_printf()转一下格式:rtsc.eclipse.org/…/System.html
CONVERSION SPECIFIERS
The following conversion specifiers are supported.
d, i signed integer
u unsigned decimal
x unsigned hex
o unsigned octal
p pointer (@ + hex num)
c character
s string