EmbDev.net

Forum: ARM programming with GCC/GNU tools syscalls and print


von Ed I. (edinsam)


Rate this post
useful
not useful
I have a simple test program that included syscalls.c as follows:

main()
{
  while(1) { printf("OK");
             delay1sec();
             flashLED() // works OK
           }
}


Program compiles and links OK.

My problem is that _write_r() doesn't get called for each character to
be output. The LED flashes every second as it should, but the system
seems to buffer output until about 1000 characters are stored
(internally somewhere), then _write_r() is called to dump the lot in one
go.

All syscalls.c stubs are as per documantations, i.e:

isatty_r() returns 1;
fsatst_r() stores st->st_mode = S_IFCHR; and returns 0;
write_r()
{ for (i = 0; i < len; i++) ser_Out(*p++);
}

ser_Out() is a standard UART output poll routine that has been fully
tested in isolation.


Any ideas what's going on? Are there any global buffer size variables
that need to be checked somewhere?

Thanks in advance

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Ed Insam wrote:
> ...
> Any ideas what's going on? Are there any global buffer size variables
> that need to be checked somewhere?
> ...

Call fflush(stdout) or use the function setvbuf to disable buffering for
stdout. Further information should be available in the newlib's
libc-manual.

Martin Thomas

von Clifford S. (clifford)


Rate this post
useful
not useful
Also, the text will be output when a newline is emited, so

printf("OK\n") ; will work also.

Clifford

von Ed I. (edinsam)


Rate this post
useful
not useful
Martin Thomas wrote:
> Ed Insam wrote:
>> ...
>> Any ideas what's going on? Are there any global buffer size variables
>> that need to be checked somewhere?
>> ...
>
> Call fflush(stdout) or use the function setvbuf to disable buffering for
> stdout. Further information should be available in the newlib's
> libc-manual.
>
> Martin Thomas

Thanks both!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.