Version 8.6 Buffering printf characters

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Version 8.6 Buffering printf characters

3,240 Views
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
Labels (1)
0 Kudos
3 Replies

921 Views
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 Kudos

921 Views
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 Kudos

921 Views
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 Kudos