syscalls and print

OP #1172484
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
Moderator #1172485
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
OP #1172487
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!

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now