syscalls and print

OP #1172484
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
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
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

A question of your own? This thread is over 19 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.