展讯平台如何调试之打LOG--串口log
2012-04-04 18:27
387 查看
接上一篇,因为当时项目急,可以用了也没去研究,现在省出来点玩DOTA的时间记录一下,就说那个串口输出函数吧,各种宏,他感觉那样好,其实更不好理解,我们可以尝试把宏替代进去就形成了这么一个函数。
嗯,这样就舒坦多了。其实这样就是标C里面的printf函数,其关键无非就是va_list、va_start、va_end!
关于这组被包含在stdarg.h头里面的函数,在网上已经传栏了,我也不过多阐述了!其实,在网上我看到别人写的类如此的函数可以贴出来。
http://www.cnblogs.com/rainduck/archive/2010/11/10/1873417.html
这样就是自己写的printf函数!
#define TF_STACK_LIMIT 0x10000 #define SIO_TX_EMPTY(s) ((s) & 0xFF00) #define WAIT_FIFO_EMPTY \ { \ while( SIO_TX_EMPTY(*(volatile uint32*)(0x8400000c)));\ }
LOCAL void WriteCharToUART(char c) { while ((((*(volatile uint32*)0x8400000c) >> 8 )&0xFF) >= 32 ) {}; *(volatile uint32*)0x84000000 = c; }
LOCAL void TF_SendMsgOut(char * buf, int size) { while (size --) { WriteCharToUART(*(buf++)); } WriteCharToUART('\r'); WriteCharToUART('\n'); }
PUBLIC void TF_UartTrace( const char *x_format, ...) { char format_str[256]; va_list args; int nBuf; WAIT_FIFO_EMPTY memset (format_str,0,256); va_start(args, x_format);\ nBuf = vsprintf(format_str, x_format, args);\ /* was there an error? */\ /* Was the expanded string too long? */\ va_end(args);\ /* Send message to serial buffer! */ \ TF_SendMsgOut(format_str, nBuf + 1); WAIT_FIFO_EMPTY }
嗯,这样就舒坦多了。其实这样就是标C里面的printf函数,其关键无非就是va_list、va_start、va_end!
关于这组被包含在stdarg.h头里面的函数,在网上已经传栏了,我也不过多阐述了!其实,在网上我看到别人写的类如此的函数可以贴出来。
http://www.cnblogs.com/rainduck/archive/2010/11/10/1873417.html
这样就是自己写的printf函数!
相关文章推荐
- 展讯平台如何调试之打LOG--串口log
- 展讯平台如何调试之assert的串口打印
- wince 6.0 如何把调试串口改为普通串口
- 如何提高keil串口的调试效率
- 如何修改安卓默认调试等级以及串口输出
- 展讯平台调试之文件输出LOG
- 如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- LINUX系统的调试信息是如何从串口输出的
- 如何正确打开华为手机的 USB 调试和 完整 log 功能?
- Expo大作战(六)--expo开发模式,expo中exp命令行工具,expo中如何查看日志log,expo中的调试方式
- 【已解决】 c8812在eclipse上调试打不出log来?求帮助如何解决?!!!
- 如何在WinCE模拟器中调试串口程序
- android开发板只有网口和串口如何使用android studio进行调试
- 如何关闭cocos2d调试时输出的log
- 【MTK6572】如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- 如何在WinCE模拟器中调试串口程序(两台设备、一台设备的两种情况下的串口调试)
- 如何在WinCE模拟器中调试串口程序
- android studio如何导入和运行调试unity导出的项目,并查看log日志?(或者说:android studio如何导入eclipse项目?)
- [FAQ03891] 如何在User版本开启串口(Uart),抓取上层Log,开启输入控制台
- 如何在一台电脑上调试串口收发数据