Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
rt_kprintf
rt-thread自己实现可变长度printf报错
发布于 2021-03-22 19:25:32 浏览:1109
订阅该版
各位大佬们,我在用rt-thread的时候,发现用标准c实现的可变长度的printf函数时,rt-thread就会报错了,是硬件错误,不知道为啥
查看更多
3
个回答
默认排序
按发布时间排序
军城Justin
2021-03-22
这家伙很懒,什么也没写!

flashman2002
2021-03-22
这家伙很懒,什么也没写!
可以参考rtt的源码,在kservice.c中: ``` /** * This function will print a formatted string on system console * * @param fmt the format */ void rt_kprintf(const char *fmt, ...) { va_list args; rt_size_t length; static char rt_log_buf[RT_CONSOLEBUF_SIZE]; va_start(args, fmt); /* the return value of vsnprintf is the number of bytes that would be * written to buffer had if the size of the buffer been sufficiently * large excluding the terminating null byte. If the output string * would be larger than the rt_log_buf, we have to adjust the output * length. */ length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args); if (length > RT_CONSOLEBUF_SIZE - 1) length = RT_CONSOLEBUF_SIZE - 1; #ifdef RT_USING_DEVICE if (_console_device == RT_NULL) { rt_hw_console_output(rt_log_buf); } else { rt_uint16_t old_flag = _console_device->open_flag; _console_device->open_flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(_console_device, 0, rt_log_buf, length); _console_device->open_flag = old_flag; } #else rt_hw_console_output(rt_log_buf); #endif va_end(args); } RTM_EXPORT(rt_kprintf); ```
cxhxy12345
2021-03-22
这家伙很懒,什么也没写!
va_start()...是一个重载函数,标准C是不支持的。如果你要用到,需要在编译前打开C++支持功能。 这样解惑不知能不能给你帮助,如有帮助给点个采纳~~~~
撰写答案
登录
注册新账号
关注者
0
被浏览
1.1k
关于作者
军城Justin
这家伙很懒,什么也没写!
提问
2
回答
1
被采纳
0
关注TA
发私信
相关问题
1
rt_kprintf问题,拔掉串口系统就不运行了么?
2
rt_kprintf打印异常
3
开启C++功能后,rt_kprintf和单步调试功能无法使用
4
大家有什么好用的方法开关串口打印吗
5
rt_kprintf 格式描述符
6
怎么实现printf函数打印浮点数?
7
rt_kprintf串口打印信息有时出现乱码,有时候又是正常的
8
GD32E230k开发板,打开终端窗口中最后一行是这样的,是什么问题,怎么解决?
9
rt_thread studio rt_kprintf输出中文乱码?
10
关于rt_kprintf无法显示浮点数
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
CherryUSB STM32 glue 新增初始化
2
在LPC1114上移植 RT-Thread Nano 3.1.5
3
求助can通讯下怎末运用485
4
STM32F407ZGT适配串口V2驱动
5
【CFP】2025 RT-Thread全球技术大会演讲征集开始啦!
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
I2C_IIC
cubemx
UART
ESP8266
WIZnet_W5500
BSP
ota在线升级
PWM
flash
packages_软件包
freemodbus
潘多拉开发板_Pandora
ADC
GD32
定时器
flashDB
编译报错
keil_MDK
socket
中断
rt_mq_消息队列_msg_queue
Debug
ulog
SFUD
msh
C++_cpp
at_device
本月问答贡献
聚散无由
9
个答案
6
次被采纳
RTT_逍遥
10
个答案
2
次被采纳
a1012112796
5
个答案
2
次被采纳
三世执戟
4
个答案
2
次被采纳
加缪
2
个答案
2
次被采纳
本月文章贡献
wake_mirco
2
篇文章
7
次点赞
mushroom
1
篇文章
9
次点赞
张世争
1
篇文章
7
次点赞
RTT_逍遥
1
篇文章
6
次点赞
Jack_____
1
篇文章
5
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部