嵌入式开发者社区

标题: 串口打印 [打印本页]

作者: 红线绕指柔    时间: 2019-4-22 15:35
标题: 串口打印
double xiangwei=3.1415926;double fuzhi=3.1415926;
UARTprintf("fuzhi:%f and xiangwei:%f\n",fuzhi,xiangwei);

如上所示的代码,我使用串口发送到串口调试助手上显示,为什么串口调试助手显示浮点数时会出现这种情况[attach]5013[/attach]这是串口调试助手的显示问题还是串口本身的原因啊

作者: 广州创龙莫工    时间: 2019-4-23 18:41
不支持浮点输出,要用sprintf转换成字符串再输出。
作者: 785235014    时间: 2019-5-5 22:33
void UARTprintf (const char * pcString,
...
)

A simple UART based printf function supporting %c, %d, %p, %s, %u, %x, and %X.
Parameters
pcStringis the format string.
...are the optional arguments, which depend on the contents of the format string.
This function is very similar to the C library fprintf() function. All of its output will be sent to the UART. Only the following formatting characters are supported:
For %s, %d, %u, %p, %x, and %X, an optional number may reside between the % and the format character, which specifies the minimum number of characters to use for that value; if preceded by a 0 then the extra characters will be filled with zeros instead of spaces. For example, \%8d'' will use eight characters to print the decimal value with spaces added to reach eight;%08d'' will use eight characters as well but will add zeroes instead of spaces.
The type of the arguments after pcString must match the requirements of the format string. For example, if an integer was passed where a string was expected, an error of some kind will most likely occur.
ReturnsNone.上面说的这个函数不是不能打印浮点型得嘛



作者: shayingzhe    时间: 2020-12-9 21:11
您好,请问你这些函数的说明怎么查的?





欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4