Version 8.6 Buffering printf characters

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Version 8.6 Buffering printf characters

4,334 次查看
TomS
Contributor I
When using the printf function in Code Warrior 8.6 for a Power PC to output strings to a Hyper Terminal, I am finding the characters are not sent to the Hyper Terminal until 256 characters are in the output buffer or a '\n' is at the end of the string.
Is there a way to disable this buffering?  I figure it a compile condition I need to set.
 
Thanks
标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

2,015 次查看
TomS
Contributor I
Thanks Teo, that worked.
 
Now I'm having a problem with gets(). 
The carriage return isn't being read back fully and and the next time I call gets(), it thinks a the carriage return is there, and doesn't wait for key board input?
 
Do you know what can cause this?  This all worked with version 8.1
Thanks
0 项奖励
回复

2,015 次查看
Teo
NXP Employee
NXP Employee
You have to disable buffering for stdin also. If you choosed to recompile MSL this should have been done alreadey with the same macro (_MSL_BUFFERED_CONSOLE), i.e. by recompiling MSL you change buffering for all console files (stdin, stdout, stderr).


In case that you've changed buffering at runtime by calling "setvbuf", note that this is recomended to be done only once at the beggining of "main" before any console IO activities.

Regards,
Teo
0 项奖励
回复

2,015 次查看
Teo
NXP Employee
NXP Employee
You need either to recompile MSL library to not use console IO buffering, or you can change this at runtime with setvbuf. e.g. "setvbuf(stdout, NULL, _IONBF, 0);"

If you decide to recompile MSL, you need to change _MSL_BUFFERED_CONSOLE define to 0 in ansi_prefix.PPCEABI.bare.h.

Regards,
Teo
0 项奖励
回复